openclaw - 💡(How to fix) Fix [Bug]: Windows: exec tool causes console window flash when spawning commands [1 comments, 1 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
openclaw/openclaw#59362Fetched 2026-04-08 02:25:29
View on GitHub
Comments
1
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2

On Windows, every exec tool call causes a brief black console window (cmd) to flash on screen. This happens because the exec tool wraps all commands through powershell.exe -NoProfile -NonInteractive -Command "...", and PowerShell as a console application creates a visible console window even when windowsHide: true is set on the spawn options.

Root Cause

In src/process/supervisor/adapters/child.ts, createChildAdapter correctly sets windowsHide: true on spawn options. However, the shell config (getShellConfig) wraps all commands through powershell.exe:

if (process.platform === "win32") return {
    shell: resolvePowerShellPath(),
    args: ["-NoProfile", "-NonInteractive", "-Command"]
};

So the actual spawn is: spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "<actual command>"], { windowsHide: true }).

windowsHide: true passes CREATE_NO_WINDOW to CreateProcess, but PowerShell is a console application (CUI subsystem), and Windows still briefly allocates and shows a console window before hiding it.

Code Example

if (process.platform === "win32") return {
    shell: resolvePowerShellPath(),
    args: ["-NoProfile", "-NonInteractive", "-Command"]
};

---

// This does NOT flash:
spawn('D:\\toolbox\\Toolbox.exe', ['cli', 'timestamp', '--datetime', '2026-04-02 10:37:00'], {
    windowsHide: true,
    stdio: ['pipe', 'pipe', 'pipe']
});

// This DOES flash:
spawn('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
    'D:\\toolbox\\Toolbox.exe cli timestamp --datetime "2026-04-02 10:37:00"'], {
    windowsHide: true,
    stdio: ['pipe', 'pipe', 'pipe']
});

---
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

On Windows, every exec tool call causes a brief black console window (cmd) to flash on screen. This happens because the exec tool wraps all commands through powershell.exe -NoProfile -NonInteractive -Command "...", and PowerShell as a console application creates a visible console window even when windowsHide: true is set on the spawn options.

Steps to reproduce

Steps to Reproduce

  1. Run OpenClaw on Windows (tested with both openclaw gateway start and Windows Service mode)
  2. Trigger any exec tool call from an agent (e.g., running an external CLI tool)
  3. Observe a black console window briefly flashing on screen

Expected Behavior

No visible window should appear when executing commands via the exec tool.

Actual Behavior

A black cmd/console window flashes briefly on screen for every exec tool invocation.

Root Cause Analysis

In src/process/supervisor/adapters/child.ts, createChildAdapter correctly sets windowsHide: true on spawn options. However, the shell config (getShellConfig) wraps all commands through powershell.exe:

if (process.platform === "win32") return {
    shell: resolvePowerShellPath(),
    args: ["-NoProfile", "-NonInteractive", "-Command"]
};

So the actual spawn is: spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "<actual command>"], { windowsHide: true }).

windowsHide: true passes CREATE_NO_WINDOW to CreateProcess, but PowerShell is a console application (CUI subsystem), and Windows still briefly allocates and shows a console window before hiding it.

Verification

Directly spawning the target executable without the PowerShell wrapper eliminates the flash completely:

// This does NOT flash:
spawn('D:\\toolbox\\Toolbox.exe', ['cli', 'timestamp', '--datetime', '2026-04-02 10:37:00'], {
    windowsHide: true,
    stdio: ['pipe', 'pipe', 'pipe']
});

// This DOES flash:
spawn('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
    'D:\\toolbox\\Toolbox.exe cli timestamp --datetime "2026-04-02 10:37:00"'], {
    windowsHide: true,
    stdio: ['pipe', 'pipe', 'pipe']
});

Suggested Fix

For exec commands that don't require shell features (pipes, redirections, glob expansion, etc.), spawn the target executable directly without the PowerShell wrapper. This would:

  • Eliminate the console window flash
  • Reduce startup latency (no PowerShell overhead)
  • Reduce memory usage

For commands that do need shell features, consider using cmd.exe /c with CREATE_NO_WINDOW (which handles the flag better than PowerShell), or explore conhost.exe --headless on Windows 10+.

Environment

  • OS: Windows 10 (10.0.26200, x64)
  • Node.js: v24.12.0
  • OpenClaw: latest
  • Shell: PowerShell

Expected behavior

NOT_ENOUGH_INFO

Actual behavior

NOT_ENOUGH_INFO

OpenClaw version

latest

Operating system

Windows 10 (10.0.26200, x64)

Install method

npm

Model

claude-opus-4-6

Provider / routing chain

openclaw -> ixiaozu -> claude-opus-4-6

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

Spawn the target executable directly without the PowerShell wrapper for exec commands that don't require shell features to eliminate the console window flash.

Guidance

  • Identify exec commands that don't require shell features (e.g., pipes, redirections, glob expansion) and modify the createChildAdapter function in src/process/supervisor/adapters/child.ts to spawn the target executable directly.
  • For commands that need shell features, consider using cmd.exe /c with CREATE_NO_WINDOW or explore conhost.exe --headless on Windows 10+ as alternatives to PowerShell.
  • Verify the fix by checking if the console window flash is eliminated for the modified exec commands.
  • Test the modified code with different types of exec commands to ensure the fix works as expected.

Example

// Modified createChildAdapter function
if (process.platform === "win32" && !requiresShellFeatures) {
    // Spawn target executable directly
    return spawn('D:\\toolbox\\Toolbox.exe', ['cli', 'timestamp', '--datetime', '2026-04-02 10:37:00'], {
        windowsHide: true,
        stdio: ['pipe', 'pipe', 'pipe']
    });
} else {
    // Use PowerShell or alternative shell
    return spawn('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', '...'], {
        windowsHide: true,
        stdio: ['pipe', 'pipe', 'pipe']
    });
}

Notes

The fix may not work for all types of exec commands, especially those that require shell features. Additional testing and modifications may be needed to handle such cases.

Recommendation

Apply the workaround by modifying the createChildAdapter function to spawn the target executable directly for exec commands that don't require shell features, as this approach eliminates the console window flash and reduces startup latency and memory usage.

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

NOT_ENOUGH_INFO

Still need to ship something?

×6

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

Back to top recommendations

TRENDING