Created
September 24, 2023 17:32
-
-
Save amnweb/0ddb3fdb7ec5da0f0c39f0e9aa9fdd56 to your computer and use it in GitHub Desktop.
Clear Event Viewer Logs Windows 10/11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment