I'm working on setting up a script to launch an internet explorer, installed in Windows XP through virtualbox, from my ubuntu desktop, and I have most of the pieces.

(I know that explorer can be installed through wine or playonlinux, but my wife needs to be able to access one site for her job that simply will not let her in if we're using Wine, but works fine through a VM.)

I can start the VM with
VBoxManage startvm "WindowsXP"

I can launch explorer with
VBoxManage guestcontrol WindowsXP exec --image c:\\program\ files\\Internet\ Explorer\\IEXPLORE.EXE --username owner --password password

And I can check whether or not the VM is already running with
VBoxManage showvminfo "WindowsXP" | grep State

What I'm missing is how to use grep state in a logic check so that it will only try to launch the VM if it isn't already running.

The other thing I'd like to do, which is probably WAY more trouble than it's worth, is set it up so that the VM will savestate and exit when internet explorer is closed. That would be nice, but is not required.