Name
UnregisterVM
Description
HRESULT
UnregisterVM([in] BSTR vmxFilePath,
[in] ICallback* jobDoneCallback,
[out,retval] IJob** unregisterJob);
This
method
removes a virtual machine from the host's inventory.
Parameters
- vmxFilePath
-
The storage path of the .vmx file on the host.
- jobDoneCallback
-
An ICallback instance that will be called when the
operation is complete.
- unregisterJob
-
Returns an IJob object that describes the state of this
asynchronous operation.
Return Value
HRESULT
Remarks
- This
method
unregisters the virtual machine identified by vmxFilePathName, which is
a storage path to the configuration file (.vmx) for that virtual machine.
A virtual machine must be powered off to unregister it.
- The format of the storage path depends on the host operating system.
Path to storage [standard] or [storage1] may vary.
- For VMware Server 1.x, supply the full path name instead of storage path,
and specify VIX_SERVICEPROVIDER_VMWARE_SERVER to connect.
- This
method
does not apply to Workstation, which has no virtual machine inventory.
- This method is asynchronous. Completion is reported by a IJob object.
- It is not a Vix error to unregister an already-unregistered virtual machine,
nor is it a Vix error to unregister a non-existent virtual machine.
Side Effects
None.
Requirements
VixCOM.h, since VMware Workstation 6.0.
Example
VBScript:
Dim lib
Dim err
Dim job
Dim host
Dim results
Set lib = CreateObject("VixCOM.VixLib")
Set results = Nothing
Set job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_VI_SERVER, "https://viserver/sdk", 0, "Admnistrator", "administratorpasswd", 0, Nothing, Nothing)
err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), results)
If lib.ErrorIndicatesFailure(err) Then
' Handle the error...
End If
Set host = results(0)
Set job = host.UnregisterVM("[standard] Windows XP\Windows XP.vmx", Nothing)
err = job.WaitWithoutResults()
If lib.ErrorIndicatesFailure(err) Then
' Handle the error...
End If