oukourj wrote:I'd like to do a hard shut-down, like if I closed the VM window and selected to just turn off the computer instead of shutting down Windows the normal way.
Closing the guest window without a proper shutdown of the guest OS is like pulling the power cord on a real PC. Doing this is very bad for a computer, whether virtual or physical. I would recommend a different thought, or you'll find your guest going south on you soon.
The guest window runs in the context of the host OS. You would have to issue command on the host PC in response to certain of all the random commands happening on the guest PC. Virtualbox does not come with a system to listen all commands & mouse clicks in the guest then issue host command in response.
*
Take Virtualbox out of the equation for a moment and consider that what you're really trying to do is have the closing of an application on one computer do things on another computer. Try to figure out how you'd do that with two computers side-by-side, then apply the solution to your host & guest.
* There is a way through Guest Additions to issue messages in text between host and guest, see section 8.30 in the Virtualbox manual:
Vboxmanage.exe setextradata <vmname> <keyname> <textvalue>
Vboxmanage.exe getextradata <vmname> <keyname>
In the guest the same commands can be used, except use VboxControl.exe instead of Vboxmanage.exe. You could start your guest application with a batch file as Andy recommended, then when the application is closed, issue a setextradata to set a particular 'flag' key in the guest. A host batch file would be neeeded to use getextradata in a time-delayed loop to watch for the change of the guest's 'flag', change it back, then issue the desired command on the host.
Another alternative is to leave your guest on all the time, using the
VboxVMservice add-on. Set the guest to save-state in VboxVMservice. Your guest will run headless (meaning the guest window is running invisible) and activate the Virtualbox Remote Desktop server in the guest settings. When you want to use the guest application, run the host's Remote Desktop client to access the guest window. The benefit of running the guest as a service is that it will be OK through a host shut-down/reboot.
One might think that starting the guest with a detached GUI might be a way. However, while Vboxmanage commands can be used to show the guest window, there is no Vboxmanage command to hide the guest window. Only the Virtualbox window commands in the main window or the guest's Virtualbox menu bar, or a custom host key command can hide the guest window while leaving the guest running.