HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run) rather than Windows Task Scheduler to launch at user logon.
Why HKCU Run instead of Task Scheduler
HKCU Run is simpler and works in locked-down domain environments where creating Scheduled Tasks requires elevation or is blocked by policy. The trade-off is reduced control.What you give up
Reliability and control
- No built-in restart policy. Task Scheduler can restart on failure, control retries, and enforce limits. HKCU Run launches once at login — if the process crashes later, Windows won’t relaunch it unless you build that into the app.
- No delayed start, triggers, or conditions. Scheduled Tasks support: on logon with delay, on idle, on network available, on AC power, wake the computer, etc. HKCU Run is: “run this command at user logon, period.”
- Less introspection. With Task Scheduler you can query status, last run result, and last run time. HKCU Run tracks none of that — you need your own status mechanism (PID file, lock file, local socket ping, etc.).
Security / execution context
- Always runs as that user, in an interactive session. This is usually fine for a user-level agent. Running as another account or as SYSTEM is not possible with HKCU Run.
- More vulnerable to user environment changes. HKCU Run launches in the user logon environment. Fragile PATH or working directory assumptions will surface here. Launching via a
.cmdin a fixed user folder (as OpenClaw does) makes this more robust.
Timing
- Runs at logon only. If the machine boots and nobody logs in, HKCU Run does nothing. Task Scheduler can run at boot, at logon, or both.
Policy / admin friction
- Often allowed when Task Scheduler creation is blocked. In domain environments, HKCU Run is frequently the path of least resistance. Some organisations also restrict registry Run keys — it depends on policy.
What you keep (or gain)
- No admin requirement on most machines.
- Simpler install/uninstall: write or delete one registry value.
- Fewer moving parts: no task folder ACL issues.
Best practice with HKCU Run
Add one of the following patterns to the app to recover from crashes: Option A — Watchdog loop: A small supervisor that relaunches the worker process if it exits. Option B — Single instance + self-heal:
This recovers most of the “restart on failure” value you would otherwise get from Task Scheduler.
Recommended pattern for Windows deployments
Prefer a Scheduled Task if the installer can elevate. Fall back to HKCU Run if Task Scheduler registration is blocked or the user refuses UAC.
