"SeanInSeattle" wrote:
[Quoted Text] > So, does anyone know how to get the collection / swbemobjectset from an > asynchronous call to WMI on-completed()...? And, also does anyone know how > to get the collection when its not fully done? > > It seems like it should be possible.... but I'm racking my brain trying to > find an answer. > >
Here is a sample:
Set objSWbemServices = GetObject _ ("winmgmts:\\.\root\cimv2")
Set objSink = WScript.CreateObject _ ("WbemScripting.SWbemSink","objSink_") objSWbemServices.ExecQueryAsync _ objSink, "Select * From CIM_DataFile " & _ "Where Path = '\\windows\\system32\\'"
MsgBox "Waiting for objects!"
Sub objSink_OnCompleted(iHRes, objWmiErr, objCntxt) WScript.Echo VbCrtLf & "Async call completed." End Sub
Sub objSink_OnObjectReady(objWmiObj, objCntxt) WScript.Echo objWmiObj.FileName End Sub
MsgBox prevents the script from ending. objSink_OnObjectReady receives CIM_DataFile instances asynchronously (as objWmiObj) and echoes their FileName property. When the call is completed objSink_OnCompleted is triggered. I'm not sure if it is possible to get the collection of WMI objects as a SWbemObjectSet object with an asynchronous call.
-- urkec
|