Windows native mode fails with "batch file arguments are invalid" when pwsh resolves to a .cmd shim

Open 💬 2 comments Opened Mar 10, 2026 by constansino

Summary

On Codex Desktop for Windows, all agent commands can fail before execution with:

execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

Environment

  • Codex Desktop (Microsoft Store): 26.306.996.0
  • Windows: 10.0.26200.7922
  • Integrated terminal shell: PowerShell 7.5.4
  • Agent mode: Windows native

What happened

Even trivial commands failed:

  • Write-Output hi
  • Get-Location
  • git status -sb
  • cmd.exe /c echo hi

The integrated terminal still appeared normal, which made this hard to diagnose.

Trigger / likely root cause

In this setup, pwsh resolved from PATH to a batch wrapper instead of the real pwsh.exe, e.g.:

C:\Users\...\AppData\Local\Programs\Python\Python313\Scripts\pwsh.cmd

Contents:

@echo off
"C:\Program Files\PowerShell\7\pwsh.exe" %*

Codex's Windows command runner appears to reject this .cmd shim when arguments are passed through it, and fails before the target command starts.

Why I think this is the trigger

  • All commands failed with the exact same error, including cmd.exe /c echo hi
  • Renaming/removing the pwsh.cmd shim fixed the issue immediately
  • Moving C:\Program Files\PowerShell\7\ earlier in PATH also fixed it
  • A patched desktop copy using newer Codex binaries still reproduced the same failure, so this did not look like a simple bundled-version mismatch

Possible repro

  1. Put a pwsh.cmd wrapper earlier in PATH than the real pwsh.exe
  2. Launch Codex Desktop on Windows in Windows native mode with PowerShell
  3. Run any agent command
  4. Observe batch file arguments are invalid

Suggested handling

It would help if Codex on Windows either:

  1. resolved pwsh.exe directly instead of accepting a .cmd shim from PATH, or
  2. surfaced a more actionable error when pwsh resolves to .cmd / .bat

Workaround

Ensure where pwsh resolves to the real pwsh.exe, not a batch wrapper.

Optional longer write-up (just as a debugging archive, not promotion):
https://aiya.de5.net/t/topic/119/1

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗