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.
Asked
Active
Viewed 39 times
1
-
1Yes, you can run `Start-ScheduledTask` from python subprocess – Paolo Jul 18 '23 at 13:15
-
The complete answer would be nice xD – IGRACH Jul 18 '23 at 13:17
1 Answers
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