Search code examples
pythonscriptingtaskschedulerevent-viewer

Python - Script to end scheduled task and event viewer tasks


I have been searching for a while for the solution to end a scheduled task using python 3.

I have successfully managed to end a scheduled task BUT I have to end an 'Event Viewer Task'.

Im using the current code to end a scheduled task;

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

I assumed to end an event viewer task I would need to enter the following;

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

Any input on this would be very helpful!


Solution

  • in your command

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

    testSync is what? if this is the name of process so you are get mistake. look:

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

    try use "path_to_task\and_name_of_task" for example:

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

    for see path_to_task and name_of_task:

    schtasks