Windows 8.1 how to write a bat file to clear all entries in Event Viewer?

Someone at Microsoft Support downloaded the following bat file which deletes all errors located in Windows 7 OS.  It doesn't work on Windows 8.1.  Does anyone know what changes can be made to this bat file to allow the deletion of events on Windows 8,1?


@echo on

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

July 19th, 2015 7:09pm

Try:

@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")
/bu:
echo.
echo goto theEnd
:do_clear
echo clearing %1
r cl Application /bu:C:\EventViewerBackups\Applicationbackup.evtx %1
goto :eof
:noAdmin
exit

Free Windows Admin Tool Kit Click here and download it now
July 19th, 2015 9:06pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics