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}\etfsboot.com -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}\etfsboot.com -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 Author Evangelist with PluralSight, and is a globally-recognized expert on systems management, virtualization, and cloud technologies. A multiple-year recipient of the Microsoft MVP, VMware vExpert, and Citrix CTP awards, Greg is a contributing editor for Redmond Magazine and Virtualization Review Magazine, and is a frequent speaker at IT conferences worldwide. Reach him on Twitter at @concentratedgreg.

Featured

comments powered by Disqus

Subscribe on YouTube

Upcoming Training Events

0 AM
Live! 360 Orlando
November 17-22, 2024
TechMentor @ Microsoft HQ
August 11-15, 2025