Tuesday, April 03, 2012

How to convert a WIM file into a VHD

So you've been rolling out your Windows 7 image with all the software on, that you spent ages testing. Then you realise that you want to run this on a virtual machine, except you've spent ages setting this one up and testing and you don't want to have to do it all again. Well Microsoft have thought of this and provide a WIM to VHD convertor.

Before you go any further, I've had great success with this and never once had a problem. This doesn't mean you wont, so probably best to test with a copy of the original WIM file.

With that said, here's how you do it.

First, download and install the AIK from Microsoft. You can download it from here.

Now download the WIM2VHD Convertor. All it is is a WSF file.

Now, copy the folder that your custom WIM image is in (eg. browse to your deployment server and open \DeploymentShare\Operating Systems\ and copy the entire folder) and place it on the windows 7 PC.



Now on the windows 7 PC, run a command prompt as Administrator.



Browse to the folder where the WIM2VHD script is (WIM2VHD.wsf) and run the following command.

Cscript WIM2VHD.WSF /WIM:C:\source\custom.wim /SKU:Enterprise /VHD:C:\customwim.vhd

----------------------------------------------------------------------------------------------

The /WIM:C:\source folder is where your .wim image is stored. This is changed depending on the name of the file and where it is.”



“The /SKU:Enterprise section should be changed depending on what kind of windows 7 operating system the image is based on”



“The /VHD:C:\customwim.vhd part can be changed to where you want to save the new vhd file to. Its name can be changed to”

-----------------------------------------------------------------------------------------------





This is all once sentence; only press enter at the end.



This should run the script and create you a VHD file.

4 comments:

Bernard said...

...I want to add this can be tricky but possible with doing this under Vista or Windows 7. You would need to create a virtual machine in VirtualBox that uses 2 VHD disks: one to restore from (mount this with Win7 in Disk Mgmt, copy WIM files here) and one to "restore to" within the VM (as big or bigger than the original disk). Have the VirtualBox VM boot from the WinPE CDROM with ImageX, restore from the WIM to the big VHD. Then save the big VHD as the converted file. Hope this helps someone.

Harjeet said...

Failing with error:-
INFO: Making the VHD bootable with BCDBoot...
WARNING: Command "C:\Program Files\Windows AIK\Tools\amd64\bcdboot.exe C:\Users\ADMINI~1.ADM\AppData\Local\Temp\WIM2VHD.WSF\EA7A01CE-2A34-4B16-BE32-E9C9EACC231D\mount\windows /l en-US /s \??\Volume{49c2cb3e-c2e8-11e2-9421-00271371432c}" exited with error code 193
WARNING: Failed to configure the VHD boot loader with the language en-US.
Falling back to en-us...
*******************************************************************************
Error: 0: Command "C:\Program Files\Windows AIK\Tools\amd64\bcdboot.exe C:\Users\ADMINI~1.ADM\AppData\Local\Temp\WIM2VHD.WSF\EA7A01CE-2A34-4B16-BE32-E9C9EACC231D\mount\windows /l en-us /s \??\Volume{49c2cb3e-c2e8-11e2-9421-00271371432c}" exited with error code 193
*******************************************************************************
INFO: Unmounting the VHD due to error...
WARNING: In order to help resolve the issue, temporary files have
not been deleted. They are in:
C:\Users\ADMINI~1.ADM\AppData\Local\Temp\WIM2VHD.WSF\EA7A01CE-2A34-4B16-BE32-E9C9EACC231D
Summary: Errors: 1, Warnings: 3, Successes: 0
INFO: Done.

Unknown said...

Powerful VHD Data Recovery is an ultimate utility to get back deleted or lost data from Microsoft (VHD), Oracle (VDI) and VMware (VMDK) image files.

See full details at: http://www.filesrecoverytools.com/vhd-data-recovery.html

paulspmiths said...

VHD Data Recovery software is an advanced and highly efficient VHD repair tool that offers paramount efficiency in repairing the corrupt, damaged and inaccessible VHD files. This software handles all issues related to accessibility or use of Windows Hyper-V VHD files easily.

Fastest technology that people going to adopt it very frequently for high efficiency.

For more info: http://www.undeletepcfiles.com/vhd-data-recovery-tool.html