Last active
          December 2, 2023 18:21 
        
      - 
      
 - 
        
Save liantian-cn/70ecbc40a896c9be2512 to your computer and use it in GitHub Desktop.  
    List Task Schedule by Python
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | """ | |
| 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) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Hard to fin example with win32api and task use. Thanks you ! It's perfect to make any server script.