SWbemServices.DeleteAsync method

The DeleteAsync method of the SWbemServices object deletes the class or instance specified in the object path. The call to DeleteAsync returns immediately and the results and status are returned to the caller through events delivered to the sink that is specified in objWbemSink. For more information about creating a sink, see Receiving a WMI Event. You can only delete objects in the namespace to which you are connected.

If a dynamic provider supplies the class or instance, sometimes it is not possible to delete this object unless the provider supports class or instance deletion.

The method is called in the asynchronous mode. For more information, see Calling a Method.

For an explanation of this syntax, see Document Conventions for the Scripting API.

Syntax

SWbemServices.DeleteAsync( _
  [ ByVal ObjWbemSink ], _
  ByVal strObjectPath, _
  [ ByVal iFlags ], _
  [ ByVal objWbemNamedValueSet ], _
  [ ByVal objWbemAsyncContext ] _
)

Parameters

ObjWbemSink [optional]

Object sink that receives the results of the deletion. Create an SWbemSink object to receive the objects.

strObjectPath

Required. String that contains the object path to the object that you want to delete. For more information, see Describing the Location of a WMI Object.

iFlags [optional]

Determines if status updates are returned. This parameter can accept the following values.

wbemFlagSendStatus (128 (0x80))

Causes asynchronous calls to send status updates to the OnProgress event handler for the object sink.

wbemFlagDontSendStatus (0 (0x0))

Prevents asynchronous calls from sending status updates to the OnProgress event handler for the object sink.

objWbemNamedValueSet [optional]

Typically, this is undefined. Otherwise, this is an SWbemNamedValueSet object whose elements represent the context information that can be used by the provider that is servicing the request. A provider that supports or requires such information must document the recognized value names, data type of the value, allowed values, and semantics.

objWbemAsyncContext [optional]

An SWbemNamedValueSet object that returns to the object sink to identify the source of the original asynchronous call. Use this parameter if you are making multiple asynchronous calls using the same object sink. To use this parameter, create an SWbemNamedValueSet object and use the SWbemNamedValueSet.Add method to add a value that identifies the asynchronous call you are making. This SWbemNamedValueSet object is returned to the object sink and the source of the call can be extracted using the SWbemNamedValueSet.Item method. For more information, see Calling a Method.

Return value

This method does not return a value. If the call is successful, the object sink receives notification of the deletion.

Error codes

After the completion of the DeleteAsync method, the Err object may contain one of the error codes in the following list.

wbemErrFailed - 2147749889 (0x80041001)

Unspecified error.

wbemErrInvalidParameter - 2147749896 (0x80041008)

Invalid parameter was specified.

wbemErrOutOfMemory - 2147749894 (0x80041006)

Not enough memory to complete the operation.

wbemErrTransportFailure - 2147749909 (0x80041015)

Networking error occurred, preventing normal operation.

wbemErrAccessDenied - 2147749891 (0x80041003)

Current or specified user name and password are not valid or authorized to make the connection.

wbemErrNotFound - 2147749890 (0x80041002)

Requested item was not found.

Remarks

This call returns immediately. The status of the delete operation is returned to the caller through a callback delivered to the sink that is specified in objWbemSink. You can perform final processing in your implementation of the objWbemSink.OnCompleted event.

An asynchronous callback allows a non-authenticated user to provide data to the sink. This poses security risks to your scripts and applications. To eliminate the risks, see Setting Security on an Asynchronous Call.

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
Wbemdisp.h
Type library
Wbemdisp.tlb
DLL
Wbemdisp.dll
CLSID
CLSID_SWbemServices
IID
IID_ISWbemServices

See also

SWbemServices

SWbemObjectPath