sleep: on Windows, unschedule --all removes nothing and reports success, because schtasks lists task names with a leading backslash
On Windows, skillopt-sleep schedule creates a task named SkillOpt-Sleep-<digest> in the root folder of Task Scheduler. _list_win_tasks then reads schtasks /query /fo csv and keeps names that start with SkillOpt-Sleep-. But schtasks lists the full task path, so the name comes back as \SkillOpt-Sleep-<digest> and never matches.
Commit: 45f65ca04f5f6713bca7b9797b495696ba812751
https://github.com/microsoft/SkillOpt/blob/45f65ca04f5f6713bca7b9797b495696ba812751/skillopt_sleep/scheduler.py#L87-L103
Effects:
skillopt-sleep unschedule --alldeletes nothing, but still prints "Removed all scheduled tasks." and exits 0. The nightly tasks keep running.list_scheduled()always returns[], soskillopt-sleep schedulenever prints the "currently scheduled" list on Windows.
unschedule for a single project still works, because it builds the task name itself and does not use the listing.
Real schtasks /query /fo csv output on Windows 11:
"TaskName","Next Run Time","Status"
"\OneDrive Startup Task-S-1-5-21-...","N/A","Ready"
Repro, with subprocess.run mocked to return that format:
from unittest import mock
from skillopt_sleep import scheduler
csv = '"TaskName","Next Run Time","Status"\r\n"\SkillOpt-Sleep-0123456789abcdef0123","N/A","Ready"\r\n'
proc = mock.Mock(returncode=0, stdout=csv, stderr="")
with mock.patch("sys.platform", "win32"), \
mock.patch("shutil.which", return_value="schtasks.exe"), \
mock.patch("subprocess.run", return_value=proc) as run:
print(scheduler.list_scheduled()) # []
print(scheduler.unschedule(all_projects=True)) # (True, 'Removed all scheduled tasks.')
print([c.args[0][1] for c in run.call_args_list]) # ['/query', '/query'], no '/delete'
Expected: list_scheduled() returns ['SkillOpt-Sleep-0123456789abcdef0123'], and unschedule --all deletes that task.
Actual: the task is not found, nothing is deleted, and the command reports success.
I have a fix with a regression test and will open a PR.