In this tutorial, I make a script to clean all events.
The script is very simple and is just a run of wevtutil command and some printing messages.
Open your editor and save the script with the extensions bat or cmd.
Also, you need to have Administrator rights to run the script.
The script run FOR, IF and GOTO selections to run well with the admin.
First and second lines of code are for to run the batch file and throw up admin rights.
Let’s see the source code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | @echo off FOR /F "tokens=1,2*" %%V IN ('bcdedit') DO SET adminTest=%%V IF (%adminTest%)==(Access) goto noAdmin for /F "tokens=*" %%G in ('wevtutil.exe el') DO (call :do_clear "%%G") echo. echo Event Logs is clean ! goto theEnd :do_clear echo clearing %1 wevtutil.exe cl %1 goto :eof :noAdmin echo Need to have Administrator rights! echo. :theEnd |