Hello Friends, today we are going to learn how to clear all the event logs with a few clicks. Before that understand first what is Event logs and how can we view them.
What are Event Logs ?
According to Microsoft , Event logs are special files that record significant events on your computer, such as when a user logs on to the computer or when a program encounters an error. Whenever these types of events occur, Windows records the event in an event log that you can read by using Event Viewer.
How to View them ?
Go to Run Prompt ( WINDOWS +R ) -> Type "Eventvwr" -> Enter -> Now you will be able to see the event viewer console. This is the place where windows store all the event logs of your computer.
Now the main question is, what is the need of clearing all this logs ?
Whether you do some unauthorized access into a machine or run your own virus on the machine, everything is being recorded in the form of logs. So people can anytime go through this logs and can easily understand what might have happened during that time.
So there is a need of learning how to clear all the logs.
Steps to clear Event Logs :
Step 1 : Open Notepad and copy-paste the below text and save the file as "somename.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 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
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
Step 2 : That's it we are done, Now right click on the "bat file" and do "Run as Administrator". When ever you click on the "bat" file it will clear the logs as shown in the image.
Earlier
NOW
>_ Hope u all enjoyed today'z trick any doubt related to the code just message us in the comment.
Note : Microsoft doesn't recommend deleting of logs so always perform this only at extreme levels.
Comments
Post a Comment