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

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

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.

View original on GitHub ↗

2 Comments

github-actions[bot] contributor · 3 months ago

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

  • #18984

Powered by Codex Action

kivikdigitalgroup · 21 days ago

Confirmation / forensic update (2026-08-06)

Still reproducing on current Windows ChatGPT/Codex desktop app-server.

Environment

  • Package: OpenAI.Codex Microsoft Store / WindowsApps
  • Identity version: 26.730.7989.0
  • Binary: C:\Program Files\WindowsApps\OpenAI.Codex_...\app\resources\codex.exe
  • Host: Windows 10 (build 19045-class), x64
  • Also present: npm @openai/codex 0.146.0 vendor codex.exe (same AST payload string; also lacks CREATE_NO_WINDOW string)

Process tree (live)

codex.exe  -c features.code_mode_host=true app-server --analytics-default-enabled
  └── powershell.exe -NoLogo -NoProfile -NonInteractive -EncodedCommand <...>

Decoded payload header (exact):

# Long-lived PowerShell AST parser used by the Rust command-safety layer on Windows.
# The caller starts one child process per PowerShell executable variant and then sends
# newline-delimited JSON requests over stdin:

Binary inspection

Scanned installed codex.exe (Store 26.730.7989.0, ~347 MB):

  • Contains: Long-lived PowerShell AST parser..., command-safety, powershell.exe, -WindowStyle / Hidden (appears only in agent guidance text, not as process spawn flags)
  • Does NOT contain: CREATE_NO_WINDOW, SW_HIDE, STARTF_USESHOWWINDOW, CREATE_NEW_CONSOLE string markers

So the child is still being spawned without Win32 no-window creation flags. -WindowStyle Hidden is not applied to this long-lived AST helper (or is insufficient alone when the parent is a console-capable process).

Symptom for users

Visible PowerShell console open/close flashes while Codex app-server is running in the background — even when the user is typing in a different app (e.g. Hermes CLI). It is easy to mis-attribute to keystrokes; the correlation is Codex tool/command-safety activity / helper lifetime, not the other app's input.

Requested fix

Spawn the AST helper with:

  • CREATE_NO_WINDOW (0x08000000), and/or
  • STARTF_USESHOWWINDOW + SW_HIDE, and/or
  • powershell.exe -WindowStyle Hidden on the argv

plus keep stdin/stdout redirected as today. Do not disable command-safety — only hide the console host.

Happy to retest a preview build against 26.730.7989.0.