Automatically attaching VHD files in Windows 7 and Windows 2008 26 November 2009 jscott If you have played with the new VHD feature in windows 7 or windows 2008 then you know just how cool of a feature this is. However the problem is that when you reboot your machine you find that when it comes back up all your VHD files are no longer attached? Here is what I did to get around the issue. Create a batch file that will hold the following line: diskpart /s “c:\path to script\diskpartscript.txt” I named my batch file attachvhd.bat and placed it in the same folder as my VHD files Create the script file that is being referenced by the attachvhd.bat batch file. Here is what the contents of that script needs to contain: select vdisk file="c:\path to vhd files\myvhddrive.vhd" attach vdisk I named my script file diskpartscript.txt and placed it in the same folder as my VHD files. Create a scheduled task that will automatically run when your machine starts up. Go to Start / Administrative Tools / Task Scheduler Click Create Basic Task Fill in the name of the task and the description and Click Next Select “Start a program” radio button option and then Click Next Select “When the computer starts” and then Click Next Browse to the folder that you setup your batch file in and select it. Click Next Click Finish You have now completed all the necessary steps. Restart your computer and you should find that your VHD files are now automatically attached. One caveat is that if you reboot and you log into your machine quick enough it is possible that the task may not have been run yet. Once you are logged in if the task runs you will get an Autoplay dialog as follows. Simply close it. This does not happen if the task runs before you get logged in.