Launch on host a user program installed on guest

This is for discussing general topics about how to use VirtualBox.
Post Reply
sebbobo
Posts: 6
Joined: 13. Nov 2023, 09:32

Launch on host a user program installed on guest

Post by sebbobo »

Hello,

On my notebook (Windows 11) I created a VM Windows XP x32 with VirtualBox 7.0. I installed in Windows XP the last version available of VirtualBox Guest Additions.

I try to create a shortcut on W11 desktop to launch user program installed on VM

Before create the shortcut i tried to launch a command with Command window on W11 without success (i tried different sentence found in different website without success…)

E.g : vboxmanage guestcontrol “Windows XP” run --exe “calc.exe” --wait-stdout --username “Name” --password “Pass”

Could you help me to find my mistake

Thank you
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Launch on host a user program installed on guest

Post by mpack »

I don't have time to consider your problem right now, but just to let you know... the old style Windows calculator (e.g. from the XP era) is available as a download that you can install on Windows 11 directly. No need for a VM to do that. I can't give you a download link, but try a search.
sebbobo
Posts: 6
Joined: 13. Nov 2023, 09:32

Re: Launch on host a user program installed on guest

Post by sebbobo »

Thank you but "Calc.exe" is just an example. I want to launch the special software (e.g Schneider PL7Pro 32 bits) on this VM

Best regards
Last edited by sebbobo on 15. Nov 2023, 13:44, edited 1 time in total.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Launch on host a user program installed on guest

Post by mpack »

Well your first post shows you already on the right lines: make sure the GAs are installed inside the VM (a VM log would allow us to verify that), then create a batch file to launch the VM and then launch your app. Detecting when the guest OS is ready to receive a launch command will be the tricky part.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Launch on host a user program installed on guest

Post by scottgus1 »

mpack wrote: 15. Nov 2023, 15:45 Detecting when the guest OS is ready to receive a launch command will be the tricky part.
This could be done with vboxmanage guestproperty get/set.

The host script that launches the VM could set a guestproperty on that VM, then go into a delayed loop waiting for the guest property to be reset. Once that happens, jump out of the loop and run the guestcontrol command.

Inside the VM OS with Guest Additions installed, a script set to auto-run when the VM has logged into its desktop could run a "vboxcontrol guestproperty set" which sets the guestproperty to the value the host script loop is looking for.

A bit of extra scripting is needed to check if the VM was already running, perhaps by making the guest script continually reset the guestproperty so the host script will always see the guestproperty indicate when the VM is running.

Regarding your command:
sebbobo wrote: 13. Nov 2023, 09:38 vboxmanage guestcontrol “Windows XP” run --exe “calc.exe” --wait-stdout --username “Name” --password “Pass”
Please see https://www.virtualbox.org/manual/ch08. ... estcontrol

The --wait-stdout may be a problem, but I haven't played with this much to know for certain. Some folks have reported that it depends on the app being launched whether the command worked or not. (Some Microsoft Office apps kicked up a fuss.)
sebbobo
Posts: 6
Joined: 13. Nov 2023, 09:32

Re: Launch on host a user program installed on guest

Post by sebbobo »

Hello,

I work again on this subject...
  1. Checking on log if GA's are correctly installed
    The log make few kilometers...how i have to see on log to be sure that the GA's are correctly installed ?

    Code: Select all

    00:01:03.248666 GUI: UISession::sltAdditionsChange: GA state really changed, notifying listeners
    00:01:03.248681 GUI: UIMachineViewNormal::adjustGuestScreenSize: Adjust guest-screen size if necessary
    00:01:03.248690 GUI: UISession::sltAdditionsChange: GA state change event came, notifying listeners
    00:01:03.248693 GUI: UIMachineLogicNormal::sltCheckForRequestedVisualStateType: Requested-state=1, Machine-state=6
    00:01:03.248803 VMMDev: Guest Log: Service 'VRDP' started
    00:01:03.248821 VMMDev: Guest Log: Starting service 'IPC' ...
    00:01:03.248896 VMMDev: Guest Log: VBoxIPCInit: Local IPC server now running at "\\.\pipe\VBoxTrayIPC-Maintenance"
    00:01:03.248997 VMMDev: Guest Log: Service 'IPC' started
    00:01:03.249010 VMMDev: Guest Log: Starting service 'LA' ...
    00:01:03.249028 VMMDev: Guest Log: LA: RegQueryValueExW: failed [SOFTWARE\Oracle\VirtualBox Guest Additions/VBoxTrayLog]
    00:01:03.249042 VMMDev: Guest Log: LA: RegQueryValueExW: failed [SOFTWARE\Oracle\VirtualBox Guest Additions/VBoxTrayLA]
    00:01:03.249054 VMMDev: Guest Log: LA: DetachOnDisconnect=true
    00:01:03.249280 VMMDev: Guest Log: Service 'LA' started
    00:01:03.249292 VMMDev: Guest Log: Starting service 'draganddrop' ...
    00:01:03.250226 VMMDev: Guest Log: DnD: Drag and drop service successfully started
    00:01:03.250292 VMMDev: Guest Log: Service 'draganddrop' started
    00:01:03.250304 VMMDev: Guest Log: All services started
    00:01:03.253012 VMMDev: Guest Additions capability report: (0x1 -> 0x5) seamless: yes, hostWindowMapping: no, graphics: yes
    00:01:03.253107 DnD: Feature is disabled, ignoring request from guest
    00:01:03.253793 GUI: UISession::sltAdditionsChange: GA state really changed, notifying listeners
    00:01:03.253813 GUI: UIMachineViewNormal::adjustGuestScreenSize: Adjust guest-screen size if necessary
    00:01:03.253817 GUI: UISession::sltAdditionsChange: GA state change event came, notifying listeners
    00:01:03.253819 GUI: UIMachineLogicNormal::sltCheckForRequestedVisualStateType: Requested-state=1, Machine-state=6
    00:01:03.253825 GUI: UISession::sltAdditionsChange: GA state change event came, notifying listeners
    00:01:03.253827 GUI: UIMachineLogicNormal::sltCheckForRequestedVisualStateType: Requested-state=1, Machine-state=6
    00:01:06.459954 GUI: UIMediumEnumerator: Medium-enumeration finished!
    
    To be sure i download and installed GA's manually on Windows XP VM. I tried again to launch calc.exe without success
  2. The --wait-stdout may be a problem
    I deleted stdout
  3. waiting the Windows XP end of starting
I launch manually the VM, i logon the user on Windows XP session and i wait the end of starting. After that i launch this command on Windows 11 (host).

vboxmanage guestcontrol “Windows XP” run --exe “calc.exe” --username “Name” --password “Pass”
Image

The calculator app should open in Windows 11 right?
Attachments
command.png
command.png (13.9 KiB) Viewed 4071 times
VirtualBoxR2.jpg
VirtualBoxR2.jpg (100.44 KiB) Viewed 4071 times
Last edited by sebbobo on 12. Dec 2023, 11:42, edited 1 time in total.
fth0
Volunteer
Posts: 5678
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Launch on host a user program installed on guest

Post by fth0 »

Please have a look at #21822 VBoxManage guestcontrol works for calc.exe but not for WINWORD.EXE. The ticket shows a command line working for calc.exe (the path might be relevant), but not for notepad.exe (and winword.exe), which indicates a bug in VirtualBox 7.0.12.
sebbobo
Posts: 6
Joined: 13. Nov 2023, 09:32

Re: Launch on host a user program installed on guest

Post by sebbobo »

fth0 wrote: 12. Dec 2023, 14:20 Please have a look at [... VBoxManage guestcontrol works for calc.exe but not for WINWORD.EXE[/url]. The ticket shows a command line working for calc.exe (the path might be relevant), but not for notepad.exe (and winword.exe), which indicates a bug in VirtualBox 7.0.12.
Thx fth0...I tried the new command line...is better but calc.exe never appears in my host (W11)
verbose.png
verbose.png (41.01 KiB) Viewed 4049 times
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Launch on host a user program installed on guest

Post by scottgus1 »

Testing a text batch file:
I have tried the following on an XP VM on a 6.0.14 host with 6.0.14 Guest Additions. I made a .cmd batch file with this command:

Code: Select all

echo Hello World > "C:\Documents and Settings\All Users\testout.txt"
saved it as:

Code: Select all

C:\Documents and Settings\All Users\testguestcontrol.cmd
then ran this host command:

Code: Select all

vboxmanage guestcontrol "XP1" run --exe "C:\Documents and Settings\All Users\testguestcontrol.cmd" --wait-stdout --username "Name" --password "password"
Since echo was not turned off in the cmd batch file, the command would print on the command line then execute the command.

The command line printed in the host command prompt window. The batch file ran in the VM's disk and made the text file "C:\Documents and Settings\All Users\testout.txt" with the words "Hello World" in it, inside the VM's disk.

The same happened on a 7.0.10 host with 7.0.10 Guest Additions in the VM.

**************************
Testing Calc.exe:
I ran these commands on Calc.exe on the 6.0.14 host:

Code: Select all

vboxmanage guestcontrol "XP1" run --exe "calc.exe" --username "SnC" --password "daddy1"
vboxmanage guestcontrol "XP1" run --exe "calc.exe" --wait-stdout --username "SnC" --password "daddy1"
Both did the same thing, with or without the "--wait-stdout":
The Calc.exe app started on the XP VM's desktop. It did not start on the host's desktop in a separate window. The vboxmanage command on the host stopped and waited for Calc.exe to be closed inside the XP VM. Once Calc.exe was closed, the vboxmanage command completed.

On the 7.0.10 host, Calc.exe only appeared in the XP Task Manager. It did not appear on the XP desktop or the host desktop. The vboxmanage command with "--wait-stdout" waited to complete until Calc.exe was closed in the Task Manager. The vboxmanage command without the "--wait-stdout" completed right away without waiting until Calc.exe was closed in the Task Manager.

FWIW in both 6.0.14 and 7.0.10 the Calc.exe appeared in the Task Manager under the logged-on XP account's name that was used for the vboxmanage command.

Testing with Wordpad.exe behaved the same as with Calc.exe in every respect, on both 6.0.14 and 7.0.10.

I did not try 7.0.12 yet.

**************************
Conclusions so far:
A bug has crept in since 6.0.14.

I have only seen Virtualbox being able to launch apps inside the guest from the host command line. The apps always appear inside the guest. That part was working before but is broken now.

I have never seen mention of Virtualbox making a guest app appear on the host as if it was running on the host desktop. If that ever happened, it has long been lost. Virtualbox running like Apple Fusion has been requested, but hasn't been implemented.

The closest one can get in Virtualbox to having guest apps look like they're on the host desktop is through Seamless. This only makes the guest desktop transparent. All guest apps come forward when one of them is clicked on the host, because one is bringing the whole guest desktop forward. The guest apps still only see the guest disks, not the host disks.

@sebbobo, if you're wanting true integrated guest apps appearing like host apps, it won't happen in Virtualbox yet, even if the existing bug that has crept in since 6.0.14 is fixed. You'll need to re-think how Virtualbox is working now: they're two separate computers, and viewing guest apps is like remote-desktop-ing into another computer. Enhancement requests can be posted on the Bugtracker, also bug reports.
fth0
Volunteer
Posts: 5678
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Launch on host a user program installed on guest

Post by fth0 »

sebbobo wrote: 12. Dec 2023, 11:37 The calculator app should open in Windows 11 right?
No, the GUI should open in the guest OS's (virtual) display. Only standard input, standard output and standard error are redirected to the host.
scottgus1 wrote: 12. Dec 2023, 18:15 On the 7.0.10 host, Calc.exe only appeared in the XP Task Manager. It did not appear on the XP desktop or the host desktop.
Interesting! It does appear in my Windows 10 guest's window running in VirtualBox 7.0.12. So there could be an additional twist regarding Windows XP guests. Perhaps Calc.exe is a different type of Windows application ... ah, the Windows 10 Task Manager shows "CalculatorApp.exe", so there's an indirection between executables involved, and even more interestingly, this seems to have helped.
sebbobo
Posts: 6
Joined: 13. Nov 2023, 09:32

Re: Launch on host a user program installed on guest

Post by sebbobo »

(Since my last post I installed VirtualBox 6.0.24 and i make a try with Windows 7 instead of Windows XP)

Thank you scottgus1 and fth0 for your help,
fth0 wrote: 12. Dec 2023, 19:11 No, the GUI should open in the guest OS's (virtual) display. Only standard input, standard output and standard error are redirected to the host.
:shock: ok since my 1st message i tried to do the impossible :shock:

In my mind it was possible to show a guest app on host desktop like in Seamlessmode. In Seamless mode i launch Calc.exe, Calc apprear in W11 desktop. I try to do the same but without W7 task bar.
desktop.jpg
desktop.jpg (51.02 KiB) Viewed 3696 times
Best regards
sebbobo
Posts: 6
Joined: 13. Nov 2023, 09:32

Re: Launch on host a user program installed on guest

Post by sebbobo »

Hello,

I found a solution...launch seamless mode, hide windows7(guest) task bar and create a shorcut on W11(host) desktop 8)

When i launch the shortcut, the guest app aprear in a windows :D
Post Reply