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
3 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I am running into the same issue. I have pwsh.cmd however I use this start config:
"C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NonInteractive -NoProfileLoadTimeI also use tty: false.
All of these together let me remove the artificial line breaks and ANSI color codes that mess up the formatting of my scripts and act as noise. In the CLI I was able to get around this by calling my pwsh.cmd first, then calling codex. But now that I want to use the app there doesn't seem to be a simple workaround. I am also getting
Failed to create unified exec process: batch file arguments are invalidwhen codex tries exec_command.Is there any chance we can get support for launch scripts in addition to the executables?
<img width="746" height="482" alt="Image" src="https://github.com/user-attachments/assets/9a86220a-3def-450f-8261-fc8e6139fd0a" />
Confirming a current Windows Codex Desktop reproduction of the same pre-execution failure.
Environment:
Reproduction matrix:
| Parent
functions.shell_commandcall | Result ||---|---|
|
Get-Location| fails before execution ||
pwd, withlogin:false| same failure ||
git status --short| same failure || Other parent
shell_commandcalls | same failure |Actual error:
Expected behavior: trivial commands should execute and return output, regardless of login mode or permission profile.
In the same task, Node REPL and a delegated subagent shell still work. This suggests the failure is isolated to the parent Desktop
shell_commandbridge rather than a general inability to execute commands on the host.login:falsedoes not change the result.Temporary workaround: use the delegated subagent shell or Node REPL. I could not verify local PowerShell PATH resolution because the failing bridge prevents that check.