Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing Event Logs

Status
Not open for further replies.

irkey

MIS
Sep 23, 2002
14
0
0
CA
Can anyone tell me how to clear all the event logs on a W2K machine?

I found the following script, but it doesn't clear the Security log. Help!

set LogFileSet1 = GetObject("winmgmts:{impersonationLevel=impersonate,(Backup)}").ExecQuery("select * from Win32_NTEventLogFile where LogfileName='Application'")

For each Logfile in LogFileSet1
RetVal = LogFile.ClearEventlog()
if RetVal = 0 then WScript.Echo "The Application Log Has Been Cleared"
Next

set LogFileSet2 = GetObject("winmgmts:{impersonationLevel=impersonate,(Backup)}").ExecQuery("select * from Win32_NTEventLogFile where LogfileName='System'")

For each Logfile in LogFileSet2
RetVal = LogFile.ClearEventlog()
if RetVal = 0 then WScript.Echo "The System Log Has Been Cleared"
Next

set LogFileSet3 = GetObject("winmgmts:{impersonationLevel=impersonate,(Backup)}").ExecQuery("select * from Win32_NTEventLogFile where LogfileName='Security'")

For each Logfile in LogFileSet3
RetVal = LogFile.ClearEventlog()
if RetVal = 0 then WScript.Echo "The Security Log Has Been Cleared"
Next
 
You need to add , Security after Backup as shown below

set LogFileSet3 = GetObject("winmgmts:{impersonationLevel=impersonate,(Backup, Security)}").ExecQuery("select * from Win32_NTEventLogFile where LogfileName='Security'")


Regards
Steve Friday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top