Windows sandbox runner fails with CreateProcessAsUserW 1312 after successful setup refresh
Environment
- Codex Desktop for Windows: 26.707.3748.0
- Windows: Windows 11 x64
- Shell: PowerShell 7 via pwsh.exe
- Command runner: codex-command-runner-0.144.0-alpha.4.exe
Problem
Every normal sandbox shell command fails before PowerShell executes, including a minimal command such as:
Write-Output 'POWERSHELL_OK'
The reported error is:
windows sandbox: runner failed: CreateProcessAsUserW failed: 1312
A specified logon session does not exist
The same PowerShell works normally when run directly in an interactive Windows PowerShell window.
The issue persists after restarting both Codex and Windows.
Relevant sandbox log
The recent log shows setup and ACL preparation succeeding:
setup refresh: processed 3 write roots (read roots delegated); errors=[]
setup binary completed
read ACL run completed
helper copy: reused command-runner
helper launch resolution: using copied command-runner path ...\\.codex\\.sandbox-bin\\codex-command-runner-0.144.0-alpha.4.exe
For the failing command, the log then contains:
START: ...\\pwsh.exe -NoProfile -Command ...
setup refresh: processed 3 write roots (read roots delegated); errors=[]
setup binary completed
read ACL run completed
helper launch resolution: using copied command-runner path ...\\.codex\\.sandbox-bin\\codex-command-runner-0.144.0-alpha.4.exe
There is no subsequent runner launch, runner launch failed, child process exit, stdout, or stderr entry.
What has been ruled out
- The interactive Windows user is active in session 1.
- Codex and the interactive shell use the same Windows user.
- Direct PowerShell execution works.
- The sandbox setup binary reports no ACL errors.
- The issue remains after a full Windows reboot.
- The failure occurs for read-only and minimal commands, not just Git or project-specific commands.
Expected behavior
A minimal read-only PowerShell command should run in the normal Codex sandbox after successful setup refresh.
Request
Please investigate the command-runner launch/token path on Windows and improve the logging around the boundary after helper launch resolution, especially failures between launching codex-command-runner.exe and its internal CreateProcessAsUserW call.
4 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I have been having this same issue for over a month with my elevated sandbox
I was able to isolate this failure to the Microsoft Store/MSIX build of PowerShell 7 rather than the elevated Windows sandbox in general.
Environment:
26.707.3748.00.144.126200.8655elevated7.6.3The failing Codex shell resolved
pwsh.exethrough the per-user App Execution Alias / Store package:Normal Codex shell execution failed before PowerShell started:
The sandbox setup itself appeared healthy:
CodexSandboxOfflineandCodexSandboxOnlinewere enabled.CodexSandboxUsers.LastLogonupdated during the failing test.I then ran controlled A/B tests by passing executables directly to the elevated Codex sandbox:
C:\Windows\System32\cmd.exe-> succeeded.C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe) -> succeeded.Program Files\WindowsApps-> failed with the sameCreateProcessAsUserW 1312.C:\Program Files\PowerShell\7\pwsh.exe-> succeeded.After installing the MSI/WiX package and allowing Codex to resolve:
both ordinary Codex shell commands and
apply_patchupdates worked successfully with the elevated sandbox.The working installation command was:
The
--installer-type wixpart matters because WinGet installs the MSIX package by default beginning with PowerShell 7.6.This suggests the 1312 failure can be caused by trying to launch the per-user Store/MSIX PowerShell package under the dedicated Codex sandbox user. The MSI build provides a system-wide ordinary executable and avoids that package/logon-session boundary.
I can independently reproduce this and confirm the Microsoft Store/MSIX PowerShell 7 boundary described above.
Environment
openai.chatgpt-26.707.41301-win32-x640.144.0-alpha.426100elevated7.6.3, installed as the Microsoft Store/MSIX packagepwsh.exe:C:\Program Files\WindowsApps\Microsoft.PowerShell_7.6.3.0_x64__8wekyb3d8bbwe\pwsh.exeThe normal Codex shell wrapper uses the App Execution Alias under
%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exeand fails before PowerShell executes:Controlled A/B test
From a fresh Codex CLI process, using the same elevated sandbox:
The system-wide MSI/WiX path
C:\Program Files\PowerShell\7\pwsh.exeis not installed on this machine.Other observations:
codex doctor --jsonreports overall statusok, including readable sandbox configuration.Get-Content) because Codex fails while launching the PowerShell wrapper, before the requested command starts.pwsh.exe, which rules out the failure being limited to a stale long-lived extension process.Suggested product-side fixes:
codex doctorperform a minimal launch probe using the shell Codex will actually select inside the configured sandbox.