The Windows 7 operating system comes with the option to create virtual hard drive [vhd] images that can be mounted in the operating system after creation. This works pretty much the same way that iso images and other disk images can be mounted in an operating system. VHD images are automatically attached after their creation but never again automatically after the computer system has been rebooted. This is a nuisance for users who need to work regularly with the same vhd image on the computer system.
An easy option to automatically attach vhd images is to use the diskpart command line utility which is part of the Windows 7 operating system. Diskpart is a powerful tool to enable storage configuration from the command line (as well as remote sessions and scripts).
Diskpart can be lauched manually by typing in diskpart in the run box in the Windows 7 start menu. This will open a new command line window with Diskpart launched.

The first command specifies the vhd image that should be attached to Windows 7:
select vdisk file=c:\pathtovhdfile

The second command attaches the specified vhd image
attach vdisk

This is the manual process. To automate the process of attaching a vhd to the system do the following. Create a new text document and place the two lines mentioned above in it. You can add those two lines again for every vhd image that should be automatically mounted during system start. Save the file as vhdattach.s
Create a new text document and add the following line to it.
diskpart -s “c:\pathtovhdattach.s”
Rename the text document to diskpart.cmd and place this file in the startup folder in the Windows start menu. Diskpart.cmd will be executed on startup of the operating system. It will process the commands in vhdattach in diskpart so that the vhd images will be attached to the system.
It might be necessary on the first run to go into the disk management tool to format the vhd drives in Windows so that drive letters are assigned to them. The Disk Management tool can also be used to detach vhd images.
Attention: Copying articles to your website is not allowed. If you like the article you may copy the code below and post it on your website or user profile.Related Articles:
Watermark Images [Windows]Mount Iso Images
Speed Up Windows Vista Reinstallation
Create Virtual Images Of Physical Drives With Disk2vhd
Gmail Starts Displaying Images Automatically For Contacts
