← Back to PRs

#5496: Fix: Windows path separators stripped in Gateway scheduled task

by giuliozelante open 2026-01-31 15:18 View on GitHub →
gateway
## Summary The parseCommandLine function in src/daemon/schtasks.ts was applying Unix-style escape logic (\ as escape character) to Windows cmd.exe command lines. This caused every backslash in file paths to be silently stripped when reading back gateway.cmd, so the gateway entrypoint path was always corrupted. As a result, openclaw doctor permanently reported "Gateway service entrypoint does not match the current install" on Windows, and --fix could never resolve it. ## Changes - **src/daemon/schtasks.ts**: Removed the scapeNext / backslash-escape logic from parseCommandLine. In cmd.exe, \ is a path separator, not an escape character. - **src/daemon/schtasks.test.ts**: Updated existing quoted-path test to use backslash paths. Added a new regression test (preserves backslashes in Windows paths). ## Test plan - [x] pnpm vitest run src/daemon/schtasks.test.ts — all 18 tests pass - [x] Verified on a real Windows 10 machine: openclaw doctor no longer reports the gateway entrypoint mismatch after this fix. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR fixes Windows scheduled task command parsing by removing Unix-style backslash escaping from `parseCommandLine` in `src/daemon/schtasks.ts`, which was stripping path separators when reading `gateway.cmd`. Tests in `src/daemon/schtasks.test.ts` were updated to use realistic backslash paths and a new regression test was added to ensure backslashes are preserved when parsing a typical gateway script that includes `set` env vars and a quoted Node executable path. Overall this aligns the parser with cmd.exe semantics for backslashes and should unblock `openclaw doctor --fix` from repeatedly reporting a gateway entrypoint mismatch on Windows. <h3>Confidence Score: 4/5</h3> - This PR is generally safe to merge and appears to fix the reported Windows path corruption. - Change is narrow (removes backslash-escape handling) and is covered by updated/added unit tests; main remaining risk is that cmd.exe quoting/escaping rules are more complex than simple quote toggling, so unusual arguments containing literal quotes could still parse incorrectly. - src/daemon/schtasks.ts (cmd.exe quoting/escaping edge cases) <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs