Event Viewer One Click Clear

How to Clear Event Viewer with One Click in Windows


   Information
This will show you how to create a command line shortcut that will clear all of the Event Viewer logs in one click.



Here is a batch file that can help you clear the event viewer in one click.

Download


Download this file above..

Unzip on your desktop.

You can use the task scheduler to give it a high priority so you won't get a UAC prompt

See Brink's Tip HERE

Or, just copy this script and paste in notepad and save as Clean Viewer.BAT

Right click, and click on Run as administrator to run the file
Code:
@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 goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
exit

:geek:






 
Last edited by a moderator:
@Lightningltd

Great batch file! but I have always wondered, what's with the long pauses between various log clearings?

dev

Slow processor reaction. Mine slides like butter.

:geek:
 

My Computer My Computer

Computer Manufacturer/Model Number
Asus
OS
Windows 7 x64 Ultimate SP1
CPU
I5 875K Unlocked
Motherboard
P7P55D-E-PRO
Memory
Kingston HyperX Genesis DDR3-1600MHz 9-9-9-27 @ 1.65V XMP
Graphics Card(s)
EVGA GeForce GTX 570 HD 732 MHz GPU 1280 MB, 152 GB Mem
Sound Card
Onboard Via 1828S
Monitor(s) Displays
Samsung T240 HD
Screen Resolution
Dual 1920X1200 1027X768
Hard Drives
OCZ Vertex II Extended Sandforce SSD 60 Gig 2X WD Black Caviar 1 terabyte 6GBS Transer Sata 3 Marvell Chip
PSU
Corsair Gold fully Modular 80 Plus 850
Case
Coolermaster Half X Full Tower
Cooling
Noctua NH-U12P
Keyboard
MS
Mouse
MS
Internet Speed
Fast enough
Other Info
My fridge has a water tap
I have 3 edits of this file, which one is the best?

@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 Event Logs have been cleared! ^<press any key^>
goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
echo You must run this script as an Administrator!
echo ^<press any key^>
:theEnd
pause>NUL

--------------------------------------------------------------------------------------------

@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 goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
exit

---------------------------------------------------------------------------------------------

@echo off
FOR /F "tokens=1,2*" %%V IN ('bcdedit') DO SET adminTest=%%V
IF (%adminTest%)==(Access) goto theEnd
for /F "tokens=*" %%G in ('wevtutil.exe el') DO (call :do_clear "%%G")
goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:theEnd


They all appear to do the same thing, but is any one of them "better" than the others?
 

My Computer My Computer

Computer Manufacturer/Model Number
Dell XPS 8300
OS
Win7 x64
CPU
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
Memory
16GB Dual-Channel
Graphics Card(s)
NVIDIA GeForce GTS 450
Monitor(s) Displays
Viewsonic VX2753mh-LED 27" HDMI
Screen Resolution
1920x1080
Hi there,

The last one is the best. It has all unecessary commands removed.


@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 goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
exit

:cool:
 

My Computer My Computer

Computer Manufacturer/Model Number
Asus
OS
Windows 7 x64 Ultimate SP1
CPU
I5 875K Unlocked
Motherboard
P7P55D-E-PRO
Memory
Kingston HyperX Genesis DDR3-1600MHz 9-9-9-27 @ 1.65V XMP
Graphics Card(s)
EVGA GeForce GTX 570 HD 732 MHz GPU 1280 MB, 152 GB Mem
Sound Card
Onboard Via 1828S
Monitor(s) Displays
Samsung T240 HD
Screen Resolution
Dual 1920X1200 1027X768
Hard Drives
OCZ Vertex II Extended Sandforce SSD 60 Gig 2X WD Black Caviar 1 terabyte 6GBS Transer Sata 3 Marvell Chip
PSU
Corsair Gold fully Modular 80 Plus 850
Case
Coolermaster Half X Full Tower
Cooling
Noctua NH-U12P
Keyboard
MS
Mouse
MS
Internet Speed
Fast enough
Other Info
My fridge has a water tap
Hi there,

The last one is the best. It has all unecessary commands removed.


@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 goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
exit

:cool:


You say the last one but you show the second one in your post???
 

My Computer My Computer

Computer Manufacturer/Model Number
Dell XPS 8300
OS
Win7 x64
CPU
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
Memory
16GB Dual-Channel
Graphics Card(s)
NVIDIA GeForce GTS 450
Monitor(s) Displays
Viewsonic VX2753mh-LED 27" HDMI
Screen Resolution
1920x1080
My Bad, second one.

Sorry
 

My Computer My Computer

Computer Manufacturer/Model Number
Asus
OS
Windows 7 x64 Ultimate SP1
CPU
I5 875K Unlocked
Motherboard
P7P55D-E-PRO
Memory
Kingston HyperX Genesis DDR3-1600MHz 9-9-9-27 @ 1.65V XMP
Graphics Card(s)
EVGA GeForce GTX 570 HD 732 MHz GPU 1280 MB, 152 GB Mem
Sound Card
Onboard Via 1828S
Monitor(s) Displays
Samsung T240 HD
Screen Resolution
Dual 1920X1200 1027X768
Hard Drives
OCZ Vertex II Extended Sandforce SSD 60 Gig 2X WD Black Caviar 1 terabyte 6GBS Transer Sata 3 Marvell Chip
PSU
Corsair Gold fully Modular 80 Plus 850
Case
Coolermaster Half X Full Tower
Cooling
Noctua NH-U12P
Keyboard
MS
Mouse
MS
Internet Speed
Fast enough
Other Info
My fridge has a water tap
Thanks a lot.
 

My Computer My Computer

Computer Manufacturer/Model Number
Asus N53v-DH 72
OS
windows 7 home premium 64bit
CPU
Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
Motherboard
ASUSTeK Computer Inc
Memory
6049 MB
Graphics Card(s)
NVIDIA GeForce GT 540M (1024 MB)
Monitor(s) Displays
15.6
Screen Resolution
1920-1080
Hard Drives
ST9750420AS (698 GB, IDE)

C: (NTFS) 293.0 GB (229.9 GB free)
D: (NTFS) 380.6 GB (380.5 GB free)
Total Size 673.6 GB (610.4 GB free)
Keyboard
Standard
Mouse
Optical
Internet Speed
D-12877kbps U-370kbps
Hi barbarossa2241,

You're welcome.
 

My Computer My Computer

Computer Manufacturer/Model Number
Asus
OS
Windows 7 x64 Ultimate SP1
CPU
I5 875K Unlocked
Motherboard
P7P55D-E-PRO
Memory
Kingston HyperX Genesis DDR3-1600MHz 9-9-9-27 @ 1.65V XMP
Graphics Card(s)
EVGA GeForce GTX 570 HD 732 MHz GPU 1280 MB, 152 GB Mem
Sound Card
Onboard Via 1828S
Monitor(s) Displays
Samsung T240 HD
Screen Resolution
Dual 1920X1200 1027X768
Hard Drives
OCZ Vertex II Extended Sandforce SSD 60 Gig 2X WD Black Caviar 1 terabyte 6GBS Transer Sata 3 Marvell Chip
PSU
Corsair Gold fully Modular 80 Plus 850
Case
Coolermaster Half X Full Tower
Cooling
Noctua NH-U12P
Keyboard
MS
Mouse
MS
Internet Speed
Fast enough
Other Info
My fridge has a water tap
Nice Gift Thanks
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
custom build
OS
win7 Ultimate 64
CPU
icore5
Motherboard
Gigabyte P67
Memory
4 Gig
Graphics Card(s)
ATI Radeon HD5700
Sound Card
envy24
Monitor(s) Displays
Samsung SyncMaster T22HD/HP F1905
Screen Resolution
1680x1050
Hard Drives
Samsung
WDC
PSU
650
Case
GMC
Cooling
corsair
Keyboard
Dell
Mouse
MS3000
Internet Speed
slow
Antivirus
Microsoft
Browser
IE
Hi Korea7 ,

You're welcome.
 

My Computer My Computer

Computer Manufacturer/Model Number
Asus
OS
Windows 7 x64 Ultimate SP1
CPU
I5 875K Unlocked
Motherboard
P7P55D-E-PRO
Memory
Kingston HyperX Genesis DDR3-1600MHz 9-9-9-27 @ 1.65V XMP
Graphics Card(s)
EVGA GeForce GTX 570 HD 732 MHz GPU 1280 MB, 152 GB Mem
Sound Card
Onboard Via 1828S
Monitor(s) Displays
Samsung T240 HD
Screen Resolution
Dual 1920X1200 1027X768
Hard Drives
OCZ Vertex II Extended Sandforce SSD 60 Gig 2X WD Black Caviar 1 terabyte 6GBS Transer Sata 3 Marvell Chip
PSU
Corsair Gold fully Modular 80 Plus 850
Case
Coolermaster Half X Full Tower
Cooling
Noctua NH-U12P
Keyboard
MS
Mouse
MS
Internet Speed
Fast enough
Other Info
My fridge has a water tap
I had so many errors and warning - this cleared them out...thanks a billion. Looking forward to browsing these forums for more info in the future!
 

My Computer My Computer

Computer Manufacturer/Model Number
Asus G73 ROG Laptop
OS
Windows 7 Home Premium 64 bit
CPU
i7
Memory
8bg
Graphics Card(s)
Ati Radeon Mobility 5870
Hi Blappy and welcome to the forums.

We're all here to help each other.

:geek:
 

My Computer My Computer

Computer Manufacturer/Model Number
Asus
OS
Windows 7 x64 Ultimate SP1
CPU
I5 875K Unlocked
Motherboard
P7P55D-E-PRO
Memory
Kingston HyperX Genesis DDR3-1600MHz 9-9-9-27 @ 1.65V XMP
Graphics Card(s)
EVGA GeForce GTX 570 HD 732 MHz GPU 1280 MB, 152 GB Mem
Sound Card
Onboard Via 1828S
Monitor(s) Displays
Samsung T240 HD
Screen Resolution
Dual 1920X1200 1027X768
Hard Drives
OCZ Vertex II Extended Sandforce SSD 60 Gig 2X WD Black Caviar 1 terabyte 6GBS Transer Sata 3 Marvell Chip
PSU
Corsair Gold fully Modular 80 Plus 850
Case
Coolermaster Half X Full Tower
Cooling
Noctua NH-U12P
Keyboard
MS
Mouse
MS
Internet Speed
Fast enough
Other Info
My fridge has a water tap
This still works fine in Win 8 CP just FYI.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Airbot 2.0
OS
Windows 7 Ultimate x64 SP1
CPU
Core i7 920 (D0) @ 4Ghz, *26c idle *65c full load on air
Motherboard
Asus P6X58D Premium - Sata 6Gb/s - USB 3.0
Memory
12GB DDR3 Corsair Dominator -CMD12GX3M6A1600C8 at 1600MHz
Graphics Card(s)
Zotac Geforce GTX 770
Sound Card
ASUS Xonar D2X
Monitor(s) Displays
1 LG 24" Flatron W2453V-PF 1 Samsung 24" P2450H both 2ms RT
Screen Resolution
1920x1080@60hz
Hard Drives
1 Samsung 250GB 840 Evo SSD
1 OCZ Vertex2 180GB SSD
1 TB Samsung Spinpoint F1 7200RPM 32MB cache
2 500GB WD Caviar Blacks 7200RPM 32MB cache (WD5001AALS)

Pioneer DVD Burner DVR-S18M
PSU
Corsair HX1000W
Case
Cooler Master HAF 932
Cooling
Case Fans *3 230mm, *1 140mm/CPU - *Tuniq Tower 120 Extreme
Keyboard
Logitech Wireless MK700
Mouse
Logitech Wireless MK700
Internet Speed
DL 15 Mbps UL 0.98 Mbps
Antivirus
None
Browser
Firefox Nightly
Other Info
Processor-7.7 *RAM- 7.9 *Graphics-7.9 *Gaming Graphics- 7.9 *SSD- 7.8 W.E.I final score= 7.7
*Phone- LG Nexus 5

My Computer My Computer

Computer Manufacturer/Model Number
Asus
OS
Windows 7 x64 Ultimate SP1
CPU
I5 875K Unlocked
Motherboard
P7P55D-E-PRO
Memory
Kingston HyperX Genesis DDR3-1600MHz 9-9-9-27 @ 1.65V XMP
Graphics Card(s)
EVGA GeForce GTX 570 HD 732 MHz GPU 1280 MB, 152 GB Mem
Sound Card
Onboard Via 1828S
Monitor(s) Displays
Samsung T240 HD
Screen Resolution
Dual 1920X1200 1027X768
Hard Drives
OCZ Vertex II Extended Sandforce SSD 60 Gig 2X WD Black Caviar 1 terabyte 6GBS Transer Sata 3 Marvell Chip
PSU
Corsair Gold fully Modular 80 Plus 850
Case
Coolermaster Half X Full Tower
Cooling
Noctua NH-U12P
Keyboard
MS
Mouse
MS
Internet Speed
Fast enough
Other Info
My fridge has a water tap
Awesome!!

Zardoc,

Thanks for posting this very useful batch file.
 

My Computer My Computer

OS
Windows 7 Home Premium 64 bit, Windows 7 Professional 64 bit
Hi Redstar,

Welcome to the forums.

You're welcome
 

My Computer My Computer

Computer Manufacturer/Model Number
Asus
OS
Windows 7 x64 Ultimate SP1
CPU
I5 875K Unlocked
Motherboard
P7P55D-E-PRO
Memory
Kingston HyperX Genesis DDR3-1600MHz 9-9-9-27 @ 1.65V XMP
Graphics Card(s)
EVGA GeForce GTX 570 HD 732 MHz GPU 1280 MB, 152 GB Mem
Sound Card
Onboard Via 1828S
Monitor(s) Displays
Samsung T240 HD
Screen Resolution
Dual 1920X1200 1027X768
Hard Drives
OCZ Vertex II Extended Sandforce SSD 60 Gig 2X WD Black Caviar 1 terabyte 6GBS Transer Sata 3 Marvell Chip
PSU
Corsair Gold fully Modular 80 Plus 850
Case
Coolermaster Half X Full Tower
Cooling
Noctua NH-U12P
Keyboard
MS
Mouse
MS
Internet Speed
Fast enough
Other Info
My fridge has a water tap
Here's my take on the script.

Code:
@echo off
cls
title Eventing Command Line Utility: Cleanup Script
goto :question

:question
echo.
echo EMPTY ALL WINDOWS AND PROGRAM EVENT LOGS?
echo.
set /p ANSWER=(YES/NO): 
if /i {"%ANSWER%"}=={"y"}   (goto :start)
if /i {"%ANSWER%"}=={"yes"} (goto :start)
if /i {"%ANSWER%"}=={"n"}   (goto :cancel)
if /i {"%ANSWER%"}=={"no"}  (goto :cancel)
goto :input_error

:input_error
cls
echo.
echo          *ERROR: Invalid Option
echo _________________________________________
goto :question

:start
for /f "tokens=*" %%G in ('wevtutil.exe el') do (call :clear "%%G")
goto :finish

:clear
echo Emptying %1
wevtutil.exe cl %1
goto :eof

:finish
cls
echo.
wevtutil.exe cl System
echo.
echo DONE. Press any key to exit.
pause>nul
goto :end

:cancel
cls
echo.
REM USER CANCELED, Quiting Silently...
goto :end

:end
title Command Prompt
cls
@echo on
goto :eof

:eof
 
Last edited:

My Computer My Computer

OS
Windows 7 Professional x64 SP1
Very nice indeed! Thank ya :)
 

My Computer My Computer

Computer Manufacturer/Model Number
Acer 7551
OS
Windows 7 Professional 64bit
CPU
AMD Phenom X4 N970 2.2 GHz
Motherboard
AMD
Memory
4 GB DDR3 Upgrade Available
Graphics Card(s)
AMD ATI Mobility Radeon HD 4250 1919 MB Hyper Memory
Sound Card
Realtek High Definition Audio Bus
Monitor(s) Displays
17.3 HD+ LED, LCD
Screen Resolution
1600x900
Hard Drives
Model WDC WD50 00BEVT-22A0RT0 SATA Disk Device
Keyboard
Standard PS/2 Keyboard
Mouse
PS/2 Compatible Mouse
Lovely thanks!!
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Me :D
OS
Windows 7
CPU
AMD X6 1090T 4.02Ghz
Motherboard
ASUS Crosshair IV Formula
Memory
16.00GB
Graphics Card(s)
Nvidia Geforce 470
Sound Card
ASUS Xonar DX
Monitor(s) Displays
Dell 24" Monitor
Hard Drives
2TB WD
1TB WD
2TB WD
60 SSD
60 SSD
PSU
700W Crosshair
Case
Antec Three hundred
Cooling
Water Cooling
Gerard48

Gentlemen: First of all: Many thanks for this script to clean up win7! As we say here in the Netherlands: It went like a spear. I searched all internet for a script like this, well, it sounds familiar to you I think. I have a question: Our daily computer is win7, but is there also a script to clean up win xp home edition? Because I purchased a beautiful Acer 9800, you know, that 21" laptop that can`t be used on the lap because its weight of about 18 pound :D, but with a very nice screen for my technical works and drawings. A friend of mine put winxp on it, so that`s why I would like a script to clean it up sometimes. Well, wishing all of you all the best, Gerard, The Netherlands.
 

My Computer My Computer

OS
win 7 64 bit
That bat file is magical. cleaned all my event logs. I had been searching for days how to clear that custom administrative logs dating back to 2-3 year old entries on my pc. This script did that.

thanks.
--
Rawat
India
 

My Computer My Computer

Computer Manufacturer/Model Number
assembled locally.
OS
Windows 7 Ultimate x86/x64 dual boot
CPU
Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz
Motherboard
ASUSTeK Computer INC. Model P5G-MX
Memory
2GB DDR2
Graphics Card(s)
Intel 82945G Express Chipset Family v 8.15.10.1930
Sound Card
Realtek High Definition Audio 2.65 v6..0.1.6449
Monitor(s) Displays
LG Flatron W1943S
Screen Resolution
1360*760
Hard Drives
Seagate SATA 250 GB, Seagate IDE 40 GB
PSU
beetel ATX
Case
Intex
Cooling
?
Keyboard
zebronics K06 non-multimedia
Mouse
zebronics M05
Internet Speed
3.1 Mbps reliance broadband+ (it crowls mostly)
Back
Top