
AttachVHD V2.0.0 - attaches VHDs + ISOs and assigns mount points
Freeware by Uwe Sieber - www.uwe-sieber.de

Win32 version works on Windows XP and higher. It does not work on x64 version of Windows.
x64 version works on x64 versions Windows only.

Windows 7 and higher have build-in VHD support, XP, Server 2003, Vista, Server 2008 need
Microsoft Virtual Server 2005 installed in its default folder (%ProgramFiles%\Microsoft Virtual Server\Vhdmount),
here AttachVHD looks for its vhdmount.dll.

Admin privilegs are required or (under Windows 7 and higher) USBDLM V5.7.6+ with CommandInterface 0x100 active.



Usage:
AttachVHD VHDfile [Letter] [-ro] [-na] [-n] [-w:nnnn]

AttachVHD VhdFile [Letter] [-h] [-ro] [-na] [-n] [-w:nnnn]
VhdFile   the VHD, VHDx or ISO file to attach
Letter    one or more drive letter(s) or mountpoints to assign
-ro       mount read-only
-na       no about info
-n        no wait on end when started standalone
-w:nnnn   wait nnnn ms on end



Samples:

AttachVHD X:\test.vhd

AttachVHD X:\test.vhd X:

AttachVHD X:\test.vhd X: Y:

AttachVHD X:\test.vhd C:\vhdmounts\test

AttachVHD X:\test.vhd C:\vhdmounts\%ContainerFileBody%_Part%PartitionNumber%_%VolumeLabel%


When using NTFS mountpoints then some variables can be used:

%ContainerPath%          the VHD file's complete path, like "D:\VHDs\VirtualDisk.vhd"
%ContainerFile%          the VHD file's file name, like "VirtualDisk.vhd"
%ContainerFileBody%      the VHD file's file name without extension, like "VirtualDisk"

%DiskSignature%          the disk's MBR disk signature, like "9810ABEF"
%GptDiskIdGuid%          the disk's GPT ID GUID, like "{6E69654D-4220-6361-6B75-702D4C572032}"
%GptDiskIdGuidAsText%    the disk's GPT ID GUID, interpreted as 16 Bytes ASCII text, like "Backup 2026-05"
%DeviceNumber%           the disk's device number (non-static, dynamicly assigned)

%VolumeLabel%            a volume's volume label, like "Backup 05"
%VolumeSerial%           a volume's volume serial number, like "ABCDEF12"
%PartitionName%          a volume's GPT partition name, like "Basic data partition"
%PartitionNumber%        a volume's partition number

Most of these can be edited by means of USB Drive Info:
https://www.uwe-sieber.de/usbdriveinfo_e.html

When a drive letter or mount-point is specified then the VHD is attached with
the NO_DRIVE_LETTER flag which prevents Windows assigning a drive letter.
AttachVHD then assigns the specified letters to non-hidden partitions in the
order of the partition numbers. Hidden partitions are ignored and get no letter
assigned.
Specifying more letters than needed is ok, surplus ones are just not used then.
If there are not enough drive letters specified then remaining partitions get no
drive letter assigned, unless the last specified mount point is an NTFS mount-point
and contains a variable. Then this last one is used for all remaining partitions.




Returns Errorlevels:

0 - successfully attached the VHD file
1 - invalid parameters
2 - VHD is not supported
3 - VHD file not found
4 - VHD is already attached
5 - no admin privilegs and no USBDLM command interface
6 - VHD API error
> - something else :-)



For detaching a VHD there is RemoveDrive:
https://www.uwe-sieber.de/drivetools_e.html

Samples:

RemoveDrive V: -vhd
RemoveDrive Disk3 -vhd
RemoveDrive D:\test.vhdx




Licence


AttachVHD is Freeware.

Allowed:
- usage in any environment, including commercial
- include in software products, including commercial
- include on CD/DVD of computer magazines
- making available for download by means of package managers

Not allowed:
- changing any of the files
- offer for download by means of a "Downloader" software



Uwe Sieber
May 2026

