I'm trying to find the last run time of a specific task in 'task scheduler' (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 datetime from the beggining or at least as a string of unix time?
thank you!
Asked
Active
Viewed 1,191 times
0
thebjorn
- 24,226
- 9
- 82
- 127
rinat dior
- 41
- 4
-
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 Answers
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,032
- 1
- 23
- 40