【问题标题】:Is there a way to remove a task to the windows task scheduler via python?有没有办法通过 python 将任务删除到 Windows 任务调度程序?
【发布时间】:2021-04-28 10:07:53
【问题描述】:

我在任务计划程序中成功创建了任务。我知道如何禁用它,但我找不到完全删除它的方法

【问题讨论】:

    标签: python windows scheduled-tasks


    【解决方案1】:

    抱歉迟到了...我刚刚解决了这个问题。 首先我学习了如何使用这个this good snippet from xuhcc on another question...创建一个任务在我在微软的网站上搜索了大约 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) 
    ...
    

    这里的一切基本上都是一个任务计划程序脚本对象,您可以使用以下link.修改它们

    在我的例子中,“任务计划程序脚本对象”语言中的“root_folder”是 TaskFolder 对象,如您所见here.

    【讨论】:

      猜你喜欢
      • 2017-08-04
      • 1970-01-01
      • 2021-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-21
      • 2021-04-16
      相关资源
      最近更新 更多