Skip to content

Instantly share code, notes, and snippets.

@amnweb
Created September 24, 2023 17:32
Show Gist options
  • Save amnweb/0ddb3fdb7ec5da0f0c39f0e9aa9fdd56 to your computer and use it in GitHub Desktop.
Save amnweb/0ddb3fdb7ec5da0f0c39f0e9aa9fdd56 to your computer and use it in GitHub Desktop.
Clear Event Viewer Logs Windows 10/11
@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