1

I was checking but cant find it. Is there any way to trigger Windows Task, in Windows Task Scheduler from Python. It just needs to trigger a specific task from Python file/script nothin more.

IGRACH
  • 3,506
  • 6
  • 33
  • 48

1 Answers1

1

You should be able to use the subprocess module:

import subprocess

task_name = "MyTask"
subprocess.run(["schtasks", "/run", "/tn", task_name])
  • "schtasks" is the Windows command line utility to manage Task Scheduler
  • "/run" is the command to run a task
  • "/tn" specifies the task name.

(you might need to run your Python script with administrative privileges for this to work, depending on the task settings)


Option 2:

I've never tried it before, but pywin32 looks pretty good, if you want a direct API.

Plonetheus
  • 704
  • 3
  • 11