Jump to content

Clearing Event Log


Recommended Posts

This .bat file will clear ALL logs in Event Viewer.Handy when you either have a decent running OS and want to start afresh,or need to pinpoint a problem without having to muck about in thousands of logs to try to find a particular event.

Copy and Paste the following to Notepad:File>Save As>your preferred name followed by .bat:

@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 goto theEnd

:do_clear

echo clearing %1

wevtutil.exe cl %1

goto :eof

:noAdmin

exit

Microsoft Batch File must be run under Administrator account or Run As Administrator.

I know this works on Windows 7 OS.I cant say if it works on others. :unknw:

Link to comment
Share on other sites

To clear an event log by using Event Viewer

Start Event Viewer.

In the console tree, navigate to the event log you want to clear.

On the Action menu, click Clear Log.

You can either clear the event log or save a copy of the event log and then clear it.

To clear the event log without saving: Click Clear.

To clear the event log after saving: Click Save and Clear, type a name for the saved file in File name on the Save As dialog box and click Save.

Link to comment
Share on other sites

I've tried clearing events log by log and still there would be entries in "Administrative Events" under Custom views.

This is the only thing I've found to clear ALL event logs.Maybe I overlooked something-as usual.Yet I am pretty meticulous when I set my mind to do something.

Thank you for adding reference to the option to save the log before clearing.That may be useful to some. ;)

Link to comment
Share on other sites

We must always remember that an awful lot of computer users have no idea whatsoever about event logs - or anything else that cannot appear on screen with more than two mouse clicks.

This comment is no negative reflection on those users, just that they don't have any interest or need to know.

Link to comment
Share on other sites

Thanks for that blugarters.

It's saved amongst my other BAT files. (In the bat cave, next to Robin's toothbrush.)

@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 goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
exit

What pops really meant to say was: "We must always remember that an awful lot of computer users have no idea whatsoever." :lol:

Just in case some of them want to move forward along the path and learn. Here is a link:

** Event Viewer **

John.

(In Gotham City it is now accepted, and politically correct to call these people Morons ? :blink: )

This comment is no negative reflection on those users. (In Gotham) :)

Link to comment
Share on other sites

Thank you MANEMAN,for your colorful and enigmatic follow-up on this.IMO,it is always welcome.

By the way,have you bound yourself from posting on Tuesdays?I seem to have acquired a small habit of looking for hilarious content on said day and can't seem to get my fix.I guess I either need to be patient (for this fix WILL be doled out eventually),or check into a local rehab.

:drinks:

Link to comment
Share on other sites

  • 6 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy