Name
RegisterVM
Description
HRESULT
RegisterVM([in] BSTR vmxFilePath,
[in] ICallback* jobDoneCallback,
[out,retval] IJob** registerJob);
This
method
adds a virtual machine to the host's inventory.
Parameters
- vmxFilePath
-
The path name of the .vmx file on the host.
- jobDoneCallback
-
An ICallback instance that will be called when the
operation is complete.
- registerJob
-
Returns an IJob object that describes the state of this
asynchronous operation.
Return Value
HRESULT
Remarks
- This
method
registers the virtual machine identified by vmxFilePathName, which is
a storage path to the configuration file (.vmx) for that virtual machine.
You can register a virtual machine regardless of its power state.
- The format of the path name 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 register an already-registered virtual machine,
although the VMware Server UI shows an error icon in the Task pane.
Trying to register a non-existent virtual machine results in error 2000,
VIX_E_NOT_FOUND.
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.RegisterVM("[standard] Windows XP\Windows XP.vmx", Nothing)
err = job.WaitWithoutResults()
If lib.ErrorIndicatesFailure(err) Then
' Handle the error...
End If