Page 1 of 1

Get Exit Code From Guest Program

Posted: 6. Mar 2014, 03:12
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?

Re: Get Exit Code From Guest Program

Posted: 7. Mar 2014, 06:30
by LonnieMJohnson
Is there really no way to accomplish this?

Re: Get Exit Code From Guest Program

Posted: 7. Mar 2014, 12:50
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?