WIM2VHD is a new free command line tool that allows you to convert WIM (Windows Imaging Format) images to the VHD (Virtual Hard Disk) format. It is written in JScript and requires Windows 7 and the WAIK (Windows Automated Installation Kit). The VHD images are sysprepped and can be used to create virtual machines for Hyper-V, Virtual Server 2005 SP1, and Virtual PC 2007. WIM2VHD is helpful if you want to test an OS image with a virtualization tool before deploying it to physical machines.
I tried WIM2VHD with the Windows 7 Beta install.wim. Its usage is very simple. Before you use WIM2VHD, you have to set CScript as your primary script execution environment:
To convert the Windows 7 Professional volume image of a .WIM file to a VHD image you have to type:
WIM2VHD.WSF /wim:install.wim /sku:3
I assumed that install.wim is in the same folder as WIM2VHD.WSF. “/sku:3″ stands for the third volume image in the .WIM file which is Windows 7 Professional. The whole conversion process took only a couple of minutes.
I was able to boot this VHD image without problems in Virtual PC 2007. Because it is a sysprepped image, Windows setup started when I booted the virtual machine.
To create a VHD image for Hyper-V, you have to add /hyperv:true to the above command. WIM2VHD has a couple of other useful optional parameters. The most important ones are:
/disktype:<Dynamic|Fixed> The size of the VHD image is fixed or will grow dynamically.
/unattend:<unattendXmlPath> Allows you to attach an unattended.xml to automate setup when the virtual machines boot up the first time
/ref:<ref1,…,refN> Allows you to convert splited .SWM files instead of .WIM files
/passthru:<physicalDrive> Applies the WIM directly to the specified drive and makes it bootable
Unfortunately, WIM2VHD doesn’t support Vista and Server 2008 WIM images; it only works with Windows 7 and Server 2008 R2 .WIMs. I tested the WIM2VHD 6.1.7033.1 Beta.