IWbemServices::ExecMethod method
The IWbemServices::ExecMethod method executes a method exported by a CIM object. The method call is forwarded to the appropriate provider where it executes. Information and status are returned to the caller, which blocks until the call is complete.
Methods are not directly implemented by Windows Management, but are exported by method providers. For any given CIM class, the available methods and their parameters must be specified in the documentation for the provider in question.
For more information about executing methods, see Calling a Method.
Syntax
HRESULT ExecMethod( [in] const BSTR strObjectPath, [in] const BSTR strMethodName, [in] long lFlags, [in] IWbemContext *pCtx, [in] IWbemClassObject *pInParams, [out] IWbemClassObject **ppOutParams, [out] IWbemCallResult **ppCallResult );
Parameters
- strObjectPath [in]
-
Valid BSTR containing the object path of the object for which the method is executed.
- strMethodName [in]
-
Name of the method for the object.
- lFlags [in]
-
This parameter can be set to 0 to make this a synchronous call. To make this a semisynchronous call, set lFlags to WBEM_FLAG_RETURN_IMMEDIATELY, provide a valid pointer for the ppCallResult parameter, and this call returns immediately. For more information, see Calling a Method.
- pCtx [in]
-
Typically NULL; otherwise, this is a pointer to an IWbemContext object that may be used by the provider executing the method. The values in the context object must be specified in the documentation for the provider in question. For more information about this parameter, see Making Calls to WMI.
- pInParams [in]
-
May be NULL if no in-parameters are required to execute the method. Otherwise, this points to an IWbemClassObject that contains the properties acting as inbound parameters for the method execution. The contents of the object are method-specific, and are part of the specification for the provider in question. For more information about constructing input parameters, see Creating Parameters Objects in C++.
- ppOutParams [out]
-
If not NULL, receives a pointer to the outbound parameters and return values for the method execution. The contents of this object are method-specific, and are part of the specification for the provider in question. The caller must call Release on the returned object when it is no longer required.
- ppCallResult [out]
-
If NULL, this is not used. If ppCallResult is specified, it must be set to point to NULL on entry. In this case, the call returns immediately with WBEM_S_NO_ERROR. The ppCallResult parameter receives a pointer to a new IWbemCallResult object, which must be polled to obtain the result of the method execution using the GetCallStatus method. The out parameters for the call are available by calling IWbemCallResult::GetResultObject.
Return value
This method returns an HRESULT indicating the status of the method call. The following table lists the value contained within an HRESULT.
On failure, you can obtain any available information from the COM function GetErrorInfo.
COM-specific error codes also may be returned if network problems cause you to lose the remote connection to Windows Management.
| Return code | Description |
|---|---|
|
This indicates other unspecified errors. |
|
The specified class was not valid. |
|
A specified parameter is not valid. |
|
An attempt was made to execute a method marked with [disabled]. |
|
An attempt was made to execute a method not marked with [implemented] in any relevant class. |
|
The specified object path is not valid |
|
The provider does not support method calls. |
|
There was not enough memory to complete the operation. |
|
Windows Management service was probably stopped and restarted. A new call to ConnectServer is needed. |
|
This indicates the failure of the remote procedure call (RPC) link between the current process and Windows Management. |
|
The requested method was not available. |
|
The current user was not authorized to execute the method. |
|
This error results from one of two causes: The supplied pInParams object was determined by the provider to be not valid. The strObjPath parameter specifies a class without the [static] qualifier on the method. |
|
The call succeeded. |
Remarks
If ppOutParams is not NULL, the client can determine the method's return value type by examining the ReturnValue property of the object pointed to by ppOutParams.
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
For C++ code examples, see WMI C++ Application Examples.
Requirements
|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 11/19/2012