I need to check the status of a Windows scheduled task using python, verifying it by the name of the task. I basically want to know if the task is running or not.
I've searched for an answer but I didn't find any.
How can I do that?
Edit: Based on the comments below, the best way to achieve this AND to have the result in some kind of variable (checking if the State is 'Running', for instance) is this:
"Running" in check_output(["C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe", '-Command', '&{Get-ScheduledTask -TaskPath \* | where taskname -eq "TaskName" | select state;}'])