Mister Goodcat

Peter's home of all things life

Wednesday, 9/14/2011 6:40 PM
by Peter Kuhn

Installing Windows 8 Developer Preview as bootable VHD

Wednesday, 9/14/2011 6:40 PM by Peter Kuhn | 47 Comments

This tutorial is fully compatible with Windows 8 Consumer Preview (released Feb 29th, 2012).

Minutes before I submitted my previous article that talks about installing Windows 8 in a virtual machine using VirtualBox, Scott Hanselman posted an article of his own about how he installed Windows 8 into a bootable VHD. This is a nice approach because it yields in much better performance. Only the hard disk is virtualized, not the rest of the hardware, so you benefit from the full power of your CPU and video card without creating a real dual boot setup or even upgrading your system completely. The drawback is that you have to boot into that Windows 8 VHD separately, whereas the installation with VirtualBox allows you to run Windows 8 within your existing system, and you can switch back and forth between both in the blink of an eye.

Two Alternatives

Scott mentions that there are half a dozen ways to create such a bootable VHD. But generally those alternatives can be categorized in two ways: First of all we have methods that setup the blank VHD and you then install the system manually into it. This process requires the creation of a separate USB or DVD boot media from the Windows 8 ISO you've downloaded and basically is the same experience like when you install the operating system on a blank computer – you go through all the required steps and reboots as usual, with the only exception that you use the VHD as target disk drive instead of a physical disk. Scott's article describes exactly that.

The other methods create the full VHD (including the desired target operating system) without the need to manually boot from an installation media and go through all of the installation steps. This process is known as "sysprepping" and creates an "almost finished" system in the VHD. When you boot it up for the first time, you have a similar experience to what happens when you buy a computer from an OEM: only some minor final steps have to be performed, like detecting drivers, accepting license agreements, setting the computer name, and you're done. This is a cool solution especially if you often want to start over from a really fresh installation, probably on different machines. But the drawback is that the involved steps usually involve some serious administrator kung fu. Scott has an article on that too, which can be found here (for Windows 7). As you can see it involves several steps and additional tools you have to download, which is not exactly straight forward. I found it especially annoying that you need to download, extract and install a whopping 1.66GB ISO package named "Windows Automated Installation Kit (AIK)" just to retrieve another command-line tool of < 1 MB that is required for the process.

After some digging around I found a simpler method for all this, so if you're interested in booting Windows 8 Developer Preview from a VHD and don't want to go through the manual steps Scott describes, read on.


I have used this method, utterly fearless, on my main development machine. I worked like a charm and ultimately allowed me to boot into both my already existing Windows 7 system as well as the Windows 8 VHD. That however doesn't mean that it's going to work as smoothly for everybody else; I don't take responsibility for any damage you do to your system when you follow these instructions. Everything described here comes without warranty, and all you do you do at your own risk.

Creating the VHD

Instead of using command-line tools for this, I simply make use of the built-in features of Windows 7. Simply go to Control Panel => Administrative Tools => Computer Management and select the node labeled "Disk Management" there. From the Action menu you can now create a new VHD:


This will take a while, depending on the size of the virtual disk. Keep an eye on the status bar of the Computer Management window, it shows the progress. Once finished, the new disk will appear in the list of drives in the lower right panel. Right-click the drive and select "Initialize Disk".



After that, you can start creating a partition on the disk. Select the "Unallocated" space, right-click and choose "New Simple Volume…" which will spawn a new wizard. Assign all the available size to the new volume, and also assign a drive letter:


Make also sure to format the partition (quick format is sufficient).


After that, you have created a new VHD that is now available through the assigned drive letter (until you detach it or until next reboot), in the above sample that is the letter "V".

Create the Windows Image

Instead of downloading several individual files and in particular the huge "Automated Installation Kit" I mentioned above, it is sufficient to use a single tool for this: "Install-WindowsImage". It is a PowerShell script that makes use of a built-in dll of Windows 7 to achieve the same the other tools do, but it's only a few kilobytes big and can be downloaded from the MSDN archive here. Make sure that you right-click the file after download and select "Unblock" from the properties to avoid running into security issues when you try to run the script.

What it of course needs is the source data from the Windows 8 ISO you downloaded. You have several possibilities for this: either mount that ISO file as virtual DVD drive using a tool like MagicDisc, or burn it on DVD, or extract it to a local disk using 7-zip or similar tools.

The process then is the following: open a PowerShell command prompt with elevated rights (right-click the start menu entry and select "Run as Administrator") and navigate to the path you have put the script into. Then execute the following command:


 1: PS D:\temp\win8> .\Install-WindowsImage.ps1 
 2:   -WIM D:\temp\win8\extracted_iso\sources\install.wim 
 3:   -Apply 
 4:   -Index 1 
 5:   -Destination V:\

Let's break that down for a moment:

  • WIM: Tells the script where to find the the source. This always is the "sources\install.wim" file of the Windows 8 ISO content; adjust the path to fit your needs. Note: Relative paths do not seem to work here and result in an error (thanks for finding this issue, Kunal!). Please use absolute paths when you specify the .wim source.
  • Apply: the source content should be applied to the target
  • Index: the index of the SKU contained in the source. The Windows 8 Developer Preview only has one, so "1" is the only option possible in this case (note: 1, not 0).
  • Destination: the target where to apply the source to. This is the drive letter assigned to your VHD.

The process takes a few minutes, so grab a cup of coffee until it's finished.

Note: if this is the first time you're using PowerShell to run a script, you will receive an error like "Install-WindowsImage.ps1 cannot be loaded because the execution of scripts is disabled on this system". This is a security mechanism of PowerShell to prevent accidental execution of malicious scripts. You can use the following command to set this execution policy to something that allows execution of all local scripts and only digitally signed remote scripts. Setting this is a one-time thing and persisted permanently:

   1: PS D:\temp\win8> Set-ExecutionPolicy RemoteSigned

Thank you Michael for pointing this out.

Booting from the VHD

Most tutorials now show you how to use BCDEdit to manipulate the boot menu of your computer to add an additional entry for the VHD. I won't do that simply because I couldn't find a way to make the Windows 7 bootloader actually load Windows 8 (which I would have preferred, given the pre-release nature of Windows 8). So BCDEdit alone is not sufficient, and booting the VHD will fail even if you add a seemingly correct boot menu entry. Instead, what I did was replace the existing boot files of Windows 7 with the ones that come with Windows 8.

This, although very simple to achieve, is probably is the most critical part of the tutorial, because now is the time you actually start screwing with your existing system. The Windows 8 bootloader is pretty smart and recognizes the existing Windows 7 installation (and also additional existing entries in the boot menu). Replacing the loader will merge the existing entries with a new one for Windows 8, which gives you the option to boot into both your existing Windows 7 installation as well as into the Windows 8 VHD. However, things may go wrong here, and there may be a chance you turn your system into a surprise box with hours of recovery fun by this last step – again: proceed at your own risk.

Open a command prompt with elevated rights and navigate to the Windows\System32 folder of your existing Windows 7 installation (not the one of the mounted VHD!). Then use the following command:


 1: bcdboot.exe V:\Windows

This of course assumes that you've also used "V" as drive letter for your VHD.

And that's it! The next time you reboot, you will be presented with this nice new boot menu that let's you choose between your existing system and the Windows 8 VHD:


The first time you start Windows 8 it finishes the last steps of the setup as mentioned above, and then you're ready to go!

Additional Notes

When I first installed Windows 8 this way, it actually asked me for a key. I simply skipped over that screen, and later on the copy was listed as "Activated" in the system properties, so I think it's safe to ignore that.

Another thing I came across, which might be a problem with my particular hardware setup, was that I could not see the tiles on the Metro UI start screen. I fired up Windows Update, which actually found a few things to update and optional drivers to install, and after the next reboot the tiles showed correctly. So if you run into any problems on your hardware, make sure to run Windows Update first and get the latest bits from Microsoft.

Comments (47) -

   When following the instructions, after running the powershell command i get this error

Exception calling "Apply" with "1" argument(s): "Unable to apply image to W:\. Error = 1392"
At C:\users\supreet\downloads\Install-WindowsImage.ps1:831 char:39
+     $wimContainer[$($Index - 1)].Apply <<<< ($Destination)
    + CategoryInfo          : NotSpecified: (Smile [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : DotNetMethodException

Any ideas what might be going wrong?
I created a VHD with 22GB & after the error its 16.9 gb occupied.

Kindly suggest.

Thanks & Regards
Supreet Tare

There seems no information about that error other than very few hits of someone who ran into the same one with Windows Server. I am no PowerShell expert and also have no experience with that API used in the script, sorry. Are you using a server operating system?

If nothing else helps, you can try to work through this using Scott Hanselman's article (either the one with the manual installation or the second one I linked to using the Automated Installation Kit.

I have the same error, you can resolve?

thanks ^^

I am not maintaining this script and have no experience with the APIs used, so unfortunately I cannot do anything if you bump into problems with it - unless it's really basic issues that are easy to fix. Sorry.

@Supreet Tare - I was getting the same error. The problem was my VHD was not attached and I can see no V: or (W: in your case). Once I attached, the command worked.

@Sandeep - You can say me the command to attach? I have the same error..

Please see my comment below (for Supreet) for a solution.

Hi Sandeep,
   Thanks thats a really great news because I was still not able to overcome the issue. Please suggest the options/ commands to fix it.


To attach the VM, you can also use the "Disk Management" component of the Control Panel mentioned in the post. From the "Actions" menu, instead of creating a new VHD, you can select the "Attach" command. Navigate to the VHD you created before and select it.

Also make sure it has a drive letter assigned. You can right-click the partition you created and select "Change drive letters and paths..." if it hasn't or if you want to change it.

Are you *sure* you made a 22G drive? The default for the Windows dialog is in MB - I missed this the first time, and got an error @ this line.... although it was error 112

Worked for me! I had to run this command in the PowerShell console to get the script to run:
Set-ExecutionPolicy RemoteSigned

But this works on my Compaq 6715b laptop. I could not be happier!

Hi Michael. Thank you for the hint, I should add that to the description.

Thanx for the post. Smile
It told me that the script is unsigned and needs to be signed for it to work!

Setting the Execution policy to unrestricted solved this:

"PS D:\> Set-ExecutionPolicy RemoteSigned"

Where is the install.wim file??????  Can't find it

Hi. It's in the "sources" folder inside the ISO you downloaded from Microsoft.

The media I had was "different" than the one from MSDN - I should be good to go thx

Great article! Thank you very much. Worked out very well for me!

Does executing bcdboot.exe c:\windows from win7 bring back old win 7 boot loader?

Yes, that is exactly how it works. By executing bcdboot.exe from Windows 7 and pointing it to the Windows 7 system folder, you restore the original boot loader.

This will not remove the boot menu entry for the Developer Preview though. You would have to remove that manually if you don't want it anymore, either by using bcdedit.exe or one of the many available 3rd party graphical UIs to edit the boot menu.

I am not getting great results here:
C:\Windows\system32>bcdboot m:\Windows
Failure when attempting to copy boot files.

Any Ideas?

Even i encountered the same error. I did the following:
1. Restart w7 and press F8 before windows boot.
2. Enter Windows repair and open command prompt.
3. enter diskpart in command prompt and then execute the following:
    a. select vdisk file="e:\win8.vhd" (where file is the path)
    b. attach vdisk
4.exit from diskpart and execute bcdboot.exe m:\Windows
5. Reboot

This worked for me.

Did you start the command prompt with elevated rights? Right-click the command prompt entry in the start menu and select "Run as Administrator" (or hit Ctrl+Shift+Enter with the entry selected).

I am entering the following in the command line:

.\Install-WindowsImage.ps1 -WIM c:\vms\win8developer\sources\install.wim -Apply - Index 1 -Destination v:\

And I am getting this error:

C:\vms\Install-WindowsImage.ps1 : A positional parameter cannot be found that a
ccepts argument '-'.
At line:1 char:27
+ .\Install-WindowsImage.ps1 <<<<  -WIM "c:\vms\win8developer\sources\install.w
im" -Apply - Index 1 -Destination v:\
    + CategoryInfo : InvalidArgument: (Smile [Install-WindowsImage.ps1], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Install-WindowsImage.ps1

Its probably something really dumb on my part - if anyone knows let me know.  When I figure it out I'll put the answer here in case someone else has this problem.

It was dumb, I had a space between the hypen and the Index parameter.

I tried this approach and when i restart at the end of this all, win8 doesnt load. When i did manage to boot my win7 with using disk, i find that the win8 dvd not attached. I think thats the reason why win8 didnt work in first place. is that expected? am i missing any setting that would attach the vhd automatically when i restart?

The "setting" that basically does that is the boot menu entry that is generated. It does not point to a partition like it would for normal installations, but to the VHD file. The boot and OS loader then take care of attaching that VHD automatically.

Please note that of course there's a possibility of incompatibility with certain hardware and setups - after all, this is a very early version of the OS. So there's a chance that it might not run on certain systems at all.

Thanks, i managed to get it working. The problem was bitlocker. I had bitlocker turned on and the whole harddisk encrypted before installation. For win8 installation, i suspended bitlocker but looks like that wont do. I had to turn it off and decrypt the whole harddrive and it worked like a charm.

For those who don't mind preparing a bootable Windows 8 installation media (DVD, USB flash drive etc.), the following is even simpler:


That's basically the same procedure Scott Hanselman shows in the article I linked to in the beginning, just with the steps a bit shuffled. Still, thanks for sharing the link!

The benefit of the procedure shown here is that you can take the prepared VHD and reuse it even on different hardware. The manual installation in contrast means that after you're done the system is "tied" to the current hardware. You would have to repeat the procedure on every machine you want to use that kind of VHD on.

Awesome guide. Worked perfect for me, was up and running in 15 minutes. Thanks! Smile

"Win 7 bootloader cannot load win 8"
> so the thing is, after you boot into win8 once, run msconfig, and from the boot tab, switch win7 to be the default. voila! it uses the win7 bootloader now, and can book win8 also. This is much faster, because the win8 bootloader takes a long time to initialize (presumably it loads the mouse, touch and graphics drivers)

Thank you for this tip, I have to try that later (yes, the Windows 8 boot loader really takes a long time to initialize).

I was wondering if anyone knows the recovery method to fix the bcdboot problem. I put my vhd file onto my C drive (Primary Hard Drive) and used the command:

C:\Windows\system32\bcdboot.exe T:\Windows
(T was the name of my VHD drive)

When I rebooted my computer, it booted into Windows Developer Preview. The problem is that I got a sad smiley face that said:


and it restarted my computer. Now I cannot get back into Windows 7... I've tried Start-up repair and it is doing nothing. I tried using my Windows 8 install disk to do an upgrade on the existing Windows 7 I have on my computer, but it told me to start Windows 7 and then do the upgrade. I need to get back into my Windows 7 OS, so does anyone know how to recover my bcdboot file? Any help is appreciated....

and Yes.... I did proceed at my own risk. If it comes to doing a complete reinstall of Windows 7 or Windows 8, I guess I will do so. Otherwise please post your knowledge here.


Hi James. You should be able to recover that by restoring the original Windows 7 boot loader, for example by using a Windows 7 installation disc. The process is described here:


@ Mister Goodcat I did not receive your reply until after I had found a way back in. I just ran my Windows 8 DVD and chose to repair my computer from the menu. It let me boot into Windows 7 without dealing with the Windows 8 VHD installation. I then used Easy BCD to change my default OS back to Windows 7.

On another note, I have tried literally every VHD installation method I could find through Google and YouTube. All have resulted in a VHD boot initialization error. I do not understand why it is doing this. I have been reading the comments on every article/blog and it seems like no one knows how to fix this yet; although several people are encountering this error.

I got the same error,


is there a fix for it, or does anybody know why is it doing this..
should I try to reinstall windows 8 , but this time installing on a partition on my HD instead of a VHD


When I run   "PS D:\temp\win8> .\Install-WindowsImage.ps1  all I get is an error":

Get-Process : A positional parameter cannot be found that accepts argument '.\Install-WindowsImage.ps1'.
At line:1 char:3
+ PS <<<<  D:\temp\win8> .\Install-WindowsImage.ps1
    + CategoryInfo          : InvalidArgument: (Smile [Get-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand

I have made sure the file path is correct and followed Michael's comment yet still nothing happens.
I am a Powershell virgin so i've probably missed out something really obvious. Any ideas?

I'm not sure whether you tried to type out the whole line (including the "PS..." part). When you've navigated to the folder where the .ps1 file is located is in, the simplest way is to start typing the first letters of the file name (e.g. "Inst" without the quotes) and hit the tab key - PowerShell will auto-complete the command correctly for you, and you should be able to execute it without errors then.

How do you undo the boot loader entry that is done by executing the command bcdboot.exe <drive>:\Windows? Any help is appreciated! Thanks!

Run bcdboot again and point it to your Windows 7 system folder, most likely something like bcdboot.exe c:\windows - this restores the original boot loader.

Just wanted to let you know that referencing bcdboot.exe to C:\Windows actually worked. I had to reinstall the VHD again because the wireless keyboard adapter didn't get recognized the first time at the stage when devices were getting ready. I ended up reinstalling the VHD and setup. But it finally worked. Thanks for writing the article and answering the question. Appreciate your help.

As suggested by Michael I tried running Set-ExecutionPolicy RemoteSigned but it still gave errors. I resolved this by using Set-ExecutionPolicy Unrestricted. Just wanted to share this Smile


This shouldn't be necessary when you unblock the script first.

@ Mister Goodcat  I installed Windows 8 according to your procedure, however when it booted I got a bluescreen with a sad face, saying VHD_BOOT_INITIALIZATION_ERROR , do you know how I might fix this.


As you can see in the comments, some people are having this error; but I don't know a solution to it, so I cannot give more than generic advice. Follow the instructions as close as possible, and in particular make sure that you have chosen enough space for the disk.

Excellent post, I thought this should be possible rather than messing around with USB disks etc I just couldn't figure out how to make the windows 7 boot menu offer to boot windows 8 - working perfectly for me thanks very much.

Well.. If you are using BitLocker on your Computer, do not create the Windows 8 VHD on your BitLocker encrypted volume.  If all of your drives are encrypted, then you won’t be able to use Boot from VHD.  Pausing BitLocker Encryption is not a workaround.. or If you are using Windows XP as your current operating system, you cannot Boot from VHD, so this method of Dual-Booting is not available to you.  You can only (officially) use this on an existing Windows 7 or Windows 2008 R2 computer..

Pingbacks and trackbacks (10)+

Comments are closed