IWbemServices::ExecMethod method (wbemcli.h)

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

[in] strObjectPath

Valid BSTR containing the object path of the object for which the method is executed.

[in] strMethodName

Name of the method for the object.

[in] lFlags

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.

[in] pCtx

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.

[in] pInParams

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++.

[out] ppOutParams

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.

[out] ppCallResult

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 list 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.

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.

Requirements

Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header wbemcli.h (include Wbemidl.h)
Library Wbemuuid.lib
DLL Fastprox.dll; Esscli.dll; FrameDyn.dll; FrameDynOS.dll; Ntevt.dll; Stdprov.dll; Viewprov.dll; Wbemcomn.dll; Wbemcore.dll; Wbemess.dll; Wbemsvc.dll; Wmipicmp.dll; Wmidcprv.dll; Wmipjobj.dll; Wmiprvsd.dll

See also

Calling a Method

IWbemCallResult::GetResultObject

IWbemServices

IWbemServices::ExecMethodAsync