VMware {code} Community
SoMoS
Contributor
Contributor

Call to RunProgramInGuest hangs without executing anything

Hello,

I'm automating several things on VMs located at a 3.5 ESX host and I've found that sometimes executing RunProgramInGuest just after rebooting the guest does not start the application nor returns error. If I call jobHandle.Wait() it just waits forever. The guest is a 2003 R2 Server, not sure if this matters.

Any hint?

PD: The code to execute the application is:

IJob jobHandle = _vmHandle.RunProgramInGuest(exePath,parameters, VixCOM.Constants.VIX_RUNPROGRAM_ACTIVATE_WINDOW, null, null);
int[] propertyIds = new int[] { VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_GUEST_PROGRAM_EXIT_CODE };
object results = new object();
ulong errorValue = jobHandle.Wait(propertyIds, ref results);
0 Kudos
2 Replies
admin
Immortal
Immortal

Are you calling WaitForToolsInGuest() after the reboot completes?

VIX's support for ESX 3.5 is only experimental; we've made numerous improvements in ESX since then, so you may find things work more reliably in 4.0 and 4.1.

My one guess is that the job returned when restarting the VM (I assume you are performing a soft reset) might be returning too soon. You could test by adding some code to determine the elapsed time between invoking the operation and when VixJob_Wait() returns.

If that is the case, you might have some luck adding something like a sleep for thirty seconds after the reboot before calling WaitForToolsInGuest(). Once that completes, you can try running the program.

0 Kudos
SoMoS
Contributor
Contributor

Yes, I'm calling WaitToolsInGuest() after rebooting. Mmmm, I really don't want to use time dependent code as I don't really know what's going on at the corporative VCenter, if there is a lot of load it could take  long to reboot, anyway, using time dependent code is not a good idea imho.

I've had to switch from 4.1 to 3.5 due to problems that i could solve with login returning VIX_E_INTERACTIVE_SESSION_NOT_PRESENT.

Sorry for my late answer but I thought that no one would answer the question so late.

0 Kudos