I’m a big fan of virtual machines and especially booting from VHD natively in Windows 7 (as you might have guesed from my previous post).
On those virtual machines I run Windows 7 for the most part. Creating new VHD is pretty easy, but installing the OS and everything you need is a tedious task.
One way to solve this is to create a parent VHD with Windows 7 and then create child VHD based on this one. This is what I do for the most part, but sometimes I just need a fresh install of Windows 7.
I could off course do this by creating a blank VHD, boot into it and install Windows 7. But where’s the fun in that? Everything boring must be automated, so here’s the way to make your life just a little less boring.
- Grab your copy of Windows 7 and extract/copy the content of the install disk into a local directory (if it’s a ISO file, use a tool like 7-zip). For exemplification I’ll use ‘d:\installs\win7’ as the directory containing the extracted Win7.
- Download the ISO Windows Automated Installation Kit (AIK) for Windows 7. As the name implies, this one is needed for automating the installation of Win7.
- Extract the AIK files from the downloaded ISO file (or burn it to disk) and install it.
- Download a neat little tool called WIM2VHD (which stands for Windows Image to Virtual Hard Disk), which is the tool that will actually do the automation for us.
- Go to the ‘tools’ folder in the AIK install folder (defaults to ‘c:\program files\windows aik\tools’)
- Find the appropriate version of the ImageX (if you’re running on a 32-bit OS that would be in the ‘x86’-folder, for 64-bit it’s the ‘ia64’) and copy it to the same folder as the WIM2VHD script.
- Run ImageX to find out which SKU to install
- Then run the WIM2VHD script with the the path to the WIM and the desired SKU as params;
The script will then start making you a brand new VHD in the same folder you’re running the script from (alternatively you can add a /vhd param to the command above to specify a path to the output vhd).
Some minutes later you’ll have a (almost) pre-installed VHD with Windows 7.