列出计划任务清单

import win32com.client

scheduler = win32com.client.Dispatch('Schedule.Service')
scheduler.Connect()
folders = scheduler.GetFolder('\\')
tasks = folders.GetTasks(1)
TASK_STATE = {0: 'Unknown',
              1: 'Disabled',
              2: 'Queued',
              3: 'Ready',
              4: 'Running'}
for task in list(tasks):
    print('=========================')
    settings = task.Definition.Settings
    print('Path       : %s' % task.Path)
    print('Hidden     : %s' % settings.Hidden)
    print('State      : %s' % TASK_STATE[task.State])
    print('Last Run   : %s' % task.LastRunTime)
    print('Last Result: %s' % task.LastTaskResult)

  

posted @ 2022-12-06 11:26  CrossPython  阅读(38)  评论(0编辑  收藏  举报