Adding an existing VHD file to your “Boot from VHD” menu

16 Mar

imageThere are more than a few ways to work with Windows Boot from VHD. I detailed one of the easiest ways to set this up in yesterdays post and that was to let Widows Setup do the work for you. In this post I will show you the easiest way I have found to add an existing VHD file to your boot menu.

 

Commands to add an existing VHD to your boot menu:

  • bcdedit /copy {originalguid} /d "New Windows 7 Installation"
  • bcdedit /set {newguid} device vhd=[D:]\Image.vhd
  • bcdedit /set {newguid} osdevice vhd=[D:]\Image.vhd
  • bcdedit /set {newguid} detecthal on

For more information on these commands can be found on TechNet: 
http://technet.microsoft.com/en-us/library/dd799299(v=ws.10).aspx

The part that I don’t like here is having to type in the GUID correctly. I think there is a high chance for failure. I would much rather have a batch file script read the original GUID and write it for me so I don’t fat finger it and type it wrong.

That is exactly what my friend, coworker, and IT Pro Guru, Dan Stolts, has done. He has written a DOS batch file that will execute those commands. I guess they are now called command shell scripts but you can use either the CMD or the BAT extension on the script.

Here is the syntax of the command that will add the VHD file “c:temp\server8.vhd” to the boot menu listed as Server8 :

C:\Temp>AutoBootVHD-BCD.bat c:\temp\server8.vhd Server8

Now isn’t that a lot easier?

 

You can pull the script off his blog post here:
http://blogs.technet.com/b/danstolts/archive/2011/03/29/how-to-automatically-create-bcdedit-data-for-a-boot2vhd-file-on-your-windows-7-or-windows-server-2008-r2-machine.aspx