Skip to main content
Have you ever wondered how many logs are available on your system?

Just how much space are they taking up?

Have you ever noticed in the event viewer there are events that you cannot clear, like Custom Views, Administrative Tasks, Device Manager, and etc.?

 

Technet has an old article that is still relevant.  It references the Wevtutil.exe that is on your system.  https://technet.microsoft.com/en-us/library/Cc732848.aspx



For those who know what a batch file is and are comfortable creating and executing one, I have saved you the trouble of having to create one from the Technet article.  There are many examples of usage available if you just search for them.

 

I'm a bit lazy at times so I borrowed this code and I have been using it on my Windows 10 Pro for a while and I love it.  Just create the file, right click, “run as admin” and watch that baby go… It clears 1024 logs on mine.

 

Enjoy

 

"Use at your own risk."

 

-------------------------File Begins Below-----------------------------------------

 @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! ^<press any key^>

goto theEnd

:do_clear

echo clearing %1

wevtutil.exe cl %1

goto :eof

:noAdmin

echo You must run this script as an Administrator!

echo ^<press any key^>

:theEnd

pause>NUL

 

End Code

 
Be the first to reply!

Reply