-1

I'm trying to find the last run time of a specific task in Windows Task Scheduler on Windows 10.

At the beginning I used schtasks /QUERY /FO LIST /V /TN "TASK_NAME", which gave me a string that I converted to datetime. But, then I realized that I have a problem with different formats.

Is there a way to get this data as a date time from the beginning or at least as a string of Unix time?

TylerH
  • 20,799
  • 66
  • 75
  • 101
rinat dior
  • 49
  • 4
  • 1
    Can you show an example of the output that gave you trouble? – Burhan Khalid Apr 22 '18 at 05:56
  • The `/xml` option gives times in ISO format. – thebjorn Apr 22 '18 at 06:00
  • 1. Where should I write "/xml"? 2. in order to convert from string do datetime I used Last_Run_Time = datetime.strptime(Last_Run_Time, '%m/%d/%Y %H:%M:%S') but if the format changes to '%m-%d-%Y or '%d/%m/%Y and etc. then I'm having a problem. – rinat dior Apr 22 '18 at 06:10
  • I tried the command 'schtasks /QUERY /XML /TN "TASK_NAME"' but it doesn't give me the attribute(?) of last run time. – rinat dior Apr 22 '18 at 07:20

1 Answers1

0

You can use this API: Task Scheduler 2.0 Interfaces.

For example in Python: Python check for Completed and failed Task Windows scheduler

zvi
  • 3,677
  • 2
  • 30
  • 48