1

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?

ss7
  • 2,902
  • 7
  • 41
  • 90
  • https://stackoverflow.com/a/2241047/9388050 using that code you could find your process ID. For specific task, I'm not sure but you can assign the execution time to a variable when you started the task, and put filter 10 seconds. You can get PID the task your script created. Obviously better way exist, but I think this way can work also for you. – Orhan Solak Jun 21 '21 at 11:51

0 Answers0