Skip to content

fix(sleep): find Windows scheduled tasks listed with their folder path - #397

Open
Muhammad Abdullah Butt (1AbdullahButt) wants to merge 1 commit into
microsoft:mainfrom
1AbdullahButt:fix/sleep-win-task-list
Open

Muhammad Abdullah Butt (1AbdullahButt) wants to merge 1 commit into
microsoft:mainfrom
1AbdullahButt:fix/sleep-win-task-list

Conversation

@1AbdullahButt

Copy link
Copy Markdown
Contributor

Fixes #396

_list_win_tasks keeps rows of schtasks /query /fo csv whose name starts with SkillOpt-Sleep-. schtasks prints the full task path, so the root-folder task that schedule creates is listed as \SkillOpt-Sleep-<digest> and never matched. As a result, on Windows:

  • list_scheduled() was always empty, so schedule never showed the "currently scheduled" list.
  • unschedule --all deleted nothing but still printed "Removed all scheduled tasks." and exited 0.

The fix strips the leading backslash before the prefix check. The returned name is the same one _win_task_name() builds, which schtasks /delete /tn already receives in the single-project path.

Tests

  • Two new tests in tests/test_scheduler_windows.py feed list_scheduled() and unschedule(all_projects=True) the CSV format that schtasks prints. I checked that format against real schtasks /query /fo csv output on Windows 11. Both tests fail on main ([] != [...]) and pass with this change.
  • python -m pytest -q tests -k schedul on Windows: 60 passed, 3 skipped.

This change was written with Claude Code.

🤖 Generated with Claude Code

schtasks /query /fo csv prints each task's full path, so the task that
`schedule` creates as SkillOpt-Sleep-<digest> is listed as
\SkillOpt-Sleep-<digest> and never matched the prefix check.
list_scheduled() was always empty on Windows, and `unschedule --all`
deleted nothing while reporting "Removed all scheduled tasks."

Strip the leading backslash before matching.

Fixes microsoft#396

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

sleep: on Windows, unschedule --all removes nothing and reports success, because schtasks lists task names with a leading backslash

1 participant