run DOS script in Guest, not minimized

Feb 12, 2010 at 4:41 PM

I've been running a script in my VM using VMWareTasks call:

virtualMachine.RunProgramInGuest("blab.bat","a b c");

this correctly calls my script and runs in a command window in the Guest that is not minimized.  That is how I prefer it.    Recently I realized that there are legitimate circumstances where the script is not getting enough time to complete before the above line gets a 'timeout' error.

So, I changed the line to:

virtualMachine.RunProgramInGuest("blab.bat","a b c", 0, 600);

this corrects the situation to prevent the timeout, but now the script runs in a minimized cmd window in the guest.

  1. How do I change that behavior?

  2. How does my C# program get access to the constants like VIX_RUNPROGRAM_ACTIVATE_WINDOW shown in the VMWareTasks help file?  Via experimentation I determined that hard-coding a 0 in that third parameter accomplished the desired behavior.

 

Thanks

-bC

 

Coordinator
Feb 13, 2010 at 12:09 AM
Edited Feb 13, 2010 at 12:10 AM

So you figured it out almost :)

RunProgramInGuest is implemented like this:

        public Process RunProgramInGuest(string guestProgramName, string commandLineArgs)
        {
            return RunProgramInGuest(guestProgramName, commandLineArgs,
                Constants.VIX_RUNPROGRAM_ACTIVATE_WINDOW,
                VMWareInterop.Timeouts.RunProgramTimeout);
        }

I am not even sure why I am passing VIX_RUNPROGRAM_ACTIVATE_WINDOW here by default, but I am sure there was a good reason.

The constants come from Interop.VixCOM.Constants, you probably need an explicit reference to that and you can replace the 0 with whatever other parameter that RunProgramInGuest supports [doc]. The doc doesn't say anything about minimizing windows, I guess 0 means do that.