Search Wiki:

Latest News

  • WIM2VHD Release Candidate is now available! There are lots of fixes and enhancements in this build, so be sure to upgrade today!
  • If you're using Windows 7/R2 RC, please upgrade to this version of WIM2VHD. You will also need to upgrade to the RC version of the Windows AIK or OPK.

Table of Contents

Introduction
Requirements
Usage
Frequently Asked Questions
Examples
Videos
Links

Introduction


The Windows(R) Image to Virtual Hard Disk (WIM2VHD) command-line tool allows you to create sysprepped VHD images from any Windows 7 installation source. VHDs created by WIM2VHD will boot directly to the Out Of Box Experience, ready for your first-use customizations. You can also automate the OOBE by supplying your own unattend.xml file, making the possibilities limitless.

Fresh squeezed, organically grown, free-range VHDs - just like Mom used to make - that work with Virtual PC, Virtual Server, Microsoft Hyper-V, and Windows 7's new Native VHD-Boot functionality!

Requirements


  • A computer running one of the following Windows operating systems:
    • Windows 7 Beta or RC
    • Windows Server 2008 R2 Beta or RC
    • Windows Server 2008 with Hyper-V RTM enabled (x64 only)
  • The Windows 7 RC Automated Installation Kit (AIK) or Windows OEM Pre-Installation Kit (OPK) installed.
  • A Windows 7 or Windows Server 2008 R2 installation source, or another Windows image captured to a .WIM file.

Usage


Usage: WIM2VHD.WSF /wim:<wimPath> /sku:<sku>
[/vhd:<vhdPath>] [/size:<vhdSizeInMb>] [/disktype:<dynamic|fixed>]
[/unattend:<unattendXmlPath>] [/qfe:<qfe1,...,qfeN>]
[/ref:<ref1,...,refN] [/dbg:<args>] [/copylocal:<localFolder>]
[/passthru:<physicalDrive>] [/signdisk:<true|false>]
[/mergefolder:<folderToMerge>]
 
Required parameters:
 
  /wim:<wimPath>
 
    The path of the WIM file to use when creating the VHD.  For example:
    X:\sources\install.wim
 
    Where X: is the drive letter of your DVD ROM drive.
 
  /sku:<skuName>|<skuIndex>
 
    The SKU within the WIM to use when creating the VHD (e.g. "ServerStandard",
    "ServerDatacenterCore", "2", etc.).  This value can either be passed as a
    SKU name (typically the easiest method) or as a SKU index (which requires
    you to have manually inspected the WIM with a tool like IMAGEX.EXE).
 
Optional parameters:
 
  /vhd:<vhdPath>
 
    The path and name of the VHD to be created.  If a file with this name
    already exists, it will be overwritten.  If no VHD is specified, a VHD will
    be created in the current folder with a name in the following format:
    <Major>.<Minor>.<Build>.<Rev>.<Arch>.<Branch>.<Timestamp>.<SKU>.<Lang>.vhd
    ex:
       6.1.7100.0.x86fre.winmain_win7rc.090421-1700.Ultimate.en-us.vhd
 
    NOTE: If the language cannot be determined from the WIM, no <Lang> block
    will be included in the VHD name.
 
  /size:<vhdSizeInMb>
 
    For Fixed disks, this is the size in MB of the VHD that will be created.
    For Dynamic disks, this is the maximum size in MB that the VHD can grow to
    as additional space is required.
    If unspecified, a default value of 40960 MB (40 GB) will be used.
 
  /disktype:<Dynamic|Fixed>
 
    Specifies what kind of VHD should be created: Dynamic or Fixed.
    A Fixed disk allocates all of the necessary disk space for the VHD upon
    creation.  A Dynamic disk only allocates the space required by files in
    the VHD at any given time, and will grow as more space is required.
    The default value is Dynamic.
 
  /unattend:<unattendXmlPath>
 
    The path to an unattend.xml file that will be used to automate the OOBE
    portion of Windows setup the first time the VHD is booted.
 
  /qfe:<qfe1,...,qfeN>
 
    A comma-separated list of QFEs to apply to the VHD after the WIM is
    applied.  QFEs must be in the .MSU file format, which is the default
    QFE format for Windows 7.  They can also be provided in a .CAB format
    if you'd prefer to extract the .CABs from the .MSU files.
 
    To extract a CAB from an .MSU, use the following command:
 
    expand -f:win*.cab <.MSU file> <location to extract to>
 
  /ref:<ref1,...,refN>
 
    A comma-separated list of WIM pieces to apply to the VHD.
    A "WIM piece" is the result of a Split WIM, and typically has a .SWM
    file extension.  The first piece of the Split WIM should be specified with
    the /WIM switch. Subsequent pieces should be specified with /REF.
      ex: WIM2VHD.WSF /WIM:C:\split.swm /REF:C:\split2.swm,c:\split3.swm
 
    See IMAGEX.EXE /SPLIT /? for more information.
 
  /dbg:<protocol>,<port/channel/target>[,<baudrate>]
 
    Configures debugging in the OS on the VHD.
    examples:
      /dbg:serial,1,115200 - configures serial debugging on COM1 at 115200bps
      /dbg:1394,10 - configures 1394 debugging on channel 10
      /dbg:usb,debugging - configures USB debugging with the target DEBUGGING
 
  /copylocal:<localFolder>
 
    Copies all of the files necessary to run WIM2VHD.WSF to localFolder,
    eliminating the need to install the Windows AIK or OPK.  This does not
    include any WIM files, just the binaries that WIM2VHD.WSF depends on.
    After this operating completes, run WIM2VHD.WSF from localFolder.
    If this switch is specified, no VHD will be created.
 
  /passthru:<physicalDrive>
 
    Applies the WIM directly to the specified drive and makes it bootable.
    NOTE: The partition on the disk must be marked as ACTIVE in order to boot
    successfully. This action is NOT performed by WIM2VHD.WSF.
 
  /signdisk:<true|false>
 
    Specifies whether or not WIM2VHD.WSF should leave a signature on the VHD
    that indicates what version of WIM2VHD.WSF created the VHD, and the date
    of creation.  The signature will be located at <VHD>:\Windows\WIM2VHD.TXT.
    The default value is "true".
 
  /mergefolder:<folderToMerge>
 
    Copies the contents of folderToMerge to the root directory of the VHD.
    This includes all subfiles and subfolders.  Any files that already exist on
    the VHD will be overwritten.

Known Issues

  • Some custom .WIM files may not work properly. Please file a bug using the Issue Tracker listing the tool that was used to create the .WIM, and the output from IMAGEX.EXE /info <your .WIM file> if you encounter problems.

Frequently Asked Questions


Q: What is a .WIM file?
A: According to Wikipedia, a .WIM file "is a file-based disk image format. It was developed by Microsoft to deploy its latest Windows operating system releases, Windows Vista and Windows Server 2008, which use it as part of their standard installation procedure. It works equally well with legacy versions of Windows however, and is used as part of Windows Fundamentals for Legacy PCs."

Q: What is a .VHD file?
A: According to Wikipedia, a .VHD file is "a file format containing the complete contents and structure representing a Hard Disk Drive, and is used to store virtual operating systems and their associated programs in a single file by various virtualization programs or a virtual machine."

Q: How does the conversion process work?
A: During the conversion, a .VHD file is created and mounted as a physical drive on the technician system. An image from the .WIM file is then applied to the .VHD, and tweaked to make the image bootable in a virtual machine, or on a physical system. This process is documented in the Windows 7 Beta Automated Installation Kit. WIM2VHD is an example of one possible way to automate that process.

Q: Can I use code from WIM2VHD in my own scripts or products?
A: Please read the Microsoft Public License (Ms-PL) for information on what is and is not allowed.

Q: I've read your code and found some problems. It could be much more efficient by doing...
A: If you've discovered a bug, please file an issue using the Issue Tracker on this website. If you've found code that you don't think is efficient, you can file an issue on that, too, but it may not get fixed. WIM2VHD is not meant to be an example of how to write the best JScript, it is an example of how to automate the process for creating .VHDs from .WIM files.

Q: If I find a bug and file an issue report, how quickly will it get fixed?
A: I can't make any promises on how quickly fixes can be made, or whether a given issue will ever be resolved. If you're being blocked by an issue, and you need an immediate fix, the best thing for you to do is to fix your copy of WIM2VHD on your own, and make a good case for getting the bug fixed in the mainline build.

Q: Can I use WIM2VHD to create .VHDs for Windows Vista and Windows Server 2008?
A: No. This process is only supported for Windows 7 and Windows Server 2008 R2.

Q: Can I use my own custom .WIM files?
A: I think so. I've tested WIM2VHD with a few different tools that can create .WIM files, but I'm sure I've missed some. Please see the Known Issues section for instructions on how to report issues with custom .WIM files.

Q: Is this tool supported by Microsoft?
A: No. The underlying process, as documented in the AIK and OPK, is supported by Microsoft, but WIM2VHD is not.

Q: Who owns this tool?
A: I created this tool (with the help of some other folks), but I did so on Microsoft's time, so technically Microsoft owns it. That said, reading the Microsoft Public License (Ms-PL) will give you more insight into this sort of thing.

Q: Can I use this tool to create .VMDK files for use with VMWare?
A: Yes and no. There is no support in this tool for creating and mounting .VMDK files, which is a necessary step. Assuming that .VMDK files can be mounted as a physical drive on a Windows computer, then you should be able to modify WIM2VHD to use .VMDK files, or you can use the /passthru switch to use a .VMDK that's already been mounted.

Q: Can I configure the OS inside the .VHD?
A: You can tell WIM2VHD to add an unattend.xml file to the .VHD, which can be used to do some system configuration.

Q: Can I copy files into the VHD?
A: You can do this manually, but there is currently no mechanism to do this with WIM2VHD. If you think there should be, vote for this issue.

Q: Are there examples on how to use WIM2VHD?
A: Look down. :) I'm also working on a series of videos that will explain how to use WIM2VHD.

Examples


Create a Windows Server 2008 R2 Server Standard Core VHD, named foo.vhd
CSCRIPT WIM2VHD.WSF /WIM:X:\sources\install.wim /SKU:SERVERSTANDARDCORE /VHD:C:\foo.vhd

Create a Windows Server 2008 R2 Server Standard VHD with an automatically generated name
CSCRIPT WIM2VHD.WSF /WIM:X:\sources\install.wim /SKU:SERVERSTANDARD

Create a Windows 7 Home Premium VHD with an automated setup answer file
CSCRIPT WIM2VHD.WSF /WIM:X:\sources\install.wim /SKU:HOMEPREMIUM /UNATTEND:C:\stuff\unattend.xml

Apply the first image in a custom WIM to a VHD named custom.vhd
CSCRIPT WIM2VHD.WSF /WIM:C:\stuff\custom.wim /SKU:1 /VHD:C:\custom.vhd

Create a Windows 7 Ultimate VHD, and copy a folder structure to the root of the drive
CSCRIPT WIM2VHD.WSF /WIM:X:\sources\install.wim /SKU:ULTIMATE /MERGEFOLDER:C:\Deploy\VHDROOT

Create a Windows 7 Ultimate VHD without leaving a signature file on the disk
CSCRIPT WIM2VHD.WSF /WIM:X:\sources\install.wim /SKU:ULTIMATE /SIGNDISK:FALSE

Create a Windows 7 Ultimate VHD and display the output in verbose/trace mode
CSCRIPT WIM2VHD.WSF /WIM:X:\sources\install.wim /SKU:ULTIMATE /TRACE:TRUE

Copy all of the binaries that WIM2VHD.WSF requires to C:\WIM2VHD, so that it can be easily moved from one machine to another
CSCRIPT WIM2VHD.WSF /WIM:X:\sources\install.wim /COPYLOCAL:C:\WIM2VHD

Videos


Introduction

The Virtualization Nation Podcast - Episode 2: WIM2VHD Release Candidate
Note: This video says that the RC version is 7100.1. After this was filmed, I found and fixed a few bugs, so I bumped the version up to 7100.2
More videos coming soon...

Links


Virtual Varia Blog - That's my blog, and I'll be talking about WIM2VHD pretty frequently.
What's New in Virtual Hard Disks
Frequently Asked Questions: Virtual Hard Disks
Windows 7 Deployment
Last edited May 6 2009 at 4:09 AM  by mikekol, version 18
Comments
glenmcafeee wrote  Apr 7 2010 at 6:44 PM  
I have downloaded the latest win2vhs.wsf and it failed to work at line 2334 column 23. If I look at the wsf file it abruptly ends with the line: if (null != argum
Where is the full file?

Updating...
Page view tracker