Search code examples
windowsvirtualbox

Executing an application with Vboxmanage guestcontrol does not display on guest


I want to use VirtualBox vboxmanage to launch an application on many Guest machine to perform tests.

In my case I have a Windows host and Windows guest machines.

Using vboxmanage does spawn the application process (in fact you can see it on Task Manager) but does not show the application on the Guest screen.

Seems like my application does not have a screen to display or does have a different one...

Is possible to display the application using vboxmanage? What am I missing?

Thanks

Example of a performed command:

"C:\Program Files\Oracle\Virtualbox\VBoxManage.exe" guestcontrol "Win64" --password pw --username admin run --exe c:\windows\system32\cmd.exe --putenv JAVA_PATH=c:\tests\jre -- cmd.exe/arg0 /C C:\tests\jre\bin\java.exe -jar c:\tests\sikulix -r c:\tests\test_app.sikuli

Solution

  • I managed to launch an application on Windows guest and to have the application show on the screen, so I will post here how to do if anyone needs something similar.

    After putting in place the virtual machine with only host network in order to be able to connect from Host to Guest, I used psexec to interact with guest as the follows:

    psexec.exe \\ipaddress -i 1 -u WORKGROUP\username -p password c:\path\to\my\application.exe -d
    

    Some notes about the command:

    • -i 1 is the options that allows to interact with the desktop of the specified session
    • -d could be used in order not to wait the process to terminate
    • WORKGROUP\username pay attention to specify the workgroup

    In order to automate operation on multiple virtual machines you can determine the ip address parsing the result of this command:

    "C:\Program Files\Oracle\Virtualbox\VBoxManage.exe" guestproperty enumerate vmname
    

    or you can parse the result of a systeminfo on guest like the following:

    "C:\Program Files\Oracle\Virtualbox\VBoxManage.exe" guestcontrol MyVMname run --username myusername --password my-password --wait-stdout --wait-stderr --exe "C:\Windows\System32\cmd.exe" -- cmd.exe/arg0 /C systeminfo