I'm in need a bat file to clear Event Viewer logs and re-boot computer...or help in modifying the ones I already have so that once ran from an administrator prompt, it'd clear the logs...and reboot the computer.
Any help would be appreciated.
Use the wevtutil commnad in your batch script.
To clear a specific log, you must first know its name. To see a list of Event Logs, run:
wevtutil el > Loglist.txt
Find the name of the log you want to clear and use it on the command.
For example, to clear the Application log, use the following command:
wevtutil cl Application
To reboot, use the shutdown command:
shutdown -r
This requires administrator permissions.
The following script searches for all Event logs, clears them, then reboots on success. It must be run as Admin.
@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")
rem Event Logs have been cleared!
shutdown -r
goto fini
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
echo You must run this script as an Administrator!
pause
echo.
:fini