Windows sandbox: command execution fails with `CreateProcessWithLogonW failed: 5`
What version of Codex is running?
codex-cli 0.80.0
What subscription do you have?
ChatGPT Plus
Which model were you using?
gpt-5.2 (reasoning medium, summaries auto)
What platform is your computer?
Microsoft Windows NT 10.0.17763.0 x64
What issue are you seeing?
After upgrading to Codex CLI v0.80.0 on native Windows, agent mode started prompting for approval for almost every command, including simple read-only commands inside the workspace (for example cmd.exe /c type AGENTS.md). In addition, command execution inside the Windows sandbox fails with:
windows sandbox: CreateProcessWithLogonW failed: 5
This prevents apply_patch and even basic commands from running. The behavior persisted even after downgrading to v0.79.0, until I forced a sandbox re-onboarding flow (disable experimental_windows_sandbox, restart, then accept the “Enable experimental sandbox” onboarding prompt). After that re-onboarding, sandbox execution worked again and the patch could be applied.
Also, release notes mention /elevate-sandbox, but the command is not recognized and is not present in the slash command list in my TUI session.
Finally, approval mode appears inconsistent during onboarding: /status showed Approval: on-request even though config.toml had approval_policy = "on-failure". After codex resume, /status returned to on-failure.
What steps can reproduce the bug?
Repro (high level)
-
Install/run Codex CLI v0.80.0 on native Windows (no WSL).
-
Ensure agent mode is enabled and sandbox is
workspace-write. -
Run any prompt that needs to read files and apply a patch.
-
Observe repeated approval prompts for in-workspace commands and/or failures:
windows sandbox: CreateProcessWithLogonW failed: 5
Notes
- Even after downgrading to v0.79.0 the failure persisted, until the sandbox was re-onboarded via the UI prompt.
Workaround that recovers the sandbox
-
Set
experimental_windows_sandbox = falsein~\.codex\config.tomland restart Codex. -
Accept the “Enable experimental sandbox” onboarding prompt.
-
After this re-onboarding, sandbox process creation works again and
apply_patchsucceeds.
Uploaded thread: 019baafa-08a3-72b0-8595-7588471ad5d1
What is the expected behavior?
Expected behavior
-
On native Windows, with sandbox
workspace-write, Codex should be able to run read-only commands inside the workspace without per-command approvals (unless accessing outside workspace or network). -
approval_policyshould be consistently reflected by/status, and should followconfig.tomlunless explicitly overridden. -
Windows sandbox should be able to create processes reliably, so
apply_patchand basic commands do not fail withCreateProcessWithLogonW failed: 5.
Additional information
Environment
-
OS: Windows 10 Enterprise LTSC 2019 (1809), build 17763.7792 (native, no WSL)
-
Codex CLI: v0.80.0 (problem), v0.79.0 (problem persisted after downgrade)
-
Install: npm global (@openai/codex)
-
Shell: Windows PowerShell 5.1 and cmd.exe
-
Workspace: D:\Downloads\LTSC clean\win10-ltsc-2021-clean-quiet-baseline
-
Config (
~\.codex\config.toml):-
sandbox_mode = "workspace-write" -
approval_policy = "on-failure" -
[features] experimental_windows_sandbox = true -
[features] elevated_windows_sandbox = false(also tested true/false)
-
I got it working by forcing a sandbox re-onboarding/reset: in ~\.codex\config.toml I temporarily set experimental_windows_sandbox = false, restarted Codex, then accepted the “Enable experimental sandbox” onboarding prompt. After that, the sandbox started creating processes normally again, and the agent stopped spamming approvals (especially with approval_policy = "on-failure").
But the bug still exists, this looks like a workaround that reinitializes the sandbox state. Old threads can still get stuck in CreateProcessWithLogonW failed: 5 and go back to asking for approvals on trivial in-workspace commands.
@tagor-sian sorry to hear that - we're investigating this issue. Could you check your ~/.codex/.sandbox/sandbox.log and share any notable failure logs?
Thanks a lot! I attached the requested file (~/.codex/sandbox/sandbox.log) to the issue (“sandbox.log”). If it's not readable for any reason I'll upload it again gladly.
Important nuance: the sandbox.log does NOT contain the CreateProcessWithLogonW failed: 5 error. In my case that error only shows up in the Codex TUI/terminal output (and should be present in the uploaded /feedback thread artifacts for this session).
What sandbox.log contains is a single repeating pattern (hundreds/thousands of repeats with different timestamps), e.g.:
[2026-01-11 20:46:55.225 codex.exe] AUDIT: world-writable scan FAILED; cwd="D:\Downloads\LTSC clean\win10-ltsc-2021-clean-quiet-baseline"; checked=289; duration_ms=12; flagged:
- \?\C:\Users\Public
- \?\C:\Users\Public\AccountPictures
- \?\C:\Users\Public\Documents
- \?\C:\Users\Public\Downloads
- \?\C:\Users\Public\Libraries
- \?\C:\Users\Public\Music
- \?\C:\Users\Public\Pictures
- \?\C:\Users\Public\Thunder Network
- \?\C:\Users\Public\Videos
If you want, tell me which additional log/source is best for capturing the CreateProcessWithLogonW failed: 5 error (Codex CLI main log, a specific diagnostics command output, or an excerpt from the uploaded thread), and I’ll provide it.
Uploaded /feedback thread id: 019baafa-08a3-72b0-8595-7588471ad5d1
FYI the failure persisted even after downgrading v0.80 → v0.79 until I forced a sandbox re-onboarding (set experimental_windows_sandbox=false, restart, then accept “Enable experimental sandbox” prompt). After that, process creation worked again and apply_patch succeeded.
Reopening this issue until we're confident the issue has been fixed
All of my codex sessions start with "CreateProcessWithLogonW failed: 5" error, which results in the agent modifying files using powershell scripts, instead of the apply_patch functionality. It makes the edits impossible to view, and requires approval for each file modification.
I've checked the user/.codex/.sandbox/sandbox.log file, and I can see 2 errors there:
[2026-01-20T11:46:56.604656500+00:00] ensuring sandbox users offline=CodexSandboxOffline online=CodexSandboxOnline [2026-01-20T11:46:57.063973600+00:00] firewall rule configured name=codex_sandbox_offline_block_outbound protocol=256 LocalUserAuthorizedList=O:LSD:(A;;CC;;;S-1-5-21-1222248931-2282269676-1019675704-1004) [2026-01-20T11:46:57.076897400+00:00] granting write ACE to D:\Work\Code\Invarion.Services for sandbox group and capability SID [2026-01-20T11:46:57.077205900+00:00] granting write ACE to C:\Users\cooad\AppData\Local\Temp for sandbox group and capability SID [2026-01-20T11:46:57.108130900+00:00] read-acl-only mode: applying read ACLs [2026-01-20T11:46:57.109707500+00:00] setup error: LookupAccountNameW failed for Users: 1332 [2026-01-20 12:46:57.110 codex-windows-sandbox-setup.exe] setup error: LookupAccountNameW failed for Users: 1332 [2026-01-20T11:47:09.029709400+00:00] setup error: LookupAccountNameW failed for Administrators: 1332 [2026-01-20 12:47:09.029 codex-windows-sandbox-setup.exe] setup error: LookupAccountNameW failed for Administrators: 1332
This failes because I have a polish version of Windows, and group names are localized. So for polish version of windows it's "Użytkownicy" instead of "Users", and "Administratorzy" instead of "Administrators".
I tried running
codex-windows-sandbox-setup.exe --help
to see it there are any flags I can pass in order to provide polish names to these groups, but it looks like there's no human-friendly interface there
This looks like another manifestation of the same underlying issue.
The sandbox setup is resolving Users and Administrators by localized group names instead of using well-known SIDs.
This should be fixable with a very small patch: resolve these groups by well-known SIDs, not by localized names.
For reference, the relevant well-known SIDs are:
Administrators group: S-1-5-32-544
Users group: S-1-5-32-545
These SIDs are locale-independent and work consistently across all Windows language versions.
Switching the sandbox setup to use SID-based resolution instead of hardcoded group names (Users, Administrators) should eliminate this entire class of failures on localized Windows installs and restore proper sandbox + apply_patch behavior.
@tagor-sian, thanks for the analysis. This PR applies your suggested fix.
Still reproducible on codex-cli v0.89 (native Windows). I had to roll back to v0.87 to keep working.
OS: Windows 10 Pro (10.0.19045, build 19045, x64)
This happens even for read-only commands inside the workspace. Log snippet:
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -Command 'Get-Content -Path "C:/Users/Administrator/.codex/skills/question-relevant-file-paths/SKILL.md"' in E:\\vscodeProject\\AI_Helper_Suite
2026-01-24T01:34:36.251843Z ERROR codex_core::exec: exec error: windows sandbox: CreateProcessWithLogonW failed: 5
exited -1 in 0ms:
execution error: Io(Custom { kind: Other, error: "windows sandbox: CreateProcessWithLogonW failed: 5" })
using codexexec
0.88 fixed the issues on the 2 machines that I work on. One is running Windows 11 Home, the other one Windows 11 Pro
I'm not sure if my error goes to same direction, maybe in my case it's the working directorie? Codex 0.97.0
Get-ChildItem -Force
[2026-02-06 13:09:20.728 codex.exe] setup refresh: spawning C:\Users\Rene\AppData\Roaming\npm\node_modules\@openai\codex\vendor\x86_64-pc-windows-msvc\codex\codex-windows-sandbox-setup.exe (cwd=Z:\Software\_CODEX\_temp_task, payload_len=756)
[2026-02-06T12:09:20.770548200+00:00] granting write ACE to \\?\UNC\192.168.178.58\Freigabe\Software\_CODEX\_temp_task for sandbox group and capability SID
[2026-02-06T12:09:20.772599200+00:00] read-acl-only mode: applying read ACLs
[2026-02-06T12:09:20.774486600+00:00] read ACL run completed
[2026-02-06T12:09:20.802499700+00:00] setup refresh: processed 2 write roots (read roots delegated); errors=[]
[2026-02-06 13:09:20.803 codex-windows-sandbox-setup.exe] setup binary completed
This is still happening for me with a fresh install of codex-cli 0.101.0.
The error I get is: windows sandbox: CreateProcessWithLogonW failed: 2
The error I get is: windows sandbox: CreateProcessWithLogonW failed: 2
I see this in v0.114.0
Still having a similar issue on Codex App 0.115.0-alpha.4.
I have an automation running that triggers a skill. The app is set to having 'Full Access'.
Every time the automation runs I get windows sandbox: CreateProcessWithLogonW failed: 1326
Love the idea of automations. but this error kinda kills the purpouse of them.
I just had an exactly same issue in the latest version of codex.
Quick fix : Reinstall Codex App
@nicolasdemol Didn't work for me. I had to remove my .codex directory and re-initiate the app.
I had the exact issue in the laest version of codex at that time (0.123). But codex cli fixed itself for me. Here is the report:
Here is the concise report for OpenAI:
Codex native Windows sandbox failed with:
windows sandbox: runner error: CreateProcessAsUserW failed: 5
The failure was reproducible when windows.sandbox = "elevated" and the active shell resolved to the Microsoft Store / WindowsApps version of PowerShell:
C:\Program Files\WindowsApps\Microsoft.PowerShell_7.6.1.0_x64__8wekyb3d8bbwe\pwsh.exe
C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\pwsh.exe
Sandbox setup itself was not always the failing step. In the later reproduction, logs showed:
setup refresh: spawning ...\@openai\codex-win32-x64\...\codex-windows-sandbox-setup.exe
read ACL run completed
runner launch: exe=...\codex-command-runner.exe ...
But the command still failed before codex-command-runner.exe logged runner start, with:
CreateProcessAsUserW failed: 5
This suggests the elevated sandbox runner could start, but failed when trying to launch the Store/WindowsApps pwsh.exe inside the sandboxed user context.
Installing the MSI version of PowerShell fixed the issue. After installing MSI PowerShell, pwsh resolved to the normal install path instead of WindowsApps:
C:\Program Files\PowerShell\7\pwsh.exe
After that, Codex elevated Windows sandbox commands worked.
Likely root cause: Codex elevated sandbox has a compatibility issue when the configured shell is the WindowsApps / Store packaged pwsh.exe. The packaged PowerShell has AppX/WindowsApps ACL and package identity constraints that do not work correctly with Codex’s elevated sandbox user / CreateProcessAsUserW launch path.
Recommended improvement: detect when pwsh resolves to WindowsApps and either warn clearly, automatically prefer a non-Store PowerShell installation if available, or fall back to powershell.exe with an actionable diagnostic.
I just changed the sandbox = "elevated" to sandbox = "unelevated" then fixed. what's the different?
@ruiheng I can confirm that this workaround fixed the issue in my environment.
My setup was using the Microsoft Store / MSIX version of PowerShell, and sandboxed commands were failing with:
windows sandbox: runner error: CreateProcessAsUserW failed: 1920
After uninstalling the Microsoft Store / MSIX version, I installed the MSI/WiX version of PowerShell with:
winget install --id Microsoft.PowerShell --source winget --installer-type wix
After that, Codex was able to run the same sandboxed commands successfully without requiring escalation.
Verified commands included simple Get-Content, Get-ChildItem, git status --short, and a Node-based validation command. All worked normally after switching to the MSI-installed PowerShell.
Thanks for the pointer!
@YdayangY either. Based the official website. Elevated is been suggested. But i cannot get what the different between them based on the https://developers.openai.com/codex/config-basic Have you got any idaes?