In Microsoft System Center Configuration Manager 2007, when an error occurs in an asynchronous call, the error object is passed as the second parameter to the OnCompleted method. Inside your OnCompleted implementation, you check the error object the same as you would for a synchronous call.
You determine if there is an error by checking the HResult parameter of the OnCompleted method.
This VBScript sample displays error information if
there is a error during an asynchronous operation. To use this
code, replace the sink_OnCompleted method in How to Perform an
Asynchronous Configuration Manager Query by Using WMI. To test,
change the query to an invalid query such as
Select * From
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
|Visual Basic Script||Copy Code|
Sub sink_OnCompleted(HResult, oErr, oCtx) WScript.Echo "All collections returned" if HResult <> 0 Then ' Determine the type of error. If oErr.Path_.Class = "__ExtendedStatus" Then WScript.Echo "WMI Error: "& oErr.Description ElseIf ExtendedStatus.Path_.Class = "SMS_ExtendedStatus" Then WScript.Echo "Provider Error: "& oErr.Description WScript.Echo "Code: " & oErr.ErrorCode End If End If bdone = true End sub
Using script to pass the user name and password is a security risk and should be avoided where possible.
Send comments about this topic to Microsoft.