Skip to content

docs: Windows autostart task without the 72-hour limit - #7

Merged
LukiPrince merged 1 commit into
mainfrom
docs/windows-task-time-limit
Nov 7, 2026
Merged

LukiPrince merged 1 commit into
mainfrom
docs/windows-task-time-limit

Conversation

@LukiPrince

Copy link
Copy Markdown
Owner

docs/agent.md and docs/migration.md created the autostart task with schtasks /create. Such a task gets ExecutionTimeLimit PT72H (Microsoft: "By default, a task will be stopped 72 hours after it starts to run"), so Windows stopped the agent three days after boot. It also did not start on battery power. schtasks has no switch for either.

The docs now use Register-ScheduledTask with -ExecutionTimeLimit 0, the two battery switches and restart on failure, the same settings as the task XML the setup app writes (crates/agent/src/install.rs, task_xml). There is a note for tasks made the old way (-Force replaces them).

Checked on Windows 11 with throwaway tasks under a normal user: a schtasks /create task reads back PT72H and battery start off; the new settings read back PT0S, restart 255 × PT1M, batteries allowed; -Force turns an old task into the new one. Not run here: the SYSTEM account itself, which needs an elevated shell. A task XML file was not an option: schtasks /xml rejects a UTF-8 file with an encoding="UTF-8" declaration.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TEvvb1DM3ZA5FqELYSs4v8

A task made with `schtasks /create` gets ExecutionTimeLimit PT72H, so Windows stopped the agent
three days after boot, and it did not start on battery power. schtasks has no switch for either,
so the docs now use Register-ScheduledTask with -ExecutionTimeLimit 0 (PT0S), the battery
switches and restart on failure: the task the setup app creates. Checked on Windows 11: a
schtasks task reads back PT72H, the new settings read back PT0S, and -Force replaces an old task.

Source: https://learn.microsoft.com/en-us/windows/win32/taskschd/tasksettings-executiontimelimit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb1DM3ZA5FqELYSs4v8
@LukiPrince
LukiPrince merged commit dca70d1 into main Nov 7, 2026
26 checks passed
@LukiPrince
LukiPrince deleted the docs/windows-task-time-limit branch November 7, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant