How can I associate file types in desktop Linux with Windows 7 applications running through VirtualBox so they work seamlessly, starting VirtualBox if required?

I'm using KDE.

Current method

(example for Excel files):

Add a new entry in the start menu called "Excel"

  • Command: /home/USER/bin/excelstarter.sh %f
    • See below
  • Launch feedback does not work well so it's disabled

Associate .xlsx files with "Excel" by right clicking and choosing run as...

  • Remember application associations for all files of type ...

Mount relevant folders in VirtualBox

  • VirtualBox main window > Settings for machine > Shared folders:

    • Add:
      • Folder path: /data
      • Auto mount
      • Make permanent
    • Add:
      • Folder path: /home/USER
      • Auto mount
      • Make permanent

Disable group policy restriction on empty passwords

Without this change VirtualBox will not run commands if no password has been set.

  • Run gpedit.msc
  • Navigate to

    Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options

  • Change

    Limit local account use of blank passwords to console logon only to Disabled.


The idea here is that this file takes care of starting VirtualBox if it is not already running, waiting for it to start up and then starts Excel with a filepath that has been translated to the corresponding mounts set up in VirtualBox.

# Start VM (if it is already started this does nothing)
VBoxManage startvm "win7_hilti"

# Replace folders with windows-local versions (mounts need to be setup)
# /data/ is mounted as F:

# /home/USER/ is mounted as G:

# Used for debugging the file paths
#notify-send $fixedFilePath

# Start Excel
# Try to run it until it the machine has started
until VBoxManage guestcontrol "VM-NAME" start --exe "C:\\Program Files\\Microsoft Office\\Office14\\EXCEL.EXE" --username WINDOWSUSER "excel" -- "$fixedFilePath"
  # Sleep 1 gave the problem that the mounts were not yet ready, sleep 2 seems to work fine
  sleep 2


  • VirtualBox does not get focus if it was already running in the background.
  • Ugly sleep in the loop while waiting for VirtualBox to start. Sleep 1 gave problems where the mounts were not yet set up. On a slower machine this value might need to be increased.
  • Sometimes it does not start Excel after VirtualBox has started.


VBoxManage guestcontrol

The fix to enable passwordless use


Several tweaks:

-- instead of hardcoding the path to application, I used cmd.exe start command:

options=( --username WINDOWSUSER --exe "%SystemRoot%\system32\cmd.exe" -- 'cmd' /c start "run this" "$fixedFilePath" ) where $fixedFilePath is as in your code. These options work even if $fixedFilePath contains blanks.

This generalises the script -- it will work now for any type of file, not just excel files.

It should also work if $fixedFilePath is a full path to a programme within your windows guest; the name (with extension) of a programme on %PATH; or the name (with extension) if a registered programme, e.g. winword.exe, excel.exe.

I then tested the string returned by VBoxManage guestcontrol on stderr:


while [ $nError -gt 0 ] && [ $nTries -lt 20 ]; do

   nError=$(VBoxManage guestcontrol win7_hilti start "${options[@]}" 2>&1 >/dev/null | grep -c "error")
   sleep 2


(some of which I borrowed from this source)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.