简体   繁体   中英

Can I open windows task scheduler with Python?

I've just been experimenting with python so that I can make life a little more continent for myself. I tend to be doing multiple things at a time and python has been extremely helpful with moving files and opening programs. I was just wondering if there is a way it can open the scheduler, and if you can bind it to a key?

With standard os library

import os
os.system('control schedtasks')

Or for more complicated options, with subprocess

import subprocess
p = subprocess.Popen("control schedtasks")

I would try something simple like this to open the scheduler:

import os

os.system("taskschd.msc")

Note that if you don't want the UAC popup to ask you for elevation whenever your script runs, your script itself will need to be run as admin (so that every sub-process that it executes, such as the Task Scheduler, will also subsequently be run as admin).

As far as binding the script to a key...you may honestly have the most luck using something like https://autohotkey.com/ to do so. Alternatively, you could make your script run at login, and then use a package like https://pypi.python.org/pypi/system_hotkey/1.0.3 to implement hotkey watchers into it (note that this is a Python 3 package).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM