Get Exit Code From Guest Program

Discussions related to using VirtualBox on Windows hosts.
Post Reply
LonnieMJohnson
Posts: 2
Joined: 6. Mar 2014, 03:04

Get Exit Code From Guest Program

Post by LonnieMJohnson »

I apologize if this should be obvious. I've been googling, but nothing so far.

The idea is, when I use VBoxManage guestcontrol to execute a program on the guest, I would like the host to be able to read the exit code of that guest program.

Let's say the guest has fail.bat

Code: Select all

exit /b 1
Then from the host, I run

Code: Select all

"C:\Program Files\Oracle\VirtualBox\VBoxManage" guestcontrol Win7_x64 exec --image "C:\Users\Developer\Desktop\fail.bat" --username Developer --password developer --wait-stdout --wait-stderr
From the host, how can I get the exit code of fail.bat, which ran on the guest?
LonnieMJohnson
Posts: 2
Joined: 6. Mar 2014, 03:04

Re: Get Exit Code From Guest Program

Post by LonnieMJohnson »

Is there really no way to accomplish this?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Get Exit Code From Guest Program

Post by mpack »

If the guest process returns an exit code, and you used that --wait_exit flag, then I would expect VBoxManage to return that exit code to you. Does it? The example command line you show doesn't show you attempting it. Are you familiar with how exit codes are normally retrieved?

Moreover, a batch file is not directly executable, it is executed by another process - the command console app "cmd.exe". The batch file may return an exit code to the guests command console, but does the command console return that exit code to the caller?
Post Reply