Skip to content

Set machine startup task ExecutionTimeLimit to unlimited#6

Open
alex3236 with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-capsense-exit-issue
Open

Set machine startup task ExecutionTimeLimit to unlimited#6
alex3236 with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-capsense-exit-issue

Conversation

Copilot AI commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

--startup enable (machine-level) created a Task Scheduler entry without an explicit execution limit, so Windows applied the default 72-hour runtime cap. This could stop Capsense silently after long uptime despite intended always-on background behavior.

  • Startup task configuration

    • Updated the machine-level startup path in set_startup_task(enable: bool) to explicitly set the scheduled task’s Settings.ExecutionTimeLimit to PT0S (unlimited) immediately after task creation.
    • Preserves existing behavior for task creation/deletion and error propagation; only extends post-create task settings.
  • Implementation detail

    • After successful schtasks /Create, Capsense now invokes PowerShell to patch the task settings:
let ps_script = format!(
    "$task=Get-ScheduledTask -TaskName '{}';$task.Settings.ExecutionTimeLimit='PT0S';Set-ScheduledTask -InputObject $task | Out-Null",
    task_name
);

Copilot AI changed the title [WIP] Fix Capsense exit after 72 hours due to execution time limit Set machine startup task ExecutionTimeLimit to unlimited Jun 23, 2026
Copilot AI requested a review from alex3236 June 23, 2026 11:59
Replace the two-step PowerShell approach for setting ExecutionTimeLimit
with a single schtasks /Create /XML call using a pre-built XML template.
This eliminates the PowerShell dependency, avoids partial failure states,
and includes ExecutionTimeLimit=PT0S in the task definition from creation.
@alex3236 alex3236 marked this pull request as ready for review June 23, 2026 12:25
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.

Capsense exits after 72 hours when started by machine-level startup task due to Task Scheduler's execution limit

2 participants