pythonpython-3.xevent-viewer

How to end an Event Viewer task with Python


I want 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'.

I'm 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')

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