Fix Windows node service to run hidden without console window#2
Merged
Fix Windows node service to run hidden without console window#2
Conversation
- Remove /IT flag that causes interactive session - Create PowerShell wrapper script with -WindowStyle Hidden - Update schtasks to use PowerShell execution for hidden background mode - Modify uninstallScheduledTask to clean up both .cmd and .ps1 files - All existing tests pass Co-authored-by: TimLai666 <[email protected]>
- Export quotePowerShellArg and buildPowerShellWrapper for testing - Add 13 new tests covering PowerShell argument escaping and script generation - Test all script components: description, working directory, environment vars - Verify -WindowStyle Hidden flag is correctly applied - All 30 tests pass Co-authored-by: TimLai666 <[email protected]>
- Remove unused $process variable from PowerShell wrapper - Change ExecutionPolicy from Bypass to RemoteSigned for better security - Properly escape PowerShell script path using quoteCmdArg - Add comments explaining security and escaping choices - Update tests to match new output (remove -PassThru check) Co-authored-by: TimLai666 <[email protected]>
- Use path.join and path.basename instead of string replace for reliability - Ensure .ps1 extension properly replaces .cmd regardless of case - Clarify comments about CMD script backward compatibility - Apply same robust path handling in both install and uninstall functions Co-authored-by: TimLai666 <[email protected]>
- Clarify CMD script purpose: manual troubleshooting/fallback - Make error handling consistent: silent failure for both CMD and PS1 - Add informative message when no scripts found to remove - Document that scheduled task uses PowerShell, CMD is for manual use Co-authored-by: TimLai666 <[email protected]>
Copilot
AI
changed the title
[WIP] Fix OpenClaw Node scheduled task to run in background
Fix Windows node service to run hidden without console window
Feb 7, 2026
TimLai666
reviewed
Feb 7, 2026
Author
修改了 Windows 定時任務的實現,解決控制台視窗問題: 主要改動:
技術細節:
測試:
效果: |
TimLai666
approved these changes
Feb 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
openclaw node installcreates a Windows Scheduled Task that spawns a visible console window. Closing the window terminates the node host, breaking background service operation.Changes
Root cause:
/ITflag forces interactive session +.cmdwrapper spawns consoleSolution: Remove
/IT, use PowerShell wrapper with hidden windowTask Creation (
src/daemon/schtasks.ts)/ITflag fromschtasks /Create(line 356)Start-Process -WindowStyle Hidden -Waitpowershell.exe -ExecutionPolicy RemoteSigned -WindowStyle Hidden -File script.ps1.cmdfor manual troubleshootingPowerShell Wrapper
Path & Escaping
path.join()+path.basename()for.cmd→.ps1conversionquotePowerShellArg(): escape single quotes by doublingquoteCmdArg(): escape script path in task commandCleanup
.ps1and.cmdscriptsTest Coverage
Added 13 tests for PowerShell wrapper: argument escaping, script generation, hidden window flags.
All 30 tests pass.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/openclaw/openclaw/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._b3db5af5a763a0066b7099d601695d0b/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/openclaw/openclaw/node_modules/.pnpm/[email protected]_@opentelemetry+[email protected]_@types+[email protected]_@vitest+browser-playwright@4._b3db5af5a763a0066b7099d601695d0b/node_modules/vitest/dist/workers/forks.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.