I'm trying to use win32com.client in order to interact with scheduled tasks on windows.
So far it's working fine, but I'm having trouble figuring out how to get the PID of a running process created by the scheduled task.
Documentation says to look at the value of IRunningTask::get_EnginePID method. However, while I can do something like:
scheduler = win32com.client.Dispatch('Schedule.Service')
scheduler.Connect()
folder = scheduler.GetFolder('\\')
task = folder.GetTask('Name of created task')
task.State
task.Name
I'm not sure how to access this EnginePID attribute as task.EnginePID
or anything like that doesn't work.
So for example, I have a task that launches calc.exe. I want to find the PID of the calc.exe or whatever process spawned by the scheduled task.
How can I achieve this?