Windows native mode fails with "batch file arguments are invalid" when pwsh resolves to a .cmd shim
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 hiGet-Locationgit status -sbcmd.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.cmdshim fixed the issue immediately - Moving
C:\Program Files\PowerShell\7\earlier inPATHalso 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
- Put a
pwsh.cmdwrapper earlier inPATHthan the realpwsh.exe - Launch Codex Desktop on Windows in
Windows nativemode with PowerShell - Run any agent command
- Observe
batch file arguments are invalid
Suggested handling
It would help if Codex on Windows either:
- resolved
pwsh.exedirectly instead of accepting a.cmdshim fromPATH, or - surfaced a more actionable error when
pwshresolves 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
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗