# Launch an application in Windows from the Ubuntu desktop

I'd like a write a shell script in Ubuntu that does the following:

1. Boot up a Windows 7 guest OS in Virtualbox, if it isn't running already.

2. 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:

• Start VirtualBox Manager
• Switch to seamless mode Host + L
• In seamless mode save the machine's state

Now we can get full command line control over the virtual machine with the following commands:

• Start the virtual machine from seamless save state

VBoxManage startvm "<Name_of_VM>"


or (for the Qt frontend)

VirtualBox --startvm "<Name_of_VM>"

• Run an application in the VM

VBoxManage --nologo guestcontrol "<Name_of_VM>" run --exe "C:\\full\\path\\to\\program.exe" --username windowsuser --password password --wait-stdout

• Terminate VM in save state

VBoxManage controlvm "Name_of_VM" savestate


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.

Also, to use accounts without or with an empty password, the guest's group policy must be changed. To do so, open the group policy editor on the command line by typing gpedit.msc, open the key Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options and change the value of Accounts: Limit local account use of blank passwords to console logon only to Disabled.

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.

• Should each of these commands be run from the Windows command line or the Ubuntu command line? – Anderson Green Jun 21 '12 at 16:50
• Pretty nice concept, although I've never really liked the seamless mode for some reason - probably because it gets confusing about keyboard navigation. But I'm tempted to try some of this out for my few Windows programs I still use, like Quicken and iTunes. @AndersonGreen: this is run from the Ubuntu commandline, and can easily be entered in a terminal for testing, then made into a script. – Marty Fried Jun 21 '12 at 17:39
• It is the windows password you need as you are likely logged in to Ubuntu, and starting a VM should not require root access. Note that you need a Windows password and login for this to work. – Takkat Dec 23 '12 at 19:24
• Should this work in the opposite manor(running Windows as main OS and linux as virtual machine) – William Sep 10 '18 at 1:13

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):

VBoxManage guestcontrol "Windows XP Pro" execute --image "cmd.exe" --username javier --verbose "/c" "regedit.exe"


Should open regedit in Windows (the guest), but I have never been able to make it work.

You can also use

VBoxManage showvminfo "Windows XP Pro" | grep State


to check if a VM is running or not.

• Interesting ideas, and I think it could be used as another way to accomplish the task. The guest could be launched from the host, then when it's running, the command could probably be made to work to run a command. For a programmer, it may be an easier way than my idea; it involves using "sleep" in a loop to wait for the VM to be up, but it can all be done from the host, with a single script. – Marty Fried Jun 21 '12 at 16:30
• I just tried out your first execute command and was able to run Quicken on my first attempt from an already running Windows XP VM, named "Windows XP" using this command from a Ubuntu terminal commandline: VBoxManage guestcontrol Windows\ XP exec --image c:\\program\ files\\quicken\\qw.exe --username XXXXX --password XXXXX, where XXXXX was my username and password. – Marty Fried Jun 21 '12 at 16:50
• Maybe my problem is that I use a password less account. – Javier Rivera Jun 21 '12 at 17:14
• Probably... I just changed the command I ran to use your format and it did indeed run regedit. – Marty Fried Jun 21 '12 at 17:28
• Takkat have said that it doesn't work in passwordless accounts like mine. That explains why I had never been able to did it ;). – Javier Rivera Jun 21 '12 at 17:30

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'd like to create a shortcut for Visual Studio and a shortcut for Internet Explorer that can be invoked from the Ubuntu desktop(so that they run in the virtual machine). Can this be done using the method you described? – Anderson Green Jun 21 '12 at 0:24
• I'd like to know whether the inverse could also be done - launching a host application (such as Kolourpaint) from the guest operating system. – Anderson Green Jun 21 '12 at 0:28
• Could the inverse be done using guest additions, then? – Anderson Green Jun 21 '12 at 0:35
• Also, are you referring to the Windows startup folder or the Ubuntu startup applications list? – Anderson Green Jun 21 '12 at 0:36
• Sorry, I realized my first idea was flawed, because the windows folder doesn't exist until the VM is running. I revised my answer completely, and I hope it's not too confusing. – Marty Fried Jun 21 '12 at 0:42

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:

#!/bin/bash

# bail if vbox is already started/running windoze...
ps ax | grep -v grep | grep 'Windows 7' > /dev/null
if [ $? -eq 0 ]; then echo "Sorry, Windows is already running." exit 0 fi # send a message to Windoze which program to start... touch /Users/urban/Documents/Windows/START_TS2000I.TXT # startup Windoze in seamless mode vboxmanage setextradata 'Windows 7' GUI/Seamless on vboxmanage startvm 'Windows 7' & exit 0  Then on the windows client I have a matching script (BAT-file) in the Startup-folder that looks like this: @echo off pushd "C:\Program Files\Omega Research\Program" if exist Z:\start_ts2000i.txt start ORTrade.exe if exist Z:\start_ts2000i.txt del Z:\start_ts2000i.txt . . . exit 0  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. • Have you tested this in an Ubuntu host? – user68186 Nov 4 '14 at 19:12 • No, but I'm pretty sure it would work without glitches. The vbox commands are the same and so is bash. – Urban Nov 4 '14 at 19:16 • It's safer to use pgrep instead of ps | grep. The latter runs the risk of matching itself. – muru Nov 4 '14 at 19:33 • Yes, you're right. I believe fixed it above using ps by adding an extra grep -v to filter away the self-match problem. I couldn't figure out how to use pgrep as you suggested in this case since the VBox name 'Windows 7' in my case is a comment argument to the process, like this: MacMini:~ urban$ ps ax | grep -v grep | grep 'Windows 7' 10874 ?? R 4:38.49 /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS/VirtualBoxVM --comment Windows 7 --startvm 24507412-789d-42ed-9c79-b4faf0c2d130 --no-startvm-errormsgbox but maybe you have a suggestion on this? – Urban Nov 4 '14 at 20:31