Trying to connect to remote host running VMware server v1.04 running on Windows 2003 SP and job.Wait doesn't seem to return any values, there for Set host = results(0) throws a general VBScript mismatch error message during runtime. Using the same script against local installation of VMWare Workstation v6.03 works just fine. Any help on will be greatly appreciated. Below is VBScript.
Dim lib, job
Dim strUserName
Dim strPassword
Dim strHostName
Dim host
Dim vm
Dim results
Set lib = CreateObject("VixCOM.VixLib")
strHostName = "MyHostValue"
strUserName = "MyUserAccountValue"
+*strP
' Connect to host
Set job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER, strHostName, 902, strUserName, strPassword, 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)
'QuitIfError(err)
' The job result handle will be first element in the results array.
Set host = results(0)
' Open the virtual machine with the given .vmx file.
'Set job = host.OpenVM("D:\VM_Images\VMXP01EN\Windows XP Professional.vmx", Nothing) THis is for VMWare Server
Set job = host.OpenVM("V:\VmImages\eDWinXP\WindowsXPProfessional.vmx", Nothing)
err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), results)
'QuitIfError(err)
Set vm = results(0)
' Power on the virtual machine we just opened. This will launch Workstation if it hasn't
' already been started.
Set job = vm.PowerOn(VixCOM.Constants.VIX_VMPOWEROP_LAUNCH_GUI, Nothing, Nothing)
+' WaitWithoutResults is just like Wait, except it does not get any properties. +
err = job.WaitWithoutResults()
'QuitIfError(err)
Set vm = results(0)
err = vm.GetRootSnapshot(0, snapshot)
If lib.ErrorIndicatesFailure(err) Then
* ' Handle error...*
End If
Set job = vm.RevertToSnapshot(snapshot, 0, Nothing, Nothing)
err = job.WaitWithoutResults()
host.Disconnect()