Python - 结束计划任务和事件查看器任务的脚本

Python - Script to end scheduled task and event viewer tasks

我一直在寻找使用 python 3.

结束计划任务的解决方案

我已成功结束计划任务,但我必须结束 'Event Viewer Task'。

我正在使用当前代码结束计划任务;

def endScheduledTasks():
    os.system('schtasks /end /tn testSync')

我假设要结束一个事件查看器任务,我需要输入以下内容;

def endEventTasks():
    os.system('eventviewertask /end /tn Replication')

对此的任何意见都会非常有帮助!

在你的命令中

os.system('schtasks /end /tn testSync')

testSync 是什么? 如果这是进程的名称,那么您就错了。 看:

/TN  taskname    Specifies the path\name of the task to terminate.

尝试使用 "path_to_task\and_name_of_task" 例如:

schtasks /end /tn "\Microsoft\XblGameSave\XblGameSaveTask"

见 path_to_task 和 name_of_task:

schtasks