Windows exec environment drops WINDIR and crashes self-contained WPF apps during font initialization

Resolved 💬 0 comments Opened Jul 27, 2026 by Guffawaffle Closed Aug 20, 2026

Codex version

codex-cli 0.145.0

Environment

  • Windows (Microsoft Windows NT 10.0.26200.0)
  • PowerShell 7
  • .NET SDK 8.0.423
  • Codex unified exec session

Problem

Commands started through Codex inherit SystemRoot=C:\WINDOWS but no WINDIR environment variable. A self-contained .NET 8 WPF application then crashes before creating its first window because WPF font initialization receives an invalid Windows-font URI.

The .NET Runtime event is:

System.Windows.Markup.XamlParseException
 ---> System.TypeInitializationException: System.Windows.Window
 ---> System.TypeInitializationException: System.Windows.FrameworkElement
 ---> System.TypeInitializationException: System.Windows.Documents.TextElement
 ---> System.TypeInitializationException: MS.Internal.FontCache.Util
 ---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.

Reproduction

From a Codex Windows exec command:

[pscustomobject]@{
  WINDIR = $env:WINDIR
  SystemRoot = $env:SystemRoot
}

Observed:

{"WINDIR":null,"SystemRoot":"C:\\WINDOWS"}

Launch a minimal self-contained .NET 8 WPF executable. The process terminates before showing a window with the exception above.

Then restore the standard variable before launching:

$env:WINDIR = $env:SystemRoot
Start-Process .\MinimalWpfApp.exe

The same executable starts and renders correctly.

Expected behavior

Windows processes launched by Codex should inherit the standard WINDIR variable, or the exec environment should normalize it from SystemRoot when it is absent.

Impact

This produces false application-startup failures during Windows desktop development and can be mistaken for a packaging or XAML defect. It blocks reliable WPF/Windows UI validation unless the caller knows to restore the missing environment variable manually.

Workaround

Set $env:WINDIR = $env:SystemRoot before launching the WPF process.

View original on GitHub ↗