Windows Insider

The ImageX X-Files

There's nothing otherworldly about Vista's OS imaging tool -- just some command-line craziness.

First it was Windows XP. Then we got Xcopy. Next, they changed Word files from .DOC to .DOCX. Now even our operating system imaging tool for Vista is ImageX. I'm seeing a pattern here. We'd better call in Mulder and Scully to investigate this one.

Seriously though, ImageX is a new free tool for rapid OS deployment. If you've been getting yourself ready for a Vista upgrade, then you've probably been looking for tools to rapidly deploy it to workstations in your environment.

Microsoft's Windows Automated Installation Kit (WAIK), downloadable from the Microsoft Web site, includes instructions for no less than six different ways to do so. Nearly all of those methods use ImageX as the tool to capture, manipulate and deploy the operating system image.

ImageX is central to nearly all of Microsoft's deployment tools. The process of using it is relatively simple, but the documentation can be somewhat daunting. If you're looking to build a simple proof-of-concept, here's what you need to do. First, create a "master computer." Install the base Vista operating system with all the patches, drivers, configurations and any applications you want to deploy onto this computer. Then use this machine to create your "master image."

For simplicity's sake, you should ensure that the hardware makeup of the master computer is similar to those upon which you plan to deploy the image. When you're finished, run C:\Windows\System 32\sysprep\sysprep.exe /generalize / shutdown to "reseal" the installation and prepare it for distribution.

Although there are lots of ways to deploy your images, if you plan on distributing them via DVD, you'll need two more tools: the Windows Preinstallation Environment (PE) 2.0 and ImageX. Both are installed to C:\ Program Files\Windows AIK as part of the WAIK.

Windows PE is the environment for all Vista installations (and any future operating systems). This eliminates the text-based setup of previous versions and significantly eases the pain of a bare-metal install. Unlike previous versions of Windows PE -- which was restricted to select enterprise-level customers -- Windows PE 2.0 is freely available to everyone. Amen to that, I say.

To capture an image of the master computer you just created, you'll need to build a bootable Windows PE CD. You'll use this CD to boot the master computer, attach to the network and collect the image. You'll also use this same CD to later deploy the image to other machines in the network.

After installing the WAIK, go to the command prompt and change to the C:\Program Files\Windows AIK\ Tools\PETools directory. Enter copype.cmd x86 c:\{target_folder} to start the process for the x86 platform.

This will copy the files needed to create the CD to your target folder. This initial process does not, however, include imagex.exe. To add it, use ImageX to mount the Windows PE ISO file you just copied: imagex.exe /mountrw c:\{target_folder}\ISO\ sources\ boot.wim 1 c:\{target folder} \mount

If you navigate to c:\{target folder}\mount after running this command, then you'll be able to interact with the directory structure of the Windows PE ISO. Once you've done this, copy imagex.exe to your mounted ISO's \Windows\System32 folder.

You'll also need to add any device drivers not natively present in your Windows PE ISO. To add a driver, unpack it and locate its .INF file. Then, use the peimg.exe tool in the WAIK folder to install it by entering peimg.exe /inf:{Path to driver's INF file} c:\{target folder}\mount\windows

You may need network card drivers so you can transfer your captured OS image to the network. If you're using VMware Workstation as your tool to test out this process, you can find VMware's network drivers in the file C:\Program Files\VMware\VMware Workstation\windows.iso. If you mount this ISO, you'll find the correct drivers in the \Program Files\VMware \VMware Tools\Drivers\vmxnet\ win2k folder.

When you're done, unmount the Windows PE ISO file and commit the changes with imagex.exe /unmount c:\{target folder}\mount /commit

The final step is to create the bootable ISO from your working files. You can use your favorite CD-burning software to do this. The WAIK also includes a nifty free tool called oscdimg.exe. To create a bootable ISO called winpe.iso using the WAIK tool, type oscdimg.exe -bc:\{target folder}\ -n -o c:\{target folder}\ISO c:\{target folder}\winpe.iso

Go Forth and Deploy
Now you can burn this image to a CD and boot the machine that contains your master image. If you've done everything right, you should see the colorful Vista background and a command window. To gather a master image called w2003sp1.wim, use the command imagex.exe /capture c: c:\w2003sp1.wim "Windows 2003 SP1 Master Image"/verify /compressmaximum. There are three compression options available, but the best option is generally to use maximum compression. Doing this means it will take longer to create the image, but less time to deploy it.

One of the other major advantages to using Windows PE is that it includes the TCP/IP network stack necessary to connect to a remote Windows share. Once you've created the master image, you can use the net use command to map a drive to a file server and transfer the master image there.

When you're ready to deploy your image to another machine, just boot that machine with your bootable CD, map a drive and use this command to install the master image: imagex.exe /apply {path to master image}\w2003 sp1.wim 1 c:

Because Windows PE is a file-based imaging tool, it requires an already-formatted drive to unpack its files. Included within the Windows PE environment is a command-line tool called DISKPART that will initialize the hard drive, create a partition and format it. After you've booted into Windows PE and before you deploy the OS image, use DISKPART to create and format a new disk and partition that fills the disk.

The command-line craziness I've outlined here is only one way to approach matters. There are plenty of other ways to script these steps to make your image deployment a drop-in-the-DVD-and-go procedure.

To make things easier, below you'll find all these commands outlined on a tidy little cheat sheet that is suitable for framing.

More Information

Your ImageX Cheat Sheet

Here are some handy crib notes you can use when you're building your ImageX proof-of-concept on an x86 machine. (If you want to call this a cheat sheet, don't tell anyone you got it from me.):

Step 1: Create the Master Image

  • Install OS, patches, applications and any specific configurations.
  • Reseal the image with:
    C:\Windows\System32\sysprep\sysprep.exe /generalize /shutdown

Step 2: Create the Bootable CD

  • Download the WAIK here.
  • Install the WAIK to:
    c:\Program Files\Windows AIK
  • Copy the starter image for the bootable CD using:
    C:\Program Files\Windows AIK\Tools\PETools\copype.cmd x86 c:\{target_folder}
  • Mount the copied starter image using:
    C:\Program Files\Windows AIK\Tools\x86\imagex.exe /mountrw c:\{target_folder}\ISO\sources\boot.wim 1 c:\{target folder}\mount
  • Copy imagex.exe from the WAIK folder to the C:\Windows\System32 folder on the mounted starter image.
  • Install any necessary device drivers using:
    C:\Program Files\Windows AIK\Tools\PETools\peimg.exe /inf:{Path to driver's INF file} c:\{target folder}\mount\windows
  • Unmount the starter image and commit the changes using:
    C:\Program Files\Windows AIK\Tools\x86\imagex.exe /unmount c:\{target folder}\mount /commit
  • Create a bootable ISO called winpe.iso from your starter image using:
    C:\Program Files\Windows AIK\Tools\PETools\oscdimg.exe -bc:\{target folder}\ -n -o c:\{target folder}\ISO c:\{target folder}\winpe.iso
  • Burn your bootable ISO to a CD.

Step 3: Boot the Master Computer and Grab the Image

  • Drop your bootable CD into the drive of your master computer and boot from that disc.
  • When the command prompt arrives, grab your master image with:
    imagex.exe /capture c: c:\w2003sp1.wim "Windows 2003 SP1 Master Image" /verify /compress maximum
  • Connect to a remote file server and transfer your image with:
    net use * \\{file server}\{share}
    copy c:\w2003sp1.wim {drive letter}

Step 4: Deploy the Image

  • Boot the target machine with your bootable machine.
  • When the command prompt arrives, deploy the master image with:
    imagex.exe /apply {path to master image}\w2003sp1.wim 1 c:

- G.S.

About the Author

Greg Shields is a senior partner and principal technologist with Concentrated Technology. He also serves as a contributing editor and columnist for TechNet Magazine and Redmond magazine, and is a highly sought-after and top-ranked speaker for live and recorded events. Greg can be found at numerous IT conferences such as TechEd, MMS and VMworld, among others, and has served as conference chair for 1105 Media’s TechMentor Conference since 2005. Greg has been a multiple recipient of both the Microsoft Most Valuable Professional and VMware vExpert award.

comments powered by Disqus

Reader Comments:

Tue, Sep 21, 2010 Justin

Does anybody know of a way off applying the wim file via imagex /apply and then getting it to reboot automatically after it has applied the wim image???? Currently it applies the wim image and then you have t go back to the PC and type exit to reboot it and let the unattend part run through. Thanks.

Tue, Mar 18, 2008 Will Anonymous

I assume the c: part of the capture command designates capturing the c: drive. Is there a way to capure the entire drive onto the image, for example utility partition, c, d, and e?

Sun, Jun 3, 2007 Dave M AUS.

From my initial use of WDS, ImageX and the related packages, a huge thumbs up to MS for providing some usefull tools to deploy thier products properly.

I now have a single OS Image that runs across my 300 node desktop environment, consisting of atleast 5 different hardware platforms, wihtout the need to engineer a monster OS image full of drivers.

My current image is 1.6Gb and as yet has not failed to work on any platform i throw it at.

Typical turn around time from a baremetal / failed os system, to a fully AD domain joined and ready to use desktop full of applications is around ~13minutes.

top stuff. I can't speak highly enough of imagex and its supporting technologies!.

Personally i have held a tainted view of many MS products, but the WDS and ImageX tools have certainly got me using them in a far more efficent way than any other prodduct out there for deploying MS Operating systems.

Well done MS!.

Wed, May 9, 2007 Matthew Monterey

Thanks for the straight forward insight on how to use imageX. Microsoft has done a terrific job of making these tools and procedures very confusing. Since there is several ways to use these tools and the documentation pretty much just shows syntax and not really much hints on how everyhting interacts.

I personally have spent several days hunting for answers and rereading the help files looking for clues. Any really the most help has been from articles like this that save the day in the end.

Part of my problem was that I was hoping to uses these tools: imageX, WDS, Deployment tool kit with XP as well as planning for Vista. And of course, this only adds to the challenge. Like you said above, ImageX is central and I have found it to quite useful for capturing XP machines as well :)

Personally, I think the documentation is cryptic to possibly to prevent people from using it on older systems and push more for the New Vista and longhorn platforms. With WDS service windows vista deployment is pretty straight forward with these tools. The commands then become more of the details that you may be looking for at this point.

Even still, it would be much better if these tools were not such a mystery and the was more information about how they are meant to work together.

Tue, Mar 27, 2007 Kurt Tempe, AZ

I attended a Windows Vista Technical Assistance Program (TAP) training session in Redmond a while back. They talked about the same thing over a three day period. I learned more from this article than I did in the entire three days at the TAP. Thank you for carefully explaining this concept.

Wed, Mar 7, 2007 Doug Packer UK

Great article!
Thanks, Doug Packer
ps can't find the cheat sheet.

Add Your Comment Now:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Please type the letters/numbers you see above

Redmond Tech Watch

Sign up for our newsletter.

I agree to this site's Privacy Policy.