Double clicking on a VHD to mount it (take 2)

Double clicking on a VHD to mount it (take 2)

  • Comments 4

A while ago I posted about setting this up with Virtual Server 2005 R2 SP1 Beta 2 - but things have changed since then.  If you want to be able to double click on a virtual hard disk to mount it - after you have installed Virtual Server - create a plain text file, change its extension to '.reg' and put the following text inside:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD]
@="Virtual Hard Disk"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell]
@="Plug in"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell\Plug in]
@="&Plug in"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell\Plug in\command]
@="\"C:\\Program Files\\Microsoft Virtual Server\\Vhdmount\\vhdmount.exe\" /p \"%1\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell\Unplug (discard changes)]
@="Unplug (&discard changes)"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell\Unplug (discard changes)\command]
@="\"C:\\Program Files\\Microsoft Virtual Server\\Vhdmount\\vhdmount.exe\" /u /d \"%1\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell\Unplug (commit changes)]
@="Unplug (&commit changes)"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell\Unplug (commit changes)\command]
@="\"C:\\Program Files\\Microsoft Virtual Server\\Vhdmount\\vhdmount.exe\" /u /c \"%1\""

[HKEY_CLASSES_ROOT\.vhd]
@="Virtual.Machine.HD"

Double click on the .reg file and you will be ready to go.  You can now double click on a .VHD file to mount it - and right click on it to select to dismount it.

(N.B. You will need to change the path for vhdmount.exe if you did not install to the default location on C:.)

Two notes about using this with Windows Vista:

  1. For some reason 'double click' does not work.  Right clicking and selecting "Plug in" works - but not double clicking.  If anyone knows why this is - please let me know.
  2. VHDMount needs to run 'As Administrator'.  To get this to work with UAC you will need to browse to vhdmount.exe, right click on it, select Properties, change to the Compatibility tab and check Run this program as an administrator.  Now it will work just fine.

Cheers,
Ben

Leave a Comment
  • Please add 2 and 7 and type the answer here:
  • Post
  • Oh lordy, don't bait us with Vista problems Ben, your blog might never recover... <sigh>

    Signed,

     desperately hoping sp1 fixes things, and soon.

  • Double clicking might not work if the default action in the CURRENT USER's Classes is overriding the LOCAL MACHINE's.

    Maybe changing the .reg file to use the HKCR hive would help.  Otherwise one could check under HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts (I think that's where it is, I'm close at least) to see if there are any conflicting entries.

  • What a sweet tool!

    I created the .reg file, but when I double-click on a VHD file, nothing happens.  I can right-click on a VHD, select Plug In, and the drive(s) show up.

    Also, I can't seem to get rid of (Unplug) the newly mounted drive(s) without rebooting.

    Running XP SP2 with all current updates.

  • Nevermind.  After rebooting, everything works fine.

Page 1 of 1 (4 items)