Skip to content

Instantly share code, notes, and snippets.

@liantian-cn
Last active December 2, 2023 18:21
Show Gist options
  • Save liantian-cn/70ecbc40a896c9be2512 to your computer and use it in GitHub Desktop.
Save liantian-cn/70ecbc40a896c9be2512 to your computer and use it in GitHub Desktop.
List Task Schedule by Python
"""
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383607(v=vs.85).aspx
"""
import win32com.client
scheduler = win32com.client.Dispatch("Schedule.Service")
# list user task only
# scheduler.Connect()
# list all task use (requires full administrator rights)
# scheduler.Connect("localhost")
scheduler.Connect()
objTaskFolder = scheduler.GetFolder("\\")
colTasks = objTaskFolder.GetTasks(1)
for task in colTasks:
print(task.Name)
# print(task.Enabled)
# print(task.LastRunTime)
# print(task.LastTaskResult)
# print(task.NextRunTime)
# print(task.NumberOfMissedRuns)
# print(task.State)
# print(task.Path)
# print(task.XML)
@stilobique
Copy link

Hard to fin example with win32api and task use. Thanks you ! It's perfect to make any server script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment