openclaw - 💡(How to fix) Fix [Bug]: Windows auto-update restart script hangs indefinitely on `schtasks /End`, leaves zombie cmd.exe and flashing Terminal window [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
openclaw/openclaw#69970Fetched 2026-04-23 07:30:53
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
commented ×1

After OpenClaw auto-updates to v2026.4.20 on Windows, the restart batch script (openclaw-restart-*.bat) generated in %TEMP% hangs indefinitely, leaving a zombie cmd.exe process and causing a flashing Windows Terminal window.

Error Message

  • schtasks /End on a task that is not currently running appears to hang on Windows in certain TaskScheduler states, rather than returning immediately with an error

Root Cause

The restart script (openclaw-restart-*.bat) has this structure:

@echo off
REM Standalone restart script — survives parent process termination.
timeout /t 2 /nobreak >/dev/null
schtasks /End /TN "OpenClaw Gateway"          ← HANGS HERE
REM ... port polling loop ...
schtasks /Run /TN "OpenClaw Gateway"
del "%~f0"

Line 5 schtasks /End /TN "OpenClaw Gateway" hangs because:

  • The scheduled task's Last Result: 1 (from the previous run at logon)
  • The task state is Ready (not Running)
  • schtasks /End on a task that is not currently running appears to hang on Windows in certain TaskScheduler states, rather than returning immediately with an error

Evidence:

  • schtasks /query /TN "OpenClaw Gateway" /v /fo list shows:
    • Last Run Time: 2026/4/22 9:08:07
    • Last Result: 1
    • Status: Ready
  • TaskScheduler Operational Event Log has zero entries for "OpenClaw Gateway" in the past 2 hours — confirming schtasks /End never completed its RPC call
  • cmd.exe PID created at 10:18:12, still alive at 11:30+ with the bat as its command line

Fix Action

Workaround

Set update.auto.enabled: false in openclaw.json to prevent the auto-update restart script from being triggered. Manual updates can still be performed via the CLI or GUI.

Code Example

@echo off
REM Standalone restart script — survives parent process termination.
timeout /t 2 /nobreak >/dev/null
schtasks /End /TN "OpenClaw Gateway"HANGS HERE
REM ... port polling loop ...
schtasks /Run /TN "OpenClaw Gateway"
del "%~f0"

---

REM Option A: Use timeout wrapper
start /b /wait cmd /c "timeout /t 10 /nobreak >/dev/null & schtasks /End /TN "OpenClaw Gateway""

REM Option B: Check task state before attempting to stop
schtasks /query /TN "OpenClaw Gateway" /fo csv | findstr /i "Running" >/dev/null
if not errorlevel 1 (
    schtasks /End /TN "OpenClaw Gateway"
) else (
    echo Task not running, skipping End
)
RAW_BUFFERClick to expand / collapse

Environment

  • OpenClaw version: 2026.4.20 (auto-updated from prior stable)
  • OS: Windows 11 (Build 26200+)
  • Node.js: System-installed (C:\Program Files\nodejs\node.exe)
  • Gateway port: 18789
  • Scheduled Task: OpenClaw Gateway (At logon, runs gateway.cmd)
  • Auto-update config: update.auto.enabled: true, channel: stable

Description

After OpenClaw auto-updates to v2026.4.20 on Windows, the restart batch script (openclaw-restart-*.bat) generated in %TEMP% hangs indefinitely, leaving a zombie cmd.exe process and causing a flashing Windows Terminal window.

Steps to Reproduce

  1. Have OpenClaw installed on Windows with update.auto.enabled: true
  2. Let auto-update trigger (or wait for scheduled check)
  3. Update completes successfully (update-check.json confirms autoLastSuccessVersion: 2026.4.20)
  4. Restart bat is generated and executed
  5. Bat hangscmd.exe stays alive for 50+ minutes, bat file is never self-deleted

Expected Behavior

The restart script should:

  1. Stop the old Gateway via schtasks /End
  2. Wait for port 18789 to be released (max 10 attempts)
  3. Start the new Gateway via schtasks /Run
  4. Self-delete and exit

All within ~15 seconds.

Actual Behavior

  • cmd.exe running the bat hangs indefinitely (observed 50+ minutes)
  • The bat file is never self-deleted (still present in %TEMP%)
  • A Windows Terminal window repeatedly flashes on screen (appears to be port-checking via findstr)
  • Meanwhile, the Gateway service (node.exe) is actually running and healthy on port 18789

Root Cause Analysis

The restart script (openclaw-restart-*.bat) has this structure:

@echo off
REM Standalone restart script — survives parent process termination.
timeout /t 2 /nobreak >/dev/null
schtasks /End /TN "OpenClaw Gateway"          ← HANGS HERE
REM ... port polling loop ...
schtasks /Run /TN "OpenClaw Gateway"
del "%~f0"

Line 5 schtasks /End /TN "OpenClaw Gateway" hangs because:

  • The scheduled task's Last Result: 1 (from the previous run at logon)
  • The task state is Ready (not Running)
  • schtasks /End on a task that is not currently running appears to hang on Windows in certain TaskScheduler states, rather than returning immediately with an error

Evidence:

  • schtasks /query /TN "OpenClaw Gateway" /v /fo list shows:
    • Last Run Time: 2026/4/22 9:08:07
    • Last Result: 1
    • Status: Ready
  • TaskScheduler Operational Event Log has zero entries for "OpenClaw Gateway" in the past 2 hours — confirming schtasks /End never completed its RPC call
  • cmd.exe PID created at 10:18:12, still alive at 11:30+ with the bat as its command line

Suggested Fix

The restart script should guard against schtasks /End hanging:

REM Option A: Use timeout wrapper
start /b /wait cmd /c "timeout /t 10 /nobreak >/dev/null & schtasks /End /TN "OpenClaw Gateway""

REM Option B: Check task state before attempting to stop
schtasks /query /TN "OpenClaw Gateway" /fo csv | findstr /i "Running" >/dev/null
if not errorlevel 1 (
    schtasks /End /TN "OpenClaw Gateway"
) else (
    echo Task not running, skipping End
)

Additionally, schtasks /End should have a timeout (e.g., 10 seconds) and fall through to force-kill if it doesn't return.

Workaround

Set update.auto.enabled: false in openclaw.json to prevent the auto-update restart script from being triggered. Manual updates can still be performed via the CLI or GUI.

extent analysis

TL;DR

The restart script hangs indefinitely due to schtasks /End command hanging on a task that is not currently running, and a workaround or fix is needed to prevent this issue.

Guidance

  • Modify the restart script to guard against schtasks /End hanging by using a timeout wrapper or checking the task state before attempting to stop it.
  • Implement a fallback mechanism to force-kill the task if schtasks /End does not return within a specified timeout (e.g., 10 seconds).
  • Consider setting update.auto.enabled: false in openclaw.json as a temporary workaround to prevent the auto-update restart script from being triggered.
  • Verify the task state and last result using schtasks /query to ensure the task is not in a state that would cause schtasks /End to hang.

Example

start /b /wait cmd /c "timeout /t 10 /nobreak >/dev/null & schtasks /End /TN "OpenClaw Gateway""

or

schtasks /query /TN "OpenClaw Gateway" /fo csv | findstr /i "Running" >/dev/null
if not errorlevel 1 (
    schtasks /End /TN "OpenClaw Gateway"
) else (
    echo Task not running, skipping End
)

Notes

The provided fix options (A and B) should be tested and validated to ensure they resolve the issue without introducing new problems. Additionally, the root cause of the schtasks /End hanging issue should be investigated further to determine if it's a Windows or OpenClaw-specific problem.

Recommendation

Apply the suggested fix by modifying the restart script to include a timeout wrapper or task state check, as this should prevent the schtasks /End command from hanging and resolve 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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING