By Val Bakh
2.3.3 Using ImageX
ImageX is a command-line tool that can create, apply, and manage WIM images. Three architecture-specific versions of ImageX—for 32-bit computers (x86), for regular 64-bit computers (x64 or amd64), and for Itanium-based computers (ia64)—are available in Windows Automated Installation Kit (WAIK). In previous blog posts, we have discussed how you can use ImageX to capture a generalized image of a Windows 7 installation on a reference computer. Now let’s talk about deploying that image to a target computer.
Windows deployment in an enterprise environment is an enormous subject. Depending on your goals, the scale of the deployment, and the available resources, there are too many methods and technologies to even mention in a short Tips & Tricks article. Therefore, we’ll focus on only a few details of the main underlying process.
Whichever way you look at it, ultimately, installing Windows 7 always boils down to applying a WIM image to a destination disk volume on a target computer. A standard WIM image of Windows 7 is packaged in a file named install.wim, which is located in the \sources folder on a Windows 7 installation DVD. By generalizing and then capturing a custom installation of Windows 7 on a reference computer, you can create a custom WIM image. If you want an automated deployment, you can prepare all the necessary settings and instructions in an answer file and initiate an installation by running the Setup.exe application with appropriate parameters from a command line.
To better illustrate the deployment mechanics, we’ll go through a manual process. Suppose you have a single custom WIM image in a file named Custom.wim, which is located on a network share, on a USB flash drive (UFD), or anywhere else where a target computer can access it. First, boot the target computer into WinPE and open a Command Prompt window. Then use the Diskpart command-line tool to create and format a system volume, a boot volume, and any additional volumes if you need them. Assign drive letters to the volumes, and mark the system volume as active. The drive letters can be arbitrary; when Windows 7 starts, it will remove the drive letter from the system volume, assign the letter C to the boot volume, and assign letters in alphabetical order, starting with D, to the other volumes if you created them. If you need network access (ImageX and the WIM image that you need to install might be on another computer), run the following commands:
net use DriveLetter: \\ServerName\ShareName /user:Domain\UserName password
The first command will initialize the network, and the second command will map a drive letter to a network share. WinPE has never asked you for any credentials, and your computer currently does not belong to any domains. Therefore, you need to provide an appropriate user name and password to access the share.
Suppose the system volume is currently C and the boot volume is D. Also suppose that ImageX is available on the Z drive and the Custom.wim file resides on the Y drive. To install the WIM image on the boot volume, run the following command:
z:\imagex /apply y:\custom.wim 1 d:
The 1 in the command is the index of the WIM image. Generally, a .wim file can contain multiple images. Each image in the file is assigned an index, which is simply an ordinal number. The index in the command is 1 because we agreed earlier that the Custom.wim file contains a single image. If you don’t know what is inside a .wim file, you can find out which images it contains and locate their indexes by using the Deployment Image Servicing and Management (DISM) tool. You can run the following command directly from the currently open Command Prompt window in WinPE:
dism /get-wiminfo /wimfile:WIMFilePath\WIMFileName.wim
After you have installed the image on the boot volume, you need to configure the system volume so that the computer can boot from it. All the necessary code is available in the \Windows\system32\config folder in the Windows 7 image that you have just installed on the boot volume, which is currently the D drive. To configure the system volume, run the following command:
If you have created any additional volumes, now may be the time to populate them with something. Of course, you can always copy the data later, when you are already running Windows 7. But in some situations, you may want to have that data already in place when Windows 7 starts for the first time. Depending on what you want to put on those volumes, you can Xcopy the necessary data from wherever it resides at the moment or you can apply additional WIM images if the data is stored in WIM images. A WIM image is just a nicely packaged copy of a disk volume. So it doesn’t always have to be a captured installation of Windows 7; it can be just about anything.
Finally, reboot the computer, and after a few minutes of initialization, the new Windows 7 instance will be ready for your first logon.
Doesn’t this deployment process remind you of something? Like restoring a backup, maybe? Starting with a blank computer and ending up with a fully functional installation and, perhaps, even with additional data? What if you captured everything from a normal, properly configured and functioning computer and kept it someplace safe in case the computer at some point becomes nonfunctional or otherwise undergoes an undesirable change? Although the native backup application in Windows 7 has regained some of the features that were mysteriously missing from Windows Vista, it is still much too automated and not very flexible. And the backups are so huge…. And there are so many pesky details to remember about how, when, and where they can be made, maintained, and restored….
Although ImageX is not intended as a substitute for a backup/restore application, in some situations it might be very convenient to use it exactly for that purpose. WIM images can be half the size of the corresponding backups produced by using Windows Backup. WIM images can be cut into pieces small enough to fit onto DVDs or even CDs. WIM images can be mounted to an active file system and can be reviewed and even manipulated in Windows Explorer. WIM images can be easily captured and just as easily restored to a new hard disk and even to a different computer. You get the picture….