chenhg5/cc-connect · error
start scheduled task: %s (%w)
Error message
start scheduled task: %s (%w)
What it means
startWindowsTask wraps an error from runPowerShell running its start script. The script errors with 'scheduled task not found' if Get-ScheduledTask returns nothing, otherwise calls Start-ScheduledTask when the task is not already Running. The wrapped error means the task is missing or Start-ScheduledTask failed.
Source
Thrown at daemon/windows.go:255
Start-Sleep -Milliseconds 500
}
Write-Error 'scheduled task did not stop within timeout'
exit 1
`, powerShellLiteral(windowsTaskName), powerShellLiteral(windowsTaskName), powerShellLiteral(windowsTaskName)))
if err != nil {
return fmt.Errorf("stop scheduled task: %s (%w)", out, err)
}
return nil
}
func startWindowsTask() error {
out, err := runPowerShell(fmt.Sprintf(`
$task = Get-ScheduledTask -TaskName %s -ErrorAction SilentlyContinue
if ($null -eq $task) { Write-Error 'scheduled task not found'; exit 1 }
if ($task.State -ne 'Running') { Start-ScheduledTask -TaskName %s }
`, powerShellLiteral(windowsTaskName), powerShellLiteral(windowsTaskName)))
if err != nil {
return fmt.Errorf("start scheduled task: %s (%w)", out, err)
}
return nil
}
func deleteWindowsTask() error {
out, err := runPowerShell(fmt.Sprintf(`
$task = Get-ScheduledTask -TaskName %s -ErrorAction SilentlyContinue
if ($null -eq $task) { exit 0 }
Unregister-ScheduledTask -TaskName %s -Confirm:$false
`, powerShellLiteral(windowsTaskName), powerShellLiteral(windowsTaskName)))
if err != nil {
return fmt.Errorf("delete scheduled task: %s (%w)", out, err)
}
return nil
}
// CheckLinger is a no-op on Windows (always returns false).
func CheckLinger() (enabled bool, user string) {View on GitHub (pinned to 4000b2338a)
Solutions
- Run `cc-connect daemon install` (or Install()) first — a 'scheduled task not found' error means no task exists.
- Check the task exists for the current user: `Get-ScheduledTask -TaskName <name>`.
- Read the wrapped output; if Start-ScheduledTask failed, verify the Task Scheduler service (`Get-Service Schedule`) is running.
- Reinstall to recreate a fresh task if the entry is corrupt.
Example fix
// before
daemon.Start()
// after: guard with a status check
if !daemon.Installed() {
if err := daemon.Install(scriptPath); err != nil { /* handle */ }
}
if err := daemon.Start(); err != nil { /* handle */ } Defensive patterns
Strategy: validation
Validate before calling
if !daemon.Installed() {
if err := daemon.Install(scriptPath); err != nil {
return err
}
}
// safe to Start() now Try / catch
if err := daemon.Start(); err != nil {
if strings.Contains(err.Error(), "scheduled task not found") {
if instErr := daemon.Install(scriptPath); instErr != nil {
slog.Error("auto-install failed", "error", instErr)
} else {
err = daemon.Start()
}
}
} Prevention
- Never Start before Install — always install first or guard with an Installed() check.
- Do not delete the task manually in Task Scheduler; use the daemon's Uninstall.
- Perform Start/Restart under the same Windows user that registered the task.
When it happens
Trigger: Called by Start/Restart (and indirectly by Install) on Windows when: Get-ScheduledTask finds no task with windowsTaskName (Write-Error + exit 1), Start-ScheduledTask returns an error, or powershell.exe exec fails.
Common situations: Starting/restarting the daemon before it was ever installed; the task was deleted manually in Task Scheduler; different user session (task is per-user AtLogOn); corrupted task entry.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- start existing task: %w
- start task: %w
- register scheduled task: %s (%w)
- delete scheduled task: %s (%w)
- powershell.exe not found: Windows Task Scheduler management
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/29fe9c9fda1aee5f.
Report an issue: GitHub.