![](/img/trans.png)
[英]Is there a way to add a task to the windows task scheduler via python 3?
[英]Is there a way to remove a task to the windows task scheduler via python?
我在任务计划程序中成功创建了任务。 我知道如何禁用它,但我找不到完全删除它的方法
抱歉迟到了......我刚刚解决了这个问题。 首先,我在另一个问题上学习了如何使用来自xuhcc的这个好片段来创建任务......在我在 Microsoft 的网站上搜索了大约 40 分钟后,我得到了它并且它可以工作。
这是我的代码的一小部分:
def deleteWindowsTask(updatetask_id):
obj = UpdateTask.objects.get(pk=updatetask_id)
scheduler = win32com.client.Dispatch('Schedule.Service')
scheduler.Connect()
root_folder = scheduler.GetFolder('\\')
root_folder.DeleteTask(obj.task_name,0)
...
基本上这里的所有内容都是一个任务计划程序脚本 object,您可以使用以下链接对其进行修改。
在我的情况下,“任务计划程序脚本对象”语言中的“root_folder”是TaskFolder object,如您在此处看到的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.