Windows app 26.422.8496.0: all shell commands fail with "batch file arguments are invalid" after update

Resolved 💬 2 comments Opened Apr 28, 2026 by agent-wrangler Closed Aug 5, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

Summary

After updating Codex Windows app on 2026-04-28, all agent shell commands fail before execution with:

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

This happens even for minimal commands such as Get-Location and pwd.

Environment

  • Platform: Windows x64
  • Codex app package: OpenAI.Codex
  • Codex app version: 26.422.8496.0
  • Package full name: OpenAI.Codex_26.422.8496.0_x64__2p2nqsd0c76g0
  • Shell context: PowerShell

Minimal repro

  1. Open Codex Windows app.
  2. Open any thread/workspace.
  3. Ask the agent to run a minimal command:
  • Get-Location
  • or pwd
  1. The command fails immediately with:
Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

Diagnostics already checked

Direct process launch outside the Codex shell tool works on the same machine:

  • cmd.exe /d /s /c echo OK_CMD succeeds.
  • WindowsPowerShell\v1.0\powershell.exe -NoProfile ... succeeds.
  • Windows PowerShell version observed: 5.1.22621.6060.

Get-Command pwsh -All shows a .cmd shim before the real PowerShell executable:

C:\Users\<USER>\AppData\Local\Microsoft\WindowsApps\pwsh.cmd
C:\Users\<USER>\AppData\Local\Programs\PowerShell\7\pwsh.exe

PowerShell 7 version observed: 7.4.15.

I also changed Codex config from:

[windows]
sandbox = "elevated"

to:

[windows]
sandbox = "unelevated"

The current thread still fails, so either the setting requires app restart or the failure occurs before this setting helps.

Expected behavior

The shell tool should execute minimal commands normally, or fall back to a valid PowerShell executable instead of failing during command launch.

Related context

There are recent Windows app / sandbox / child process environment issues, for example:
https://github.com/openai/codex/issues/18248

View original on GitHub ↗

2 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #18937
  • #19550

Powered by Codex Action

agent-wrangler · 4 months ago

Verified local workaround and likely root cause

I was able to recover the shell tool on this machine.

Root cause observed locally

Before the workaround, pwsh resolved first to a WindowsApps .cmd shim:

C:\Users\<USER>\AppData\Local\Microsoft\WindowsApps\pwsh.cmd
C:\Users\<USER>\AppData\Local\Programs\PowerShell\7\pwsh.exe

The shim content was:

@echo off
"%LOCALAPPDATA%\Programs\PowerShell\7\pwsh.exe" %*

Launching the shim directly failed locally:

absolute pwsh.cmd -> spawn EINVAL

Launching the real executable worked:

absolute pwsh.exe -> 7.4.15

Workaround that fixed Codex App

I renamed the WindowsApps shim instead of deleting it:

C:\Users\<USER>\AppData\Local\Microsoft\WindowsApps\pwsh.cmd
->
C:\Users\<USER>\AppData\Local\Microsoft\WindowsApps\pwsh.cmd.codex-bak

After that, Get-Command pwsh -All resolved directly to:

C:\Users\<USER>\AppData\Local\Programs\PowerShell\7\pwsh.exe

Then I fully restarted the Codex Windows app. After restart, the shell tool recovered and a minimal tool call succeeded:

Get-Location

Output:

D:\agent-task-market-stitch

Suggested fix direction

On Windows, Codex shell resolution should probably avoid selecting .cmd / .bat shims for pwsh when a real pwsh.exe is available later in PATH, or explicitly prefer executable candidates such as:

pwsh.exe
powershell.exe

instead of invoking the WindowsApps command shim.