Batch file as shortcut to guest program on host?

Discussions related to using VirtualBox on Windows hosts.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Batch file as shortcut to guest program on host?

Post by scottgus1 »

Lendri Mujina wrote:the batch file works
Good, I'm glad we've got that far. I have never run across anything in Virtualbox settings that would block 'guestcontrol'. The only thing I can think of is to make doubly sure that the username and password of the VM's auto-log-on'ed account is being used in the command.

example: my VM's account that I set to auto log on is "snc" with a password of "daddy1". So my command is:

VBoxManage --nologo guestcontrol "Windows XP" run --exe "mspaint.exe" --wait-stdout --username snc --password daddy1

Also, double-check that the Guest Additions installed in the VM aren't very out-of-date with Virtualbox. You should be able to mouse-over the GAs icon in the system tray next to the clock to see the GAs version
Lendri Mujina
Posts: 17
Joined: 29. Jun 2021, 00:33

Re: Batch file as shortcut to guest program on host?

Post by Lendri Mujina »

scottgus1 wrote:
Lendri Mujina wrote:the batch file works
Good, I'm glad we've got that far. I have never run across anything in Virtualbox settings that would block 'guestcontrol'. The only thing I can think of is to make doubly sure that the username and password of the VM's auto-log-on'ed account is being used in the command.

example: my VM's account that I set to auto log on is "snc" with a password of "daddy1". So my command is:

VBoxManage --nologo guestcontrol "Windows XP" run --exe "mspaint.exe" --wait-stdout --username snc --password daddy1

Also, double-check that the Guest Additions installed in the VM aren't very out-of-date with Virtualbox. You should be able to mouse-over the GAs icon in the system tray next to the clock to see the GAs version
Now Command Prompt is giving me a Syntax Error.

Code: Select all

C:\Program Files\Oracle\VirtualBox>VBOXMANAGE guestcontrol run --exe "C:\WINDOWS\system32\calc.exe"
Oracle VM VirtualBox Command Line Management Interface Version 6.1.22
(C) 2005-2021 Oracle Corporation
All rights reserved.

Usage:

VBoxManage guestcontrol     <uuid|vmname> [--verbose|-v] [--quiet|-q]
                              [--username <name>] [--domain <domain>]
                              [--passwordfile <file> | --password <password>]

                              run [common-options]
                              [--exe <path to executable>] [--timeout <msec>]
                              [-E|--putenv <NAME>[=<VALUE>]] [--unquoted-args]
                              [--ignore-operhaned-processes] [--profile]
                              [--no-wait-stdout|--wait-stdout]
                              [--no-wait-stderr|--wait-stderr]
                              [--dos2unix] [--unix2dos]
                              -- <program/arg0> [argument1] ... [argumentN]]

                              start [common-options]
                              [--exe <path to executable>] [--timeout <msec>]
                              [-E|--putenv <NAME>[=<VALUE>]] [--unquoted-args]
                              [--ignore-operhaned-processes] [--profile]
                              -- <program/arg0> [argument1] ... [argumentN]]

                              copyfrom [common-options]
                              [--follow] [-R|--recursive]
                              <guest-src0> [guest-src1 [...]] <host-dst>

                              copyfrom [common-options]
                              [--follow] [-R|--recursive]
                              [--target-directory <host-dst-dir>]
                              <guest-src0> [guest-src1 [...]]

                              copyto [common-options]
                              [--follow] [-R|--recursive]
                              <host-src0> [host-src1 [...]] <guest-dst>

                              copyto [common-options]
                              [--follow] [-R|--recursive]
                              [--target-directory <guest-dst>]
                              <host-src0> [host-src1 [...]]

                              mkdir|createdir[ectory] [common-options]
                              [--parents] [--mode <mode>]
                              <guest directory> [...]

                              rmdir|removedir[ectory] [common-options]
                              [-R|--recursive]
                              <guest directory> [...]

                              removefile|rm [common-options] [-f|--force]
                              <guest file> [...]

                              mv|move|ren[ame] [common-options]
                              <source> [source1 [...]] <dest>

                              mktemp|createtemp[orary] [common-options]
                              [--secure] [--mode <mode>] [--tmpdir <directory>]
                              <template>

                              stat [common-options]
                              <file> [...]

VBoxManage guestcontrol     <uuid|vmname> [--verbose|-v] [--quiet|-q]

                              list <all|sessions|processes|files> [common-opts]

                              closeprocess [common-options]
                              <   --session-id <ID>
                                | --session-name <name or pattern>
                              <PID1> [PID1 [...]]

                              closesession [common-options]
                              <  --all | --session-id <ID>
                                | --session-name <name or pattern> >

                              updatega|updateguestadditions|updateadditions
                              [--source <guest additions .ISO>]
                              [--wait-start] [common-options]
                              [-- [<argument1>] ... [<argumentN>]]

                              watch [common-options]

VBoxManage.exe: error: Unknown option: --exe

C:\Program Files\Oracle\VirtualBox>
It doesn't recognize "-exe", either.
Or "exe".
Or omitting the "exe" part entirely.

This is after upgrading Virtualbox and reinstalling Guest Additions.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Batch file as shortcut to guest program on host?

Post by scottgus1 »

That's even weirder now, especially since the syntax output of the command clearly says:
run [common-options]
[--exe <path to executable>]
Unless there's a hard space or an n-dash instead of a hyphen in there somewhere, I am beginning to wonder if the original Portable Virtualbox is somehow still having an influence, as odd as it would be. I would try switching hard drives in the physical PC, fresh-installing the host OS, and Virtualbox and the VM, then try the commands again.
Lendri Mujina
Posts: 17
Joined: 29. Jun 2021, 00:33

Re: Batch file as shortcut to guest program on host?

Post by Lendri Mujina »

scottgus1 wrote:That's even weirder now, especially since the syntax output of the command clearly says:
run [common-options]
[--exe <path to executable>]
Unless there's a hard space or an n-dash instead of a hyphen in there somewhere, I am beginning to wonder if the original Portable Virtualbox is somehow still having an influence, as odd as it would be. I would try switching hard drives in the physical PC, fresh-installing the host OS, and Virtualbox and the VM, then try the commands again.
That is genuinely impossible. This is a laptop (a thousand-dollar gaming laptop at that!), I can't afford an additional drive, and besides, I very strongly doubt that would be an issue, because I never even installed Portable Virtualbox on this particular machine. That folder is residual from a previous installation putting it in Dropbox long ago, and I keep the folder around because that folder is where my VM's hard disks and .vbox files are (and I just can't be assed to change the directories). The program itself has never even touched this machine.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Batch file as shortcut to guest program on host?

Post by scottgus1 »

I'm at a loss then. I've run your batch files on my computer and had success. I've also run a similar script on a host for heartbeat testing and had success.

Microsoft Sysinternals has an app called PsExec that can launch programs from other networked computers. If you make a Host-Only or Bridged network to the XP VM such that you can ping the VM and the host from each other, then PsExec may get your apps to launch.

Many modern PCs and laptops can boot from external USB drives, which are not that expensive nowadays.

Sorry I can't figure out why your host is failing to launch the VM programs and mine succeeds. It's a real puzzle.
Post Reply