Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Event Viewer One Click Clear


19 Sep 2009   #59
Zardoc

Windows 7 x64 Ultimate SP1
 
 
Event Viewer One Click Clear

How to Clear Event Viewer with One Click in Windows


...


My System SpecsSystem Spec
15 Nov 2012   #60
vsrawat

Windows 7 Ultimate x86/x64 dual boot
 
 

Have used the useful script many times.

There are 5 types of Events - Critical/ Error/ Warning/ Information/ Audit Success

Any method that we can retain, say, Critical and, maybe, Error, that are crucial for diagnosing problems in future, and can delete rest of the types that are informative?

How can we just stop Audit success type of events from getting recorded in event logs?

Thanks.
--


My System SpecsSystem Spec
12 Dec 2012   #61
Mirfster

Windows 7 Professional x64
 
 
VBS Version

First of all, thanks for the great batch files. Just wanted to add a VBS version that I created to do the same in case anyone was interested in it.

Please note, this does not have any checking for Admin rights, but that is since I usually have these running via a Software Delivery System (MDT, SCCM, etc) or are part of my MDT Applications.


Code:
On Error Resume Next

'Define and configure objects
Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec("%ComSpec% /C WEvtUtil.exe EL")
WshShellExecOutPut = WshShellExec.StdOut.ReadAll

'Read each line and clear the event logs 
For Each EventLog in Split (WshShellExecOutPut, VBNewLine)
    WScript.Echo "Clearing: " & EventLog
    WshShell.Run "WEvtUtil.exe CL " & EventLog, 0, TRUE
Next
My System SpecsSystem Spec
12 Dec 2012   #62
Brink
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 

Hello Mirfster, and welcome to Seven Forums.

No problem. Here's your .vbs with a UAC prompt for elevation added to it.

Code:
'UAC prompt for elevation
If WScript.Arguments.Count = 0 Then
     Set objShell = CreateObject("Shell.Application")
     objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " Run", , "runas", 1
Else
 
On Error Resume Next
 
'Define and configure objects
Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec("%ComSpec% /C WEvtUtil.exe EL")
WshShellExecOutPut = WshShellExec.StdOut.ReadAll
 
'Read each line and clear the event logs 
For Each EventLog in Split (WshShellExecOutPut, VBNewLine)
    WScript.Echo "Clearing: " & EventLog
    WshShell.Run "WEvtUtil.exe CL " & EventLog, 0, TRUE
Next
 
End If
My System SpecsSystem Spec
12 Dec 2012   #63
Mirfster

Windows 7 Professional x64
 
 

Thanks Brink, that is a nice addition.
My System SpecsSystem Spec
.


12 Dec 2012   #64
Brink
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 

You're welcome.

I'd recommend to remove the line below to not have to click on OK for each log cleared. Only a few million of them.

Code:
WScript.Echo "Clearing: " & EventLog

Maybe this instead:

Code:
'UAC prompt for elevation
If WScript.Arguments.Count = 0 Then
     Set objShell = CreateObject("Shell.Application")
     objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " Run", , "runas", 1
Else
 
On Error Resume Next

'Define and configure objects
Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec("%ComSpec% /C WEvtUtil.exe EL")
WshShellExecOutPut = WshShellExec.StdOut.ReadAll

'Read each line and clear the event logs 
For Each EventLog in Split (WshShellExecOutPut, VBNewLine)
        WshShell.Run "WEvtUtil.exe CL " & EventLog, 0, TRUE
Next
 
End If
 
MsgBox "Event Viewer logs have been successfully cleared."
My System SpecsSystem Spec
12 Dec 2012   #65
Mirfster

Windows 7 Professional x64
 
 

Actually, I just left that in there so that when it is being ran via "CScript.exe" it shows progress. The code I provided is actually a snippet from my VBS that I use to prepare my base image.

I see what you mean though if it were to be launched via "WScript.exe".
My System SpecsSystem Spec
28 May 2013   #66
Rockit

Windows 7 Premium 64 Bit
 
 

Hi Everyone,

Has a final and best version been decided?

Thank You
My System SpecsSystem Spec
28 May 2013   #67
Brink
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 

Hello Rockit,

Either option in the tutorial does the same thing. It's just a matter of which one you would like to use.
My System SpecsSystem Spec
09 Feb 2014   #68
Captain Zero

Windows 7 Home Premium x64
 
 

Just the thing I was looking for, thanks!
My System SpecsSystem Spec
15 Mar 2014   #69
m4paws

Windows 7 Ultimate x64
 
 

Great tool, thanks very much. I've become a bit OCD about no errors on boot up, so this really comes in handy
My System SpecsSystem Spec
Comment

 Event Viewer One Click Clear




Tutorial Tools



Similar help and support threads for2: Event Viewer One Click Clear
Windows 7 Tutorial Category
In Event Viewer, Where is event log for cleanmgr.exe (Disk Cleanup)? Performance & Maintenance
Solved Event Viewer Warning - Source e1yexpress - Event ID 27 General Discussion
How To Clear Administrative Events Log - Event Viewer Performance & Maintenance
WHEA-Logger event 18/19 errors in Event Viewer (W7 Home Premium) Hardware & Devices
Event Viewer Error Message Event ID11 - How do I get rid of this to? BSOD Help and Support
Event 18 WHEA-Logger Error in Event Viewer Hardware & Devices
How to clear events in viewer? General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 03:12 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33