We can use the below wmi script for clearing specific type of eventlogs from a windows computer,
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup, Security)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile " _
& "Where LogFileName='Application'")
For Each objLogfile in colLogFiles
objLogFile.ClearEventLog()
WScript.Echo "Cleared all event log file"
Next
In the above script we are going to clear all the windows application eventlogs(marked in red),
In order to execute the above command the administrator can save the script with extension .vbs
and execute as shown below,
directory_path>cscript script_file_name.vbs
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup, Security)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile " _
& "Where LogFileName='Application'")
For Each objLogfile in colLogFiles
objLogFile.ClearEventLog()
WScript.Echo "Cleared all event log file"
Next
In the above script we are going to clear all the windows application eventlogs(marked in red),
In order to execute the above command the administrator can save the script with extension .vbs
and execute as shown below,
directory_path>cscript script_file_name.vbs
Comments
Post a Comment