Windows: local runner cannot start, CreateProcessAsUserW failed: 5

Open 💬 8 comments Opened May 31, 2026 by ulvihy
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

26.527.31326

What subscription do you have?

pro

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x6

What issue are you seeing?

Bug: Codex Desktop on Windows cannot launch local runner: CreateProcessAsUserW failed: 5

Summary

Codex Desktop cannot execute any local workspace command on Windows. The workspace folder is readable from PowerShell outside Codex, but Codex tool execution fails before the command starts with:

windows sandbox: runner error: CreateProcessAsUserW failed: 5

Environment

  • OS: Windows
  • App: Codex Desktop
  • Workspace path: D:\temp\temp\Codex
  • Shell: PowerShell 7.6.2 installed via MSI
  • Controlled Folder Access: Off
  • Workspace sandbox mode shown in thread: workspace-write
  • Writable root shown in thread: D:\temp\temp\Codex

Reproduction

  1. Open Codex Desktop on Windows.
  2. Open workspace: D:\temp\temp\Codex
  3. Ask Codex to read/list the folder.
  4. Codex attempts to run:

```powershell
Get-ChildItem -Force -LiteralPath 'D:\temp\temp\Codex'

What steps can reproduce the bug?

Environment

  • OS: Windows
  • App: Codex Desktop
  • Workspace path: D:\temp\temp\Codex
  • Shell: PowerShell 7.6.2 installed via MSI
  • Controlled Folder Access: Off
  • Workspace sandbox mode shown in thread: workspace-write
  • Writable root shown in thread: D:\temp\temp\Codex

Reproduction

  1. Open Codex Desktop on Windows.
  2. Open workspace: D:\temp\temp\Codex
  3. Ask Codex to read/list the folder.
  4. Codex attempts to run:

```powershell
Get-ChildItem -Force -LiteralPath 'D:\temp\temp\Codex'

What is the expected behavior?

Codex should be able to launch its local helper/runner and read files inside the configured workspace.
Actual BehaviorCodex fails to spawn the local runner:
Add to chat
execution error: Io(Custom { kind: Other, error: "windows sandbox: runner error: CreateProcessAsUserW failed: 5" })

The Node REPL helper also failed with a sandbox/process launch error:
Add to chat
node_repl kernel exited unexpectedly
windows sandbox failed: spawn setup refresh

Additional information

Verification Outside CodexThe same folder is readable from an external PowerShell session:
powershell

Get-ChildItem -Force 'D:\temp\temp\Codex'

Output shows files successfully, including:
Add to chat
PIMCO_PIMS_Income_Fund_A_TSR_AR.pdf
PIMCO_PIMS_Income_Fund_A_TSR_SAR.pdf
PIMCO_PIMS_Income_Fund_FSTM_AR.pdf
PIMCO_PIMS_Income_Fund_FSTM_SAR.pdf

Troubleshooting Already TriedConfirmed Controlled Folder Access is off.
Confirmed folder is readable outside Codex.
Tried explicit Codex file permission grant for D:\temp\temp\Codex.
Retried command after permission grant; same error.
PowerShell is MSI-installed, not Store-installed.
NotesThis appears to be a Codex Desktop Windows runner/session-token issue rather than a workspace ACL or shell issue, because both PowerShell command execution and Node helper startup fail before accessing files.

View original on GitHub ↗

8 Comments

github-actions[bot] contributor · 1 month ago

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

  • #24416
  • #25162
  • #24259

Powered by Codex Action

DiMY-CN · 1 month ago

I ran into a similar CreateProcessAsUserW failed: 5 issue. In my case, the problem was not the target file permission or the command itself. The failure happened earlier: the Codex/Windows sandbox failed to create the PowerShell child process.

This started after I changed the default shell from Windows PowerShell 5 to PowerShell 7. The issue disappeared after I switched PowerShell 7 to the standard MSI installation and made sure Codex was using the real pwsh.exe path, not a WindowsApps alias or MSIX path.

Useful check:

Get-Command pwsh -All

One important detail: avoid the Microsoft Store version of PowerShell 7, and avoid installing the MSIX package via winget. Those installations usually resolve to WindowsApps-related paths, for example:

C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\pwsh.exe

or the corresponding WindowsApps package path. Such paths may not be launchable by CreateProcessAsUserW under a restricted sandbox token.

A simple workaround is to download the .msi installer from the PowerShell GitHub Releases page. The MSI installer lets you choose the installation directory, and its default path is usually:

C:\Program Files\PowerShell\7\pwsh.exe

My understanding is that the sandbox uses CreateProcessAsUserW to spawn the shell process. Some PowerShell 7 MSIX / Store / WindowsApps installations may be rejected by Windows under the restricted token, which results in:

windows sandbox: runner error: CreateProcessAsUserW failed: 5

Additional note: after running conda init in PowerShell 7, I also hit a separate issue:

Invoke-Expression: Missing '{' in configuration statement.

This is not the same root cause as CreateProcessAsUserW failed: 5. It is caused by a compatibility issue between PowerShell 7 native command argument passing and the older conda PowerShell initialization script. A workaround is to add this before the conda initialization block in the PowerShell profile:

if ($PSVersionTable.PSVersion.Major -ge 7) {
    $PSNativeCommandArgumentPassing = 'Legacy'
}

The longer-term fix is to update conda and regenerate the PowerShell initialization:

conda init --reverse powershell
conda init powershell
ulvihy · 1 month ago

yes the issue resolved after I uninstalled PowerShell and reinstalled from the .msi . The prior install was in a nonstandard location.

Keesan12 · 1 month ago

One thing that would make this much easier to diagnose is separating "command failed" from "runner never started."

In threads like this, people naturally go chase file ACLs, workspace permissions, or the exact shell command, but CreateProcessAsUserW failed: 5 means the failure happened before any of that mattered.

A better product response would be something like:

  • runner launch failed under the current Windows token
  • workspace access was never attempted
  • shell path detected: X
  • launch mode detected: Y
  • next checks: shell install path, token/sandbox mode, known WindowsApps/MSIX pitfalls

That would stop a lot of false debugging.

Also feels worth logging a structured fingerprint for this error family so Codex can stop retrying the same launch path over and over once it knows the runner is dead. When local execution is unavailable, the fastest path is usually a crisp fail, not another hopeful spawn attempt.

etraut-openai contributor · 1 month ago

@Keesan12, please stop posting bot-generated slop to our issue tracker. It's not useful, and it's creating noise for maintainers and users. If you do not stop, I'll ask GitHub to block your account.

TheBeems · 1 month ago
A simple workaround is to download the .msi installer from the PowerShell GitHub Releases page. The MSI installer lets you choose the installation directory, and its default path is usually: `` C:\Program Files\PowerShell\7\pwsh.exe ``

This resolved the issue ``windows sandbox: runner error: CreateProcessAsUserW failed: 5`` for me. Thanks!

ShuailingYang · 1 month ago
我也遇到过类似的CreateProcessAsUserW failed: 5问题。我的情况并非出在目标文件权限或命令本身,而是更早之前:Codex/Windows 沙箱未能创建 PowerShell 子进程。 这个问题是在我将默认 shell 从 Windows PowerShell 5 更改为 PowerShell 7 之后出现的。当我将 PowerShell 7 切换到标准 MSI 安装并确保 Codex 使用的是真实pwsh.exe路径而不是 WindowsApps 别名或 MSIX 路径后,问题就消失了。 有用的检查: Get-Command pwsh -All 一个重要的细节:避免使用 Microsoft Store 版本的 PowerShell 7,也避免通过 winget 安装 MSIX 包。这些安装通常会指向与 WindowsApps 相关的路径,例如: `` C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\pwsh.exe ` 或相应的 WindowsApps 包路径。此类路径可能无法通过CreateProcessAsUserW受限沙盒令牌启动。 一个简单的解决方法是从 PowerShell GitHub Releases 页面下载.msi安装程序。MSI 安装程序允许您选择安装目录,其默认路径通常为: ` C:\Program Files\PowerShell\7\pwsh.exe ` 我的理解是,沙箱用于CreateProcessAsUserW生成 shell 进程。某些 PowerShell 7 MSIX / Store / WindowsApps 安装可能会因受限令牌而被 Windows 拒绝,从而导致: ` windows sandbox: runner error: CreateProcessAsUserW failed: 5 ` 补充说明:conda init在 PowerShell 7 中运行后,我还遇到了另一个问题: ` Invoke-Expression: Missing '{' in configuration statement. ` 这并非与之前提到的根本原因相同CreateProcessAsUserW failed: 5`。这是由于 PowerShell 7 原生命令参数传递方式与旧版 conda PowerShell 初始化脚本之间的兼容性问题导致的。一种解决方法是在 PowerShell 配置文件中的 conda 初始化代码块之前添加以下代码: if ($PSVersionTable.PSVersion.Major -ge 7) { $PSNativeCommandArgumentPassing = 'Legacy' } 长远来看,解决办法是更新 conda 并重新生成 PowerShell 初始化程序: conda init --reverse powershell conda init powershell
ShuailingYang · 1 month ago

Love you babe. Problem perfectly solved.