codex - 💡(How to fix) Fix `codex exec` on Windows spawns a visible long-lived PowerShell helper window when launched headlessly [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#20510Fetched 2026-05-01 05:42:18
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×1unlabeled ×1

Root Cause

codex exec is documented and exposed as a non-interactive/headless mode. In background automation on Windows, it should not open visible terminal windows. This is especially disruptive for installed services, hooks, daemons, editors, or other tools that call Codex in the background.

Because this PowerShell process is a grandchild of the caller, the caller cannot reliably apply windowsHide to it. The process that spawns the helper needs to request hidden/no-window creation on Windows.

Code Example

powershell.exe
  CommandLine: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -EncodedCommand ...
  Parent: codex.exe

---

Long-lived PowerShell AST parser used by the Rust command-safety layer on Windows.
RAW_BUFFERClick to expand / collapse

Issue Draft: codex exec on Windows spawns visible PowerShell helper window

Title

codex exec on Windows spawns a visible long-lived PowerShell helper window when launched headlessly

Body

What is the problem?

We are running Codex from another tool in a headless/background mode using codex exec on Windows. The parent process launches Codex with windowsHide: true and avoids the npm .cmd shim by invoking the Codex JavaScript entrypoint through node.exe directly.

Despite that, a visible PowerShell window appears. One of these windows can remain open for the lifetime of the active Codex process.

The visible window appears to come from a PowerShell helper spawned by Codex itself, not from the parent application that launches Codex.

Why this matters

codex exec is documented and exposed as a non-interactive/headless mode. In background automation on Windows, it should not open visible terminal windows. This is especially disruptive for installed services, hooks, daemons, editors, or other tools that call Codex in the background.

Because this PowerShell process is a grandchild of the caller, the caller cannot reliably apply windowsHide to it. The process that spawns the helper needs to request hidden/no-window creation on Windows.

Environment

  • OS: Windows
  • Invocation mode: codex exec
  • Parent application launch behavior:
    • Uses Node spawn
    • Uses windowsHide: true
    • Uses stdio: [ignore, pipe, pipe]
    • Avoids npm .cmd shim by resolving to the Codex JS entrypoint and invoking it with node.exe

Observed process tree

The long-lived visible PowerShell process was parented by codex.exe, not by the parent application:

powershell.exe
  CommandLine: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -EncodedCommand ...
  Parent: codex.exe

The decoded command describes the process as:

Long-lived PowerShell AST parser used by the Rust command-safety layer on Windows.

Expected behavior

When codex exec is used non-interactively on Windows, Codex should not create visible console windows for internal helper processes.

Possible fixes:

  • Spawn the Windows PowerShell AST/helper process with hidden/no-window creation flags.
  • Provide a mode for codex exec that does not start shell/tool command-safety helper processes when the caller only needs prompt-only non-interactive behavior.

Actual behavior

codex exec can spawn a visible PowerShell helper window. When Codex is launched by a background enrichment process, this makes background work visible to the desktop user and can leave a PowerShell window open.

Reproduction shape

  1. On Windows, launch Codex from a Node process using spawn.
  2. Set windowsHide: true.
  3. Invoke codex exec non-interactively.
  4. Observe that Codex may spawn a visible powershell.exe child for its Windows command-safety layer.

The key point is that the visible window is spawned by Codex itself, so hiding the original codex exec process from the parent application is not enough.

extent analysis

TL;DR

The most likely fix is to modify the codex exec command to spawn the PowerShell helper process with hidden/no-window creation flags.

Guidance

  • Investigate the codex.exe spawn behavior to determine how it launches the PowerShell helper process and identify potential flags or options to hide the window.
  • Consider adding a new mode to codex exec that disables the command-safety helper processes when running non-interactively, as suggested in the issue.
  • Review the Node spawn documentation to ensure that the windowsHide: true option is being applied correctly and explore other options for hiding the window.
  • Test the reproduction steps to confirm that the issue is specific to the codex exec command and not a general issue with Node or PowerShell on Windows.

Example

No code snippet is provided as the issue does not include specific code examples, but the solution may involve modifying the codex.exe spawn behavior or adding a new flag to the codex exec command.

Notes

The solution may require modifications to the codex.exe code or the addition of new flags to the codex exec command, which could have unintended consequences or require additional testing.

Recommendation

Apply a workaround by modifying the codex exec command to spawn the PowerShell helper process with hidden/no-window creation flags, as this is the most direct solution to the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When codex exec is used non-interactively on Windows, Codex should not create visible console windows for internal helper processes.

Possible fixes:

  • Spawn the Windows PowerShell AST/helper process with hidden/no-window creation flags.
  • Provide a mode for codex exec that does not start shell/tool command-safety helper processes when the caller only needs prompt-only non-interactive behavior.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix `codex exec` on Windows spawns a visible long-lived PowerShell helper window when launched headlessly [1 comments, 2 participants]