Windows Desktop sandbox fails with setup refresh failed / CreateProcessAsUserW failed
What version of the Codex App are you using (From “About Codex” dialog)?
26.506.3741.0
What subscription do you have?
ChatGPT Plus
What platform is your computer?
Windows 11, x64
What issue are you seeing?
I am using Codex Desktop on Windows.
Normal sandbox command execution fails even for simple read-only PowerShell commands.
Codex App version:
26.506.3741.0
Subscription:
ChatGPT Plus
Platform:
Windows 11, x64
What happens:
When I run simple commands in the normal sandbox, they fail before executing.
Commands tested:
Get-Location
Get-Content -Tail 20 "H:\MyDrive\<PROJECT_FOLDER>\<MARKDOWN_FILE>.md"
For the project on H:\MyDrive\<PROJECT_FOLDER>, the error is:
windows sandbox: setup refresh failed with status exit code: 1
I also tested a copied local project folder under Documents.
In that local Documents project, normal sandbox execution failed with:
windows sandbox: runner error: CreateProcessAsUserW failed: 1312
I did not use external execution during these tests.
What works:
The same PowerShell commands work when run with external execution.
So the file path and the PowerShell commands themselves seem to be valid.
What I already tried:
- Restarted the Codex app
- Restarted the PC
- Tested the original project folder on Google Drive / H: drive
- Tested a copied local project folder under Documents
- Tested minimal commands such as Get-Location
The issue still happens after restarting the app and the PC.
Sandbox log:
The sandbox log exists at:
C:\Users\<USER>\.codex\.sandbox\sandbox.log
The relevant log lines for the H: drive project include:
write ACE grant failed on H:\MyDrive\<PROJECT_FOLDER>:
SetNamedSecurityInfoW failed: 87
setup refresh completed with errors
setup error: setup refresh had errors
setup refresh: exited with status ExitStatus(1)
This looks like the sandbox setup/ACL grant step is failing before the command is executed.
Expected behavior:
Read-only commands such as Get-Location and Get-Content -Tail 20 should run successfully in the normal sandbox.
Actual behavior:
Normal sandbox execution fails with either:
windows sandbox: setup refresh failed with status exit code: 1
or:
windows sandbox: runner error: CreateProcessAsUserW failed: 1312
External execution works, but I would prefer to use the normal sandbox for safer verification.
What steps can reproduce the bug?
- Open Codex Desktop on Windows.
- Open a project folder.
- Use the normal sandbox, not external execution.
- Ask Codex to run a simple read-only PowerShell command:
Get-Location
- Ask Codex to run another read-only command:
Get-Content -Tail 20 "H:\MyDrive\<PROJECT_FOLDER>\<MARKDOWN_FILE>.md"
- The normal sandbox fails before the commands run.
- Restart the Codex app and try again.
- Restart the PC and try again.
- The same sandbox error still happens.
What is the expected behavior?
Read-only PowerShell commands such as Get-Location and Get-Content -Tail 20 should run successfully in the normal sandbox.
The normal sandbox should initialize correctly and execute the command without requiring external execution.
Additional information
Codex App version:
26.506.3741.0
Subscription:
ChatGPT Plus
Platform:
Windows 11, x64
The issue happens in both:
- A project folder on Google Drive / H: drive
- A copied local project folder under Documents
Errors observed:
- On the H: drive project:
windows sandbox: setup refresh failed with status exit code: 1
- On the local Documents project:
windows sandbox: runner error: CreateProcessAsUserW failed: 1312
The same PowerShell commands work with external execution.
I already tried:
- Restarting the Codex app
- Restarting the PC
- Testing a Google Drive / H: drive project folder
- Testing a copied local Documents project folder
- Testing minimal commands such as Get-Location
Relevant sandbox log path:
C:\Users\<USER>\.codex\.sandbox\sandbox.log
Relevant sandbox log lines:
write ACE grant failed on H:\MyDrive\<PROJECT_FOLDER>:
SetNamedSecurityInfoW failed: 87
setup refresh completed with errors
setup error: setup refresh had errors
setup refresh: exited with status ExitStatus(1)
This looks like the sandbox setup / ACL grant step is failing before the command is executed.
14 Comments
i meet the same error.
Same Here
Same here, it makes codex basically unusable. This should have high priority!
UPDATE:
I was able to get the Windows sandbox working again, but I changed a few things at once, so I cannot say which part was the actual fix.
Before it started working again, I noticed that quitting Codex Desktop completely still left a
codex-windows-sandboxprocess running in Task Manager. I manually killed that leftover process, then started Codex again.At the same time, my relevant config now has:
UPDATE 2:
After more testing, this is only partially fixed for me.
Normal Windows-native sandbox command execution now works again for simple/direct commands, e.g.
git status,Get-Content, and direct Python commands like:However, I still see sandbox-related permission/process issues in some cases:
bun run fmtstill fails inside Codex with:The same command works in my normal PowerShell terminal. So direct process execution seems fixed, but nested process spawning (
bun -> oxfmt) still appears blocked or mishandled.uv run pytest/uv run mypy srcfailed inside Codex becauseuvcould not access or create cache files:.git/refs/heads/...:Inspecting ACLs showed explicit
Deny Write/Deleterules on parts of.git, so the sandbox can read the repo and edit workspace files, but some Git metadata writes are blocked.So the original
CreateProcessAsUserW failed: 1312problem seems improved after killing the leftovercodex-windows-sandboxprocess / changing config / restarting, but the Windows sandbox still has narrower permission issues around child process spawning, tool caches, and.gitref writes.The relevant config I’m currently using is still as above.
Normal PowerShell outside Codex can run all of the failing commands successfully.
Same Here
UPDATE 1
switch to unelevated sandbox can solve this problem but codex probably can read all the document in your computer.So it's better to edit the Personalization to limit the model.
Adding another reproduction report for the native Windows sandbox process launch failure.
Environment
codex-cli 0.134.0%APPDATA%\npmOriginal install issue
The Microsoft Store / app install resolved first in PATH:
codex --versionreturned:but the sandbox setup helper was missing:
Installing
@openai/codex@latestthrough npm provided both helpers:After uninstalling the Store app and removing the stale PATH entry,
codexresolves only to npm:Current sandbox failure
From an elevated PowerShell prompt:
Result:
Then from a root-level test folder:
Result:
Using a full path to
cmd.exegives the same error:Result:
Notes
danger-full-access/ YOLO mode was used.Uninstalling the WindowsApps/MSIX version of PowerShell and reinstalling the MSI version fixed the 'CreateProcessAsUserW failed: 1312' issue for me.
switch to unelevated sandbox can solve this problem but codex probably can read all the document in your computer.So it's better to edit the Personalization to limit the model.
+1
Tool use is broken on Windows with this setup, codex can not do practically anything without approval.
It worked for me. I used following command to install it:
Adding a more detailed reproduction for the
CreateProcessAsUserW failed: 1312case where the default shell resolves to PowerShell installed as MSIX/AppX.Environment
OpenAI.Codex_26.611.8273.0_x64__2p2nqsd0c76g0codex-command-runner-0.140.0-alpha.19.exeMicrosoft.PowerShell_7.6.3.0_x64__8wekyb3d8bbweSymptom
Ordinary Codex tool calls failed before the requested command started:
The Codex sandbox log showed the default shell being launched through the App Execution Alias:
Windows Event Log corroborated it as an AppModel/AppX activation failure:
0x80070520maps to Win32 error 1312 /ERROR_NO_SUCH_LOGON_SESSION.A/B test in the same Codex sandbox
These worked:
These failed with
CreateProcessAsUserW failed: 1312:That suggests the sandbox user/token was not globally broken: WinPS 5.1 and
cmd.exelaunched successfully, but the MSIX/AppX PowerShell activation path failed under the sandbox user.Additional checks
cmd.exe.Workaround that fixed it
Uninstalling the MSIX/AppX PowerShell package and installing the MSI/Win32 PowerShell 7 package fixed ordinary Codex tool calls. After the fix:
A normal Codex tool shell test succeeded with:
Request
It may be useful for Codex on Windows to detect when the default shell resolves to an MSIX/AppX App Execution Alias (
%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe) and either prefer a regular Win32 shell executable, emit a clearer diagnostic, or document MSI/Win32 PowerShell 7 as the safer option for native Windows sandbox shell execution.This issue exists on v26.5616.41845 (Released on 3/6/2025)
Terrible Strange thing!!!
Created a new chat, and everything working again.
Workaround / Root-cause analysis
I hit a similar setup refresh failed error, but with a slightly different root cause than the H: drive SetNamedSecurityInfoW error reported above. Sharing in case it helps narrow the issue.
My scenario
Every time apply_patch starts, Codex refreshes the ACLs on its three writable roots. On my machine, the refresh fails because C:\tmp returns Windows error 5 (ERROR_ACCESS_DENIED) during the write-ACE update, causing the entire refresh to abort. The project directory itself is fine.
Root cause
C:\tmp is owned by BUILTIN\Administrators. Codex (running as my standard user) cannot update the ACL on that directory, so the sandbox setup bails out.
Minimal fix
No file content needs to change. I only had to change the owner of C:\tmp to my current user or make current user has inheritable _FullControl_ permission on C:\tmp.
After that, Codex was able to add the required ACEs on its own and the sandbox initialized successfully.
Suggestion for the Codex team
It might be worth handling ownership-related ERROR_ACCESS_DENIED more gracefully—either by skipping non-project roots that can't be modified, or by surfacing a clearer error message so users don't have to dig through sandbox.log to find which directory is blocking setup.
Hope this helps anyone else stuck on the same setup refresh failed loop.
Adding another confirmed reproduction and successful workaround, this time on a current Windows 11 Insider Beta system and current Codex versions.
Environment
26.707.3748.00.144.1elevated7.6.3Microsoft.PowerShell_7.6.3.0_x64__8wekyb3d8bbweThe failure persisted after fully rebooting Windows. Ordinary sandbox shell calls failed before the command started:
The selected shell was the App Execution Alias / WindowsApps package:
At the matching timestamps,
Microsoft-Windows-AppModel-Runtime/Admincontained Event ID 202:This maps to Win32 error 1312 /
ERROR_NO_SUCH_LOGON_SESSION. The sandbox accounts existed and were enabled, so this was not fixed by refreshing credentials or rebooting.Workaround used
We kept the elevated native Windows sandbox configuration unchanged. We did not switch to
unelevated,danger-full-access, or WSL.We replaced PowerShell 7 MSIX with the official MSI/WiX package:
Important practical note: do not let the MSIX
pwsh.exebeing removed host both commands. In our first attempt, uninstalling MSIX terminated the current shell/stdout before the install command ran. We recovered by launching the install from the built-in Windows PowerShell 5.1 executable:Running the uninstall and install as separate steps from Windows PowerShell 5.1 (or another unaffected host) avoids that self-uninstall problem.
Result after fully restarting Codex Desktop
Post-fix validation succeeded:
apply_patchcreate/delete probeSo on this machine the sandbox token itself was healthy; the failure was specifically the MSIX/AppX PowerShell activation path. Replacing it with the MSI/Win32 build resolved error 1312 without weakening the sandbox policy.