Clear out Event Logs

User avatar
viking33
PlatinumLounger
Posts: 5685
Joined: 24 Jan 2010, 19:16
Location: Cape Cod, Massachusetts,USA

Clear out Event Logs

Post by viking33 »

If you REALLY want to clear out all of your Event Log files in one easy shot, here is a batch file to do it. Works fast and efficiently.
Just copy, save and name it something like Event Clear.bat and run as the administrator. This is not my authorship but found it while Googling around for a easy way to clean things out.
--------------------------------------------------
@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
------------------------------

Have used it for some time now and it seems to do a decent job.
BOB
:massachusetts: :usa:
______________________________________

If I agreed with you we'd both be wrong.

User avatar
John Gray
PlatinumLounger
Posts: 5406
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Clear out Event Logs

Post by John Gray »

Surely standard practice is to set all the event logs to appropriate sizes, and let the messages 'wrap round' when the corresponding log is full?
Event logs occupy so little space on a hard disk that clearing them seems hardly worth the bother.
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

User avatar
viking33
PlatinumLounger
Posts: 5685
Joined: 24 Jan 2010, 19:16
Location: Cape Cod, Massachusetts,USA

Re: Clear out Event Logs

Post by viking33 »

John Gray wrote:Surely standard practice is to set all the event logs to appropriate sizes, and let the messages 'wrap round' when the corresponding log is full?
Event logs occupy so little space on a hard disk that clearing them seems hardly worth the bother.
You may be right on this regarding size, John, but if you watch this thing run in the "command line" box, there seem to be a TON of logs that are cleared. ( I'll have to run a comparison before and after running it to see just how much it clears )
To me, at least, it is a bit of a bother to get into the Event Log and try to search to find a particular log entry in a long string of items. Also, I don't run this that often as a space saving utility.
I posted it as an item of interest to all.
BOB
:massachusetts: :usa:
______________________________________

If I agreed with you we'd both be wrong.

User avatar
John Gray
PlatinumLounger
Posts: 5406
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Clear out Event Logs

Post by John Gray »

Well, I'll agree there are a lot of files (141 on my Windows 7 Pro 64-bit PC, totalling 112 MB in size, in C:\Windows\System32\winevt\logs - which you have to make visible), but the only ones of any size are the System, Application and Security logs, beloved of all systems admins since NT 3.50.

Here are the first batch, sorted in descending order of size:
EventLogs.png
I wouldn't have thought that messing with 112 MB of files was worth the effort, personally...
You do not have the required permissions to view the files attached to this post.
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...