openclaw - 💡(How to fix) Fix [Bug]: Hidden CMD Window Appears After Update (findstr process) [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#59394Fetched 2026-04-08 02:24:20
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

After each OpenClaw update, a visible CMD window appears showing findstr /R /C:"18800 .*LISTENING" that cannot be manually closed. This window persists and interferes with the user experience.

  • OS: Windows 11 Pro for Workstations 10.0.26200
  • OpenClaw Version: v2026.4.1
  • Installation Method: npm global install (npm install -g openclaw)
  • Service Management: Windows Task Scheduler (Task Name: "OpenClaw Gateway")

Prerequisite: Every time I install a new version, I need to hide the CMD window that boots from booting, so I changed the Windows task scheduler to: powershell.exe Start in WindowStyle Hidden gateway.cmd. In fact, this problem is encountered with every update.

Root Cause

The issue originates from the restart script generated in dist/update-cli-BJ1Yth1Q.js (lines 520-529):

:force_kill_listener
for /f "tokens=5" %%P in ('netstat -ano ^| findstr /R /C:":${port} .*LISTENING"') do (
  taskkill /F /PID %%P >nul 2>&1
  goto port_released
)

Technical Explanation:

When using for /f with the 'command' syntax (single quotes), cmd.exe creates a child process to execute the piped command. The restart script is spawned with windowsHide: true and stdio: "ignore" (line 562-564):

spawn(isWindows ? "cmd.exe" : "/bin/sh", isWindows ? [
  "/d", "/s", "/c",
  quoteCmdScriptArg(scriptPath)
] : [scriptPath], {
  detached: true,
  stdio: "ignore",
  windowsHide: true
}).unref();

However, the child cmd.exe spawned by for /f to run netstat | findstr does NOT inherit the windowsHide property. This is a Windows limitation where:

  1. Parent process starts with windowsHide: true → hidden window
  2. Parent executes for /f with inline command → spawns child cmd.exe
  3. Child cmd.exe window visibility is controlled by Windows defaults, not parent's spawn options
  4. Child window becomes visible and persists because it's waiting for the for /f loop to complete

Code Example



---

:force_kill_listener
for /f "tokens=5" %%P in ('netstat -ano ^| findstr /R /C:":${port} .*LISTENING"') do (
  taskkill /F /PID %%P >nul 2>&1
  goto port_released
)

---

spawn(isWindows ? "cmd.exe" : "/bin/sh", isWindows ? [
  "/d", "/s", "/c",
  quoteCmdScriptArg(scriptPath)
] : [scriptPath], {
  detached: true,
  stdio: "ignore",
  windowsHide: true
}).unref();

---

:force_kill_listener
netstat -ano | findstr /R /C:":${port} .*LISTENING" >"%TEMP%\openclaw_port_${port}.txt"
for /f "tokens=5" %%P in ("%TEMP%\openclaw_port_${port}.txt") do (
  taskkill /F /PID %%P >nul 2>&1
  del "%TEMP%\openclaw_port_${port}.txt"
  goto port_released
)
del "%TEMP%\openclaw_port_${port}.txt"
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

After each OpenClaw update, a visible CMD window appears showing findstr /R /C:"18800 .*LISTENING" that cannot be manually closed. This window persists and interferes with the user experience.

  • OS: Windows 11 Pro for Workstations 10.0.26200
  • OpenClaw Version: v2026.4.1
  • Installation Method: npm global install (npm install -g openclaw)
  • Service Management: Windows Task Scheduler (Task Name: "OpenClaw Gateway")

Prerequisite: Every time I install a new version, I need to hide the CMD window that boots from booting, so I changed the Windows task scheduler to: powershell.exe Start in WindowStyle Hidden gateway.cmd. In fact, this problem is encountered with every update.

Steps to reproduce

  1. Install OpenClaw globally via npm
  2. Set up auto-start via Windows Task Scheduler (triggered on user logon)
  3. Run openclaw update to update to a newer version
  4. After update completes and gateway restarts, observe a visible CMD window appears
  5. The window title shows something like findstr /R /C:"18800 .*LISTENING"
  6. Attempting to close the window manually fails (it either doesn't respond or reappears)

Expected behavior

After the update is complete, there are no additional windows that cannot be closed, and the gateway is restarted normally

Actual behavior

After the update, a findstr CMD window appears that cannot be closed

OpenClaw version

2026.4.1

Operating system

Windows 11

Install method

npm global

Model

minimax

Provider / routing chain

minimax

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

My ClaudeCode think that is an update-cli issue:

Root Cause Analysis

The issue originates from the restart script generated in dist/update-cli-BJ1Yth1Q.js (lines 520-529):

:force_kill_listener
for /f "tokens=5" %%P in ('netstat -ano ^| findstr /R /C:":${port} .*LISTENING"') do (
  taskkill /F /PID %%P >nul 2>&1
  goto port_released
)

Technical Explanation:

When using for /f with the 'command' syntax (single quotes), cmd.exe creates a child process to execute the piped command. The restart script is spawned with windowsHide: true and stdio: "ignore" (line 562-564):

spawn(isWindows ? "cmd.exe" : "/bin/sh", isWindows ? [
  "/d", "/s", "/c",
  quoteCmdScriptArg(scriptPath)
] : [scriptPath], {
  detached: true,
  stdio: "ignore",
  windowsHide: true
}).unref();

However, the child cmd.exe spawned by for /f to run netstat | findstr does NOT inherit the windowsHide property. This is a Windows limitation where:

  1. Parent process starts with windowsHide: true → hidden window
  2. Parent executes for /f with inline command → spawns child cmd.exe
  3. Child cmd.exe window visibility is controlled by Windows defaults, not parent's spawn options
  4. Child window becomes visible and persists because it's waiting for the for /f loop to complete

Suggested Fix

Modify the restart script to avoid using for /f with inline command execution. Instead, redirect command output to a temporary file first:

:force_kill_listener
netstat -ano | findstr /R /C:":${port} .*LISTENING" >"%TEMP%\openclaw_port_${port}.txt"
for /f "tokens=5" %%P in ("%TEMP%\openclaw_port_${port}.txt") do (
  taskkill /F /PID %%P >nul 2>&1
  del "%TEMP%\openclaw_port_${port}.txt"
  goto port_released
)
del "%TEMP%\openclaw_port_${port}.txt"

This approach:

  • Avoids spawning a visible child cmd.exe for inline command execution
  • Uses file redirection which runs in the same process context
  • Properly cleans up temporary files after use

extent analysis

TL;DR

Modify the restart script to avoid using for /f with inline command execution to prevent a visible CMD window from appearing after an OpenClaw update.

Guidance

  1. Identify the problematic script: Locate the dist/update-cli-BJ1Yth1Q.js file and the restart script it generates, specifically lines 520-529.
  2. Understand the issue: Recognize that the for /f loop with an inline command spawns a child cmd.exe process that does not inherit the windowsHide property, making the window visible.
  3. Apply the suggested fix: Modify the restart script to redirect the command output to a temporary file first, as shown in the provided batch script example, to avoid spawning a visible child cmd.exe.
  4. Verify the fix: After applying the modification, update OpenClaw and observe if the visible CMD window still appears; it should not.

Example

The modified batch script to replace the original :force_kill_listener block:

:force_kill_listener
netstat -ano | findstr /R /C:":${port} .*LISTENING" >"%TEMP%\openclaw_port_${port}.txt"
for /f "tokens=5" %%P in ("%TEMP%\openclaw_port_${port}.txt") do (
  taskkill /F /PID %%P >nul 2>&1
  del "%TEMP%\openclaw_port_${port}.txt"
  goto port_released
)
del "%TEMP%\openclaw_port_${port}.txt"

Notes

This solution assumes that the issue is indeed caused by the for /f loop with an inline command. If the problem persists after applying this fix, further investigation into the OpenClaw update process and its interaction with Windows Task Scheduler may be necessary.

Recommendation

Apply the workaround by modifying the restart script as suggested, as it directly addresses the identified root cause of 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

After the update is complete, there are no additional windows that cannot be closed, and the gateway is restarted normally

Still need to ship something?

×6

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

Back to top recommendations

TRENDING