I’ve been using SysPrep to create a bootable WIn7 VHD as per this great set of blog posts by Scott Hanselman.
Step-By-Step: Turning a Windows 7 DVD or ISO into a Bootable VHD Virtual Machine
Less Virtual, More Machine - Windows 7 and the magic of Boot to VHD
Almost everything in those two posts was new to me and the last thing I have time for is to do all of this sys admin stuff. But I needed the performance benefit of the VHD while working with VS2010 Betas.
Naturally I ran into all kinds of problems that didn’t dare threaten an uber-geek like Scott.I won’t bother repeating the information in Scott’s post but am adding some extra info that I learned along the way.
What is SysPrep anyway
SysPrep is an internal WIndows utility that strips the hardware info out of a machine image so you can boot it up on another system. Sys admins at large companies use this all of the time. It allows them to create a base system that every user in teh company should have with all of the appropriate software installed and network settings, etc. When they buy a new machine then can just install the prepared image onto the new computer and hit the ground running.
The first time the image is booted on the new machine it will set itself up for the current machine’s configuration.
You need to run Sysprep on a running O/S, so in effect you are telling it to sysprep itself. I have done this with an existing VPC and also a VHD that I’ve been using as a bootable VHD. Both times I ran into many delayed hours.
Starting from an existing VPC
Although Scott shows how to start from scratch and install Windows 7 onto the VHD, I never went down this path. Originally, I was having a problem with my DVD writer so I was unable to create a bootable WIndows 7 install disk. I cheated and grabbed a VPC image onto which I had already installed Windows 7. To sysprep a VPC image, you need to start up the VPC and run sysprep from within there. (Definitely want to make a copy of the image first!) A VPC image uses special drivers. Sysprep removes all of that knowledge and allows you to reuse the VHD as bootable image that will use the computer’s real hardware.
Starting from an existing VHD boot disk
I’ve been working with my first bootable VHD for a few weeks now, but I’m going on a trip and need it on my laptop. One of the downsides Scott points out is that this is not a portable solution. That’s for sure. My VHD was stuck on my big pc drive and I needed to get it onto the other machine. The goal with this particular task was to bring over the whole thing intact with VS2010 & SQL Server and a few other applications that I’ve installed since I copied that original VPC image that had nothing but the O/S installed on it.
Therefore, after making a copy of this VHD file (onto another drive while I was booted into my regular OS), I booted into my existing VHD to sysprep it.
Once I’m booted into the target O/S to SysPrep
Sysprep itself is simple and only takes about 10 minutes to run, but it may not go as planned. Especially if you are *me*.
Start by browsing to c:\windows\system32\sysprep
Sysprep.exe is a gui and I’ve been running it as an admin.
Be sure you have these options:
- Choose the default target that will create an image which gives you an out of box experience (i.e. that will set itself up based on the machine it’s running on when you first run it)
- Check generalize
- Check Shutdown. You want it to shutdown when it’s done, not restart. That way you can make copies of the VHD file *before* it has learned about another computer.
Then let ‘er rip.
Issues I have encountered with SysPrep:
Check the sysprep’s setuperr.log in the sysprep\panther directory for a clue about errors.
1) SysPrep may not even run. It will wait about a minute then give the error: "AN ERROR OCCURED WHILE QUERYING FOR PENDING OPERATIONS"
There were only FOUR results when I did a web search for this error and I had to have faith in a suggested registry fix which thankfully worked. I modified the RegistrySizeLimit setting as per the suggestion by dlynch in this TechNet forum thread.
The setuperr info wasn’t very informative for that one: [0x0f00b0] SYSPRP WinMain: Failed to query pending CBS operations; hr = 0x80080005
2) Fatal Error – I got TWO of these.
a)One problem might be about licensing and has the term REARM in it.
This MS Support doc shows how to get around that.
I would never have gotten past this problem if Steve Andrews hadn't been at my house. He did not fear the sysprep like I did and got to the core of this problem for me.
b) Another problem is related to Digital Rights Management.
SYSPRP LaunchDll:Failure occurred while executing 'drmv2clt.dll,Sysprep
Thankfully I found the solution in this forum thread . Ending the process for wmpnetwk.exe did the trick for me.
Next Step
Now I have the sysprepped VHD file. If you were using a VPC, then after the O/S shuts down you can get to the VHD file easily. If you were using an existing boot VHD, then you need to boot into the other OS on your computer so that you can access the VHD file. I copied the VHD file onto another computer where I want to use it. Pay attention to the notes in Scott’s blog posts about drive space. While the VHD file is small it needs to expand when it’s running. So if you are on a drive that doesn’t have enough free space on it, you won’t be able to boot to the VHD. I realize my brand spanking new 120GB drive on my laptop is going to limit me. I created an 80 GB partition to run the VHD on which was more than I needed but I’ll end up putting other stuff on that partition anyway. The first 40GB are for my regular system.
Booting to the VHD in Windows 7
Now it’s time to go to Scott’s blog,Less Virtual, More Machine - Windows 7 and the magic of Boot to VHD, to get the well-laid out instructions to use bcdedit to force your win7 machine to allow you to boot to the VHD as an alternative at boot time.
When you reboot and select the VHD, the first time you use it it will need to do some setup because the sysprep removed all of the registry and settings information that were specific to the original computer it was on.
It will ask you to create a user log in. I’m using a VHD that already has a user with all of the appropriate settings, so I just create a new fake user. After logging into the new user, I just switched back to my original login and voila there was my desktop.
So naturally I spent way more time than I had planned on this because of the problems I ran into. If you are lucky, Scott’s post will do the trick. But if you do have some problems, hopefully this will provide some additional help.




