Windows sandbox command runner fails with CreateProcessAsUserW failed: 1312
Open 💬 5 comments Opened Jun 25, 2026 by martinmclee
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
What issue are you seeing?
Native Codex shell execution fails with:
windows sandbox: runner error: CreateProcessAsUserW failed: 1312
in non-escalated runs, even for trivial read-only commands.
Versions
- OS: Windows 11 x64
- Codex app/runtime: 26.616.81150 UI, runtime path under
%PROGRAMFILES%\WindowsApps\OpenAI.Codex_* - app sandbox config:
sandbox_mode = "danger-full-access",[windows] sandbox = "unelevated" - issue observed on
2026-06-25after normal tool activity
Minimal repro
- Run any trivial command such as
Get-Location. - Non-elevated command execution returns:
windows sandbox: runner error: CreateProcessAsUserW failed: 1312
Direct tool output
When invoking the same command path from non-escalated shell execution:Get-Location | Format-List -Property Path
Observed:execution error: Io(Custom { kind: Other, error: "windows sandbox: runner error: CreateProcessAsUserW failed: 1312" })
Additional notes
- Escalated execution path still works for file read commands and shell command preparation.
rgand shell attempts show sandbox setup starts and succeeds in.codex/.sandbox/sandbox.2026-06-25.log, including:setup refresh: processed 3 write roots (read roots delegated); errors=[]read ACL run completed- Yet command invocation fails with
CreateProcessAsUserW failed: 1312at runner boundary. - Attempted non-destructive recovery (state folder rollback only) did not restore execution.
Expected behavior
Simple read-only command calls (no external tooling, no writes) should execute.
Actual behavior
Command execution fails at sandbox run boundary with CreateProcessAsUserW failed: 1312.
I did not restart Codex as a workaround for this repro.
5 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I’m seeing the same failure on Windows 11 in the Codex desktop app:
CreateProcessAsUserW failed: 1312Even a harmless command such as:
Get-Locationfails before PowerShell starts.
My environment:
Troubleshooting already completed:
The issue does not appear related to the selected project folder because Codex correctly identifies the workspace path, but the local command runner fails before launching PowerShell.
I also submitted a performance trace.
Feedback ID:
019effb7-0ad1-74e1-87d9-e65a722c4a99I encountered a Windows sandbox command execution failure in the Codex desktop app on Windows 11:
CreateProcessAsUserW failed: 1312Even a harmless read-only command such as:
fails before PowerShell starts.
Environment:
workspace-write26.727.6591.0Observed behavior:
The command fails under normal permissions with:
The same command succeeds when run with elevated permissions, and Codex can then read files from the workspace normally.
This does not appear to be related to the command or project files, since the same read-only command works with elevated permissions. The issue seems to be that the Windows Native sandbox cannot create a PowerShell user session when running without elevation.
Expected behavior:
Codex should be able to execute read-only PowerShell commands under normal permissions without requiring elevation.
Verified workaround on one Windows 11 / Codex Desktop machine
I reproduced the exact failure from this issue:
Even a trivial
Write-Outputcommand failed before execution.Environment
OpenAI.Codex_26.803.5235.00.147.0-alpha.6.5CodexSandboxOnlineandCodexSandboxOfflineexisted and were enablederrors=[]What was different on this machine
pwshresolved to:That path was a tiny App Execution Alias / activation stub rather than a standalone PowerShell executable. This matches the explanation in openai/codex-plugin-cc#336.
Workaround that restored command execution
%LOCALAPPDATA%\Programs\PowerShell\7.where.exe pwshselected the real executable before the WindowsApps alias.The Store alias was left installed. I did not reset the sandbox users or delete Codex state/databases.
Verification after the restart
Get-Command pwshresolved to the standalone PowerShell 7.6.4 executable.RUNNER_OK.codex execsmoke test used the standalonepwsh.exepath and returnedNESTED_RUNNER_OK.On this machine, having a real PowerShell executable first in PATH plus a full Codex process restart was the important combination. This is a verified workaround for this environment, not proof that every 1312 report has the same root cause.
A robust product-side fix may be to reject Windows App Execution Alias targets for the sandbox shell and retry with a standalone
pwsh.exewhen process creation returns 1312.I can reproduce the same
CreateProcessAsUserW failed: 1312failure with a minimal read-only PowerShell command.Environment:
0.147.026200.8973[windows] sandbox = "elevated"Write-Output CODEX_TOOLSTART_OKThe child process fails before PowerShell executes. The parent
codex execprocess may still return exit code 0, while the session correctly reports:I reproduced this in three fresh ephemeral/read-only sessions:
The first two failures attempted to launch the Windows Store package executable:
The interactive reproduction attempted to launch the App Execution Alias:
Both paths failed with 1312. There is currently no standalone PowerShell executable at
C:\Program Files\PowerShell\7\pwsh.exeor%LOCALAPPDATA%\Programs\PowerShell\7\pwsh.exeon this machine.This makes the standalone-PowerShell workaround reported in the latest comment plausible, but it has not been tested here. The alias alone may not explain every failure because two reproductions used the Store package executable directly.
The workspace remained unchanged and the failure is independent of the project command or files. The existing
CODEX_HOME/.sandbox/sandbox.logis stale (last updated 2026-05-29) and contains no matching 1312 entry, so I am not attaching it as current evidence.I can provide the three session IDs privately if useful. No
.sandbox-secrets, tokens, environment values, or local user paths are included.