openclaw - 💡(How to fix) Fix Add Windows-Service adapter alongside Scheduled Task in service-*.js

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…

dist/service-*.js (e.g. service-ZFeJibwt.js in 2026.5.12) maps process.platform to a service-management adapter. The win32 entry currently has only one option:

win32: {
    label: "Scheduled Task",
    stage:     stageScheduledTask,
    install:   installScheduledTask,
    uninstall: uninstallScheduledTask,
    stop:      stopScheduledTask,
    restart:   restartScheduledTask,
    isLoaded:  isScheduledTaskInstalled,
    ...
}

On Windows, Scheduled Task is fragile compared to a real Windows Service:

  • No auto-restart on process crash
  • Doesn't start until a user logs in
  • The companion gateway.cmd keeps being regenerated by openclaw gateway start / onboard, dropping the final node.exe ... gateway launch line plus any custom env vars (HTTPS_PROXY, OPENCLAW_CODEX_APP_SERVER_BIN, OPENCLAW_CLI_PATH). Already filed adjacent issues around gateway.cmd and codex env vars (#82735).

Root Cause

dist/service-*.js (e.g. service-ZFeJibwt.js in 2026.5.12) maps process.platform to a service-management adapter. The win32 entry currently has only one option:

win32: {
    label: "Scheduled Task",
    stage:     stageScheduledTask,
    install:   installScheduledTask,
    uninstall: uninstallScheduledTask,
    stop:      stopScheduledTask,
    restart:   restartScheduledTask,
    isLoaded:  isScheduledTaskInstalled,
    ...
}

On Windows, Scheduled Task is fragile compared to a real Windows Service:

  • No auto-restart on process crash
  • Doesn't start until a user logs in
  • The companion gateway.cmd keeps being regenerated by openclaw gateway start / onboard, dropping the final node.exe ... gateway launch line plus any custom env vars (HTTPS_PROXY, OPENCLAW_CODEX_APP_SERVER_BIN, OPENCLAW_CLI_PATH). Already filed adjacent issues around gateway.cmd and codex env vars (#82735).

Fix Action

Fix / Workaround

Repro of the problem the workaround addresses

Code Example

win32: {
    label: "Scheduled Task",
    stage:     stageScheduledTask,
    install:   installScheduledTask,
    uninstall: uninstallScheduledTask,
    stop:      stopScheduledTask,
    restart:   restartScheduledTask,
    isLoaded:  isScheduledTaskInstalled,
    ...
}

---

const win32Service: ServiceAdapter = {
  label: "Windows Service",
  loadedText: "installed",
  notLoadedText: "missing",
  isLoaded: async () => /* sc.exe query <name> exit 0 */,
  install:   async () => /* sc.exe create / nssm-equivalent, or guide user */,
  uninstall: async () => /* sc.exe delete <name> */,
  stop:      async () => /* sc.exe stop <name> */,
  restart:   async () => /* sc.exe stop && sc.exe start */,
  readCommand: /* parse ImagePath */,
  readRuntime: /* sc.exe query <name> + Get-Process by PID */,
};

const win32Schtasks: ServiceAdapter = { /* existing */ };

// Resolution: if a Windows Service with the configured name exists, use win32Service;
// otherwise fall back to win32Schtasks.
RAW_BUFFERClick to expand / collapse

Context

dist/service-*.js (e.g. service-ZFeJibwt.js in 2026.5.12) maps process.platform to a service-management adapter. The win32 entry currently has only one option:

win32: {
    label: "Scheduled Task",
    stage:     stageScheduledTask,
    install:   installScheduledTask,
    uninstall: uninstallScheduledTask,
    stop:      stopScheduledTask,
    restart:   restartScheduledTask,
    isLoaded:  isScheduledTaskInstalled,
    ...
}

On Windows, Scheduled Task is fragile compared to a real Windows Service:

  • No auto-restart on process crash
  • Doesn't start until a user logs in
  • The companion gateway.cmd keeps being regenerated by openclaw gateway start / onboard, dropping the final node.exe ... gateway launch line plus any custom env vars (HTTPS_PROXY, OPENCLAW_CODEX_APP_SERVER_BIN, OPENCLAW_CLI_PATH). Already filed adjacent issues around gateway.cmd and codex env vars (#82735).

Ask

Add a windows-service adapter (or platform-resolution that prefers a Windows Service when one is present). Concretely:

  • Detect an installed Windows Service whose ImagePath wraps node.exe ... openclaw/dist/index.js gateway (or by service name like OpenClawGateway, or by an explicit config setting).
  • When present, openclaw gateway start/stop/restart/status should route to net start/net stop (or Start-Service/Stop-Service via powershell -NoProfile -Command) instead of schtasks.
  • Fall back to Scheduled Task when no service is installed (preserves backward compat).

I currently work around this by wrapping openclaw.ps1 in a PowerShell profile function that intercepts gateway start/stop/restart and calls *-Service OpenClawGateway (a service installed via NSSM). Works locally but obviously doesn't help anyone else using openclaw on Windows. The platform really does deserve a service-mode native to openclaw — NSSM is well known but downloading a third-party tool just to get supervisor semantics is not great UX.

Suggested implementation sketch

const win32Service: ServiceAdapter = {
  label: "Windows Service",
  loadedText: "installed",
  notLoadedText: "missing",
  isLoaded: async () => /* sc.exe query <name> exit 0 */,
  install:   async () => /* sc.exe create / nssm-equivalent, or guide user */,
  uninstall: async () => /* sc.exe delete <name> */,
  stop:      async () => /* sc.exe stop <name> */,
  restart:   async () => /* sc.exe stop && sc.exe start */,
  readCommand: /* parse ImagePath */,
  readRuntime: /* sc.exe query <name> + Get-Process by PID */,
};

const win32Schtasks: ServiceAdapter = { /* existing */ };

// Resolution: if a Windows Service with the configured name exists, use win32Service;
// otherwise fall back to win32Schtasks.

The service name could default to OpenClawGateway and be overridable via a config field like gateway.service.windowsServiceName.

Happy to draft a PR if there's appetite — would just need confirmation on naming and where the platform-resolution branch should live.

Repro of the problem the workaround addresses

  1. Install openclaw 2026.5.12 on Windows.
  2. Run openclaw gateway start — registers Scheduled Task.
  3. Kill the spawned node process: taskkill /F /PID <pid>.
  4. Observe: gateway stays dead until manual schtasks /Run or openclaw gateway start again. No automatic restart.

Compared to an NSSM-wrapped Windows Service which restarts node within 5 seconds and stays Running across reboots.

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

openclaw - 💡(How to fix) Fix Add Windows-Service adapter alongside Scheduled Task in service-*.js