Clear Windows 7 Event Log


/ Published in: DOS Batch
Save to your folder(s)

This is a simple batch script to clear the event logs from a windows 7 or server 2008 machine. The script does *not* save these logs. This was tested on a local machine but could be adapted for remote use.


Copy this code and paste it in your HTML
  1. @echo off
  2. @cls
  3. ::Tested on a local machine using Windows 7 x64 Home Premium
  4. ::Use the ping command to wait -n # seconds; change # for time to wait
  5. ::Basic code can be found in various places on the internet
  6. ::Modified by Rectifier 06-30-2012
  7.  
  8. ::If you receive an error try running the batch file as an administrator
  9. ::Note that the event log has to be enabled to begin with or this is a fairly useless batch
  10.  
  11. ::Make readable prompt
  12. echo. & echo. & echo.
  13. echo Clearing event logs...
  14. ::Clear event logs by searching for them using a for loop
  15. @for /f %%i in ( 'wevtutil el' ) do wevtutil cl "%%i" >NUL 2>&1
  16. ::Clear event logs not found by the for loop
  17. wevtutil.exe cl "Microsoft-Windows-Diagnosis-DPS/Operational"
  18. wevtutil.exe cl "Microsoft-Windows-User Profile Service/Operational"
  19. wevtutil.exe cl "Microsoft-Windows-Windows Defender/Operational"
  20. wevtutil.exe cl "Microsoft-Windows-Windows Defender/WHC"
  21. wevtutil.exe cl "Microsoft-Windows-Windows Firewall With Advanced Security/Firewall"
  22. wevtutil.exe cl System
  23. ::Informing the batch is finished executing
  24. echo Batch finished!
  25. ping 127.0.0.1 -n 3 | find "Reply" > nul

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.