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
I found the following script, but it doesn't clear the Security log. Help!
set LogFileSet1 = GetObject("winmgmts:{impersonationLevel=impersonate,(Backup)}"
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)}"
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)}"
For each Logfile in LogFileSet3
RetVal = LogFile.ClearEventlog()
if RetVal = 0 then WScript.Echo "The Security Log Has Been Cleared"
Next