Name
PowerOn
Description
HRESULT
PowerOn([in] LONG powerOnOptions,
[in] IVixHandle* propertyList,
[in] ICallback* jobDoneCallback,
[out,retval] IJob** powerJob);
Powers on a virtual machine.
Parameters
- powerOnOptions
-
VixCOM.Constants.VIX_VMPOWEROP_NORMAL or
VixCOM.Constants.VIX_VMPOWEROP_LAUNCH_GUI.
- propertyListHandle
-
Must be NULL (C++), null (C#), or Nothing (VB).
- jobDoneCallback
-
An ICallback instance that will be called when the
operation is complete.
- powerJob
-
Returns an IJob object that describes the state of this
asynchronous operation.
Return Value
HRESULT
Remarks
- This function powers on a virtual machine.
It is an asynchronous operation,
and the IJob object will be signalled when the operation completes.
- This operation completes when the virtual machine has started to boot.
If the VMware Tools have been installed on this guest operating system,
you can call VM::WaitForToolsInGuest() to determine when the guest has finished booting.
- In Server 1.0, when you power on a virtual machine, the virtual machine is powered on
independent of a console window. If a console window is open, it remains open.
Otherwise, the virtual machine is powered on without a console window.
- To display a virtual machine with a Workstation user interface,
powerOnOptions must have the VixCOM.Constants.VIX_VMPOWEROP_LAUNCH_GUI flag. If there is
an existing instance of the Workstation user interface, the virtual machine will
power on in a new tab within that instance. Otherwise, a new instance of
Workstation will open, and the virtual machine will power on there.
- This function can also be used to resume execution of a suspended virtual
machine.
Side Effects
None.
Requirements
VixCOM.h, since VMware Workstation 6.0
Example
VBScript:
Dim lib
Dim host
Dim vm
Dim err
Dim results
Dim job
Set lib = CreateObject("VixCOM.VixLib")
Set job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION, Empty, 0, Empty, Empty, 0, Nothing, Nothing)
' results needs to be initialized before it's used, even if it's just going to be overwritten.
Set results = 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.OpenVM("C:\VMs\winxppro\winxppro.vmx", Nothing)
err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), results)
If lib.ErrorIndicatesFailure(err) Then
' Handle the error...
End If
Set vm = results(0)
Set job = vm.PowerOn(VixCOM.Constants.VIX_VMPOWEROP_LAUNCH_GUI, Nothing, Nothing)
err = job.WaitWithoutResults()
If lib.ErrorIndicatesFailure(err) Then
' Handle the error...
End If