how to create a batch script to look for a particular event ID (Eventid: 26) every 5 minutes and if it finds event id of 26 then execute certain commands( Kill a particular windows service and restart it)in windows server 2003 r2?

1

There are 1 answers

0
AudioBubble On

From schtasks /create /?

==> Creates a scheduled task "EventLog" to run wevtvwr.msc starting
    whenever event 101 is published in the System channel

    SCHTASKS /Create /TN EventLog /TR wevtvwr.msc /SC ONEVENT
             /EC System /MO *[System/EventID=101]

and

==> Creates a scheduled task "logtracker" on remote machine "ABC"
    to run notepad.exe every five minutes starting from the
    specified start time with no end time. The /RP password will be
    prompted for.

    SCHTASKS /Create /S ABC /U domain\user /P password /SC MINUTE
             /MO 5 /TN logtracker
             /TR c:\windows\system32\notepad.exe /ST 18:30
             /RU runasuser /RP