Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

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 codeDescription
WBEM_E_FAILED

This indicates other unspecified errors.

WBEM_E_INVALID_CLASS

The specified class was not valid.

WBEM_E_INVALID_PARAMETER

A specified parameter is not valid.

WBEM_E_METHOD_DISABLED

An attempt was made to execute a method marked with [disabled].

WBEM_E_METHOD_NOT_IMPLEMENTED

An attempt was made to execute a method not marked with [implemented] in any relevant class.

WBEM_E_NOT_FOUND

The specified object path is not valid

WBEM_E_PROVIDER_NOT_CAPABLE

The provider does not support method calls.

WBEM_E_OUT_OF_MEMORY

There was not enough memory to complete the operation.

WBEM_E_SHUTTING_DOWN

Windows Management service was probably stopped and restarted. A new call to ConnectServer is needed.

WBEM_E_TRANSPORT_FAILURE

This indicates the failure of the remote procedure call (RPC) link between the current process and Windows Management.

WBEM_E_INVALID_METHOD

The requested method was not available.

WBEM_E_ACCESS_DENIED

The current user was not authorized to execute the method.

WBEM_E_INVALID_METHOD_PARAMETERS

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.

WBEM_S_NO_ERROR

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 XP

Minimum supported server

Windows Server 2003

Header

Wbemcli.h (include Wbemidl.h)

Library

Wbemuuid.lib

DLL

Fastprox.dll;
Esscli.dll;
Framedyn.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

IWbemServices
Calling a Method
IWbemCallResult::GetResultObject
IWbemServices::ExecMethodAsync

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.