I'm using VIX API 1.6.2 on 32 bit Windows 2003 (SP2) to control vitrual machines running on another 64-bit machine running ESXi 4.0.0 (171294).
The Virtual machine is running 32-bit Windows 2003 (SP2) and has VMWare tools installed.
Using the VIX API I first revert to a named snapshot (that has the machine in shutdown state), then I power it on and wait for tools in guest before I run programs inside the VM.
The problem is that WaitForToolsInGuest ( ) does not return and hangs indefinately even after the OS has booted up successfully.
The code below works fine for ESX 3.5 (update 3) and also VMWare Server 2.0.1 but does not work forESXi 4.0.0 (171294)
My VBScript code that uses VIX API looks like this:
' Create the VIX library
Dim lib
Set lib = CreateObject("VixCOM.VixLib")
' Connect to ESXi server
Dim jobConnect
Set jobConnect = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_VI_SERVER, "https://myesxiserver:443/sdk/", 0, "root", "mypwd", 0, Nothing, Nothing)
Set connectResults = Nothing
err = jobConnect.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), connectResults)
If lib.ErrorIndicatesFailure(err) Then
Wscript.Echo "Connecting to host failed with error code "
WScript.Quit(err)
End If
Dim host
Set host = connectResults(0)
' Open the virtual machine
Set jobOpenVM = host.OpenVM("[datastore] myvm/myvm.vmx", Nothing)
Set openVMResults = Nothing
err = jobOpenVM.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), openVMResults)
If lib.ErrorIndicatesFailure(err) Then
WScript.Echo "Opening virtual machine failed with error code "
WScript.Quit(err)
End If
' The vm object will be first element in the results array.
Dim vm
Set vm = openVMResults(0)
' Power on the virtual machine
Dim jobPowerOn
Set jobPowerOn = vm.PowerOn(VixCOM.Constants.VIX_VMPOWEROP_NORMAL, Nothing, Nothing)
err = jobPowerOn.WaitWithoutResults()
If lib.ErrorIndicatesFailure(err) Then
WScript.Echo "Powering on guest failed with error code "
WScript.Quit(err)
End If
' Wait until VMWare tools starts inside the guest
Dim jobWaitForTools
Set jobWaitForTools = vm.WaitForToolsInGuest(0, Nothing)
err = jobWaitForTools.WaitWithoutResults()
If lib.ErrorIndicatesFailure(err) Then
WScript.Echo "Waiting for tools in guest failed with error code "
WScript.Quit(err)
End If
Thanks in advance.