I'd like a write a shell script in Ubuntu that does the following:
Boot up a Windows 7 guest OS in Virtualbox, if it isn't running already.
Run a shell script in Windows, where the shell script is invoked from the Ubuntu host operating system.
My goal is to create an application launcher on the Ubuntu host desktop for an application on the guest OS. For example, I could create a shortcut for Visual Studio on the Ubuntu desktop that launches Visual Studio in Windows. I've always wanted to be able to launch Windows applications directly from the Ubuntu desktop instead of waiting for Windows to start up before clicking an application shortcut.
There are some limitation from the Windows guests but to run a guest application in seamless mode from a script that can be put in a launcher we tested the following procedure:
Now we can get full command line control over the virtual machine with the following commands:
Start the virtual machine from seamless save state
or (for the Qt frontend)
Run an application in the VM
Terminate VM in save state
Put these in a script to enjoy seamless Windows application windows on your Ubuntu desktop.
In case you have set up a passwordless Windows logon this will not work. See in the Virtual Box Manual for limitations and how to configure Windows to get it working.
On operating systems without the Group Policy Editor (gpedit.msc), such as Home editions of Windows, creating a DWORD at the registry key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\limitblankpassworduse
and setting it to zero will achieve the same effect, according to this answer.This is more a hint than an answer, but it's too big for a comment.
You should probably look at this. According to the docs, this command, run from the host OS (I' assuming an Ubuntu host and Windows guest):
Should open regedit in Windows (the guest), but I have never been able to make it work.
You can also use
to check if a VM is running or not.
I deleted the original idea when I realized that it won't work because Linux won't be able to access the windows partition in a VM if it's not running already. There may be a more complex way to do it, but I don't know if it's really worth it.
It may be feasible to have a common shared directory, and a script in Windows would always check this directory to see if it is empty or not. If not, it would run the scripts in the directory, which would be put there by the Ubuntu system before running the VM.
You could have a 2nd script that deletes the 1st one so it doesn't run the next time.
I wanted the same thing and ended up solving it without using guestcontrol. On my MacOS X host I have a folder (named Windows) that my vbox client running a Win7 has mapped as Z:. I use dummy-files to communicate between host and my clients like this:
On the Mac host: - created one shell-script complete with an icon for each windows application I wanted to start in the Win-client. What they basically do is makes sure that the VirtualBox hasn't been started before and then creates a "start this particular application"-file in the shared folder that Windows can read after startup. Example of what such a script looks like is this:
Then on the windows client I have a matching script (BAT-file) in the Startup-folder that looks like this:
This way, any time I want to add a new client-startup icon on my Mac I copy the shell script, invent a new dummy file and add the matching startup lines in the BAT-script on the client. Works great and I think it is in line with Martys idea in the previous post.