Dharmendra's Blog

Just another WordPress.com site

Tag Archives: WMI

WMI Tasks: Event Logs

Clear Event Logs:

Link: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394593%28v=vs.85%29.aspx

VB Script
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Backup)}!\\" & _
        strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile " _
    & "Where LogFileName='Application'")
For Each objLogfile in colLogFiles
    objLogFile.ClearEventLog()
    WScript.Echo "Cleared application event log file"
Next
Advertisements