HTAMount – Simplifying the mounting of Hyper-V VHD files to your computer

HTAMount is a HTML application that I wrote a while ago that provides a no-nonsense interface allowing you to mount/unmount offline Hyper-V virtual disk images (VHD) to your local file system, in read-only mode.  It consists of a HTML Application (HTA) front-end with some VBS script doing the mount/unmounting of the images via a WMI interface.  Attached to this post is a zip file that contains the application, hopefully you'll find it useful.


It should be pretty self-explanatory regarding how to use it.  To mount a VHD file,  just click the ‘Browse…’ button to select the VHD file you wish to mount, select the ‘Mount’ radio option, then press the ‘Mount / Unmount’ button.  To unmount a VHD file, just select it from the list of currently mounted VHD files (you might need to refresh this list using the button), choose the ‘Unmount’ radio option and then press the ‘Mount / Unmount’ button.  I can’t guarantee that the code is bug-free, although I have been using it for a while and I think I have solved any issues with it.  If you do find anything that needs fixing, please comment on this post to let me know!

I got the inspiration for developing this tool from a script that the ‘Virtual PC Guy’ posted back in February 2008.  Whilst the script is correct and works great, it had a couple of things that I didn’t like.  Namely, the fact that you need to hard-code the path to the VHD file you want to mount, and that you need to extend the script a bit (or create a 2nd separate one) in order to be able to unmount a VHD file.  So, HTAMount was born.

One thing that is important is that you run the application elevated (if you have UAC enabled) as it makes use of the Windows executable diskpart.exe which requires the highest security level to run.  By default, Windows 2008 does not provide the “Run as Administrator” option when you right-click on a HTA file; however, with a simple change in the registry, you can add this option to the menu for these files.

image The option in the context-menu for HTA files that is lacking by default

Included in the attached zip file is a text file that you can rename to a .reg file after extracting it from the zip archive.  Double-clicking on this file will import its contents into your registry, instantly adding the item to the context menu.


The VBS code is commented, so feel free to open it up with Notepad to see how it all works.  I have also added to the code some comments regarding certain routines, and why I have used them; If you can see any improvements that could be made in the code, I would be interested to know!

This is not an ‘in-development’ tool.  I don’t spend time revising the code, unless I experience an error while using it.  So don’t expect any updates to it unless either I find a bug, or someone else comments on this page with an error that I then fix.  Of course, feel free to suggest new features although I cannot promise anything.  Finally, please don’t distribute this code on a different website., link back to my blog post instead.  This is important so that people will always have the latest version, and know that the source of the download is from the author.

Bugfix: fixed a bug where the interface remained locked when pressing "Unmount" while no disks were mounted.


Comments (1)
  1. Anonymous says:

    Great post, explained really well and I could really understand. Thank you.

Comments are closed.

Skip to main content