How to: Easily mount VHDs by right clicking in Windows 7 (and Windows Server 2008)

VHDs are Virtual Hard Disks that are most commonly used as  hard drives for virtual machines. However, VHDs can also be mounted so they act like real hard drives; when mounted they appears to Windows as a real physical hard drive, and you can put files on, edit files on it, remove files on it, etc. Windows 7, and Windows Server 2008, have a new feature which allows users to mount VHDs without needing to use third party software.

While Windows 7 adds the ability to create and mount them natively (and theoretically ISO files as well), to do any of those actions you must use either DISKPART in command line or the Disk Management Console (DMC); and to use either you have to have Administrator rights.  Unfortunately, the only way to fix the Administrator rights problem is to turn off the UAC, a very bad idea.  However, there are ways to mount VHDs without using DISKPART or DMC. In this post, I am going to discuss two ways to do just that.

The first way is by using program called VHD Attach. All users have to do is install the program, and VHD Attach will add the the ability to “Attach” (mount) or “Detach” (demount) directly into the context menu (the menu that you get when you right click a file) for VHD files:

The cool thing about VHD Attach is once you run the installer, you need not (ever) run the program again. The context menu entries are done by editing the Windows registry and other geeky stuff so VHD Attach does not have to be running in order to use “Attach” and “Detach” from the context menu.

However, if you do want the run the program part of VHD Attach, you can use it to gain information about VHD files:

2009-11-13_190503

One *additional* feature VHD Attach adds is a “Detach” option on the context menu of real physical hard drives/partitions.

The second way is for the users who want more control over the whole process, or more options from the context menu, or just prefer not to download a program. Ben Armstrong, a Virtualization Program Manager at Microsoft, published on his blog “Virtual PC Guy’s Blog” a script that can do similar things as VHD Attach.  What makes his different and a bit more complex is that it uses DISKPART in the background, giving it more power.  Of course, “installing” the script is a bit more involved than running a simple EXE file. To install it run the code with the word install after it like “VHDBatch.cmd install”.  That will add the ability to mount, mount as read-only, demount, and compact the VHD.

My only complaint is that Ben Armstrong set the default double click action to mount as read-only, so if you’re like me and want it to mount it normally by default, you can download a version I modified.

You can download VHD Attach, Ben Armstrong’s script, and my modified version from the following links:

VHD Attach

Version reviewed: v1.00

Supported OS: Windows 7 and Windows 2008 Server R2

VHD Attach homepage [direct download]

Ben Armstrong’s Script

Version reviewed: Unknown

Supported OS: Windows 7 and Windows 2008 Server R2

Virtual PC Guy’s Blog homepage

[Direct download – Ben’s Script]

[Direct download – my modification of Ben’s script]

Share this post

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

6 comments

  1. Samuel
    Author/

    @Gerald Gibson:
    You would need to Hack the VHD API and have a parser for ISOs. The reason I said that it can handle ISOs theoretically is that in the API when you deal with disks, it asks what kind, with the options being VHD, ISO or Unknown. I suspect that microsoft plans to add ISO support, but for some reason didn’t yet. Could it be done by a third party? I don’t know. If you want to give it a try I could send you what I have on it, but it’s very complex.

  2. PTLdom

    … well … I simply

    1- right-click on the startup “computer” label,
    2- choose “diskmanagement”,
    3- wait for the central area/column filling in
    4- and click on “more actions” in the right column … where is the “attach vhd” option