Home > Windows 7 > Script To Clear Event Logs

Script To Clear Event Logs

November 11th, 2012 Leave a comment Go to comments

Awesome script to clear all of your Windows 7 event logs. Wish I remembered where I sourced it from to give them credit.


@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 have been cleared! ^ goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
echo You must run this script as an Administrator!
echo ^ :theEnd
pause>NUL

Categories: Windows 7 Tags:
  1. No comments yet.
  1. No trackbacks yet.