Cleanup Image before Capture - Event Viewer cleanup batch file

Guys, Why WIM Image cleanup is more important ? This is because it delivers error-free images to the customer and reduces the manufacturer's bugs and issues. While troubleshooting the end-user machine, there should not be previous logs that can create confusion.

If you are going to clean up the event viewer logs one by one manually it will take your whole day and also an irritating job for you. don't worry we have created a simple and easy script that helps you to clean the event viewer logs within a minute.

clean reference images before capturing them in WIM format.



copy below batch code into a new notepad file and save it as an EventViewer.bat and run as administrator on reference machine before running the sysprep✌

"Title Executed by build Administrators

REM ***********************************************************

REM*****Written by Dashrath Chate

REM*****Created Date 1:37 PM 9/19/2021

REM*****Purpose: To clean reference images before

REM***** capturing them in WIM format.

REM************************************************************

@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 All Event Logs have been cleared!

goto theEnd

:do_clear

echo clearing %1

wevtutil.exe cl %1

goto :eof

:noAdmin

echo Current user permissions to execute this .BAT file are inadequate.

echo This .BAT file must be run with administrative privileges.

echo Exit now, right click on this .BAT file, and select "Run as administrator". 

pause >nul

:theEnd

Exit

No comments:

Post a Comment

Leave your valuable words here for improve better.