GFI
English Deutsch Français Italiano Nederlands Español
Products > GFI Network Server Monitor > Scripting > WMI > Samples > Asynchronous WMI calls

Asynchronous WMI operations


Asynchronous WMI operations
Dim bDone, numEventsInspected
Dim strComputer

Do
strComputer = inputbox( "Please enter computername (or . for local host)", "Input" )
Loop until strComputer <> ""
CheckEventLog strComputer, "System"

Function CheckEventLog( strComputer, strLogFile )
    Dim objWMIService, objSink

    bDone             = False
    numEventsInspected = 0

    Set objWMIService = GetObject ("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objSink = CreateObject ("WbemScripting.SWbemSink","SINK_")
    objWMIService.ExecQueryAsync objSink,"Select * from Win32_NTLogEvent where LogFile='" & strLogFile & "'"
    While Not bDone
        WScript.Sleep 1000
    Wend
End Function


' Sub sink_onCompleted used by CheckEventLog
Sub sink_onCompleted( HResult,oErr,oCtx )
    bDone=True
End Sub

' Sub sink_onObjectReady used by CheckEventLog
Sub sink_onObjectReady( e, octx )
    WScript.Echo e.SourceName
    numEventsInspected = numEventsInspected + 1
End Sub


   © 2008. All rights reserved. GFI Software Home Products Download trials Support Ordering Site map About us Contact us
GFI solutions: Exchange anti spam filter - exchange anti virus - isa server - network vulnerability scanner - event log management - USB security software - exchange archiving - fax server software