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.
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 Event Logs is clean !
echo clearing %1
wevtutil.exe cl %1
echo Need to have Administrator rights!