Skip to content

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

Open

Description

@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

Activity

  1. added
    bug
    app
    windows-os
    tool-calls
    on Mar 10, 2026
  2. CircuitCM commented on Mar 13, 2026

    @CircuitCM

    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 -NoProfileLoadTime
    I 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 invalid when codex tries exec_command.

    Is there any chance we can get support for launch scripts in addition to the executables?
    Image

  3. removed
    tool-calls
    on Mar 30, 2026
  4. added
    terminal
    on Apr 24, 2026
  5. PatrickSys commented on Aug 9, 2026

    @PatrickSys

    Confirming a current Windows Codex Desktop reproduction of the same pre-execution failure.

    Environment:

    • Windows 11 Pro, x64, build 10.0.26200
    • Codex Desktop/app version: unavailable from the affected task
    • Bundled CLI version: unknown
    • Filesystem profile: unrestricted / danger-full-access
    • Approval policy: never

    Reproduction matrix:

    Parent functions.shell_command call Result
    Get-Location fails before execution
    pwd, with login:false same failure
    git status --short same failure
    Other parent shell_command calls same failure

    Actual error:

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

    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_command bridge rather than a general inability to execute commands on the host. login:false does 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

WSL & Terminalappbugterminalwindows-os

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions