Advertisements

How to delete all Windows Event logs at once

When troubleshooting Windows it’s often very helpful to start with clean log files. This shows you what’s happening with a system in the moment and you don’t waste time digging through log files and waiting for them to load.

To clear all Windows events from the logs, simply open an administrator-level command prompt and enter:

for /f %x in ('wevtutil el') do wevtutil cl "%x"

After a few moments all of the log files will be cleared.

Batch file use: If you’re using this in a batch file, you need to add an extra % sign to the variable names. Also, make sure you’re running the batch file as an administrator or you will get a lot of access denied messages. %x is valid on the command line only; it needs to be %%x in batch file. Here’s the updated code:

for /f %%x in ('wevtutil el') do wevtutil cl "%%x"

Thanks to stefan for bringing this up in the comments.

 

Advertisements

,