Before you start
Objectives: learn how to capture Windows 7 image using ImageX tool.
Prerequisites: we have to have WinPE media prepared, which includes ImageX tool which we will use to capture Windows image. Our reference computer should already be installed and ready to be captured.
Key terms: image, sysprep, capture, partition, imagex, winpe, diskpart, reference
Prepare the Reference System (Sysprep)
Before we capture our reference computer image, we should run Sysprep tool on it. Sysprep.exeprepares the Windows image for capture by cleaning up various user and computer specific settings, as well as log files. Let’s say that in our case the reference installation is complete and ready to be imaged. Now we will use the sysprep command with the /generalize option to remove hardware-specific information from the Windows installation, and the /oobe option to configure the computer to boot to Windows Welcome upon the next restart. You can run the Sysprep tool from a command prompt by typing: ‘c:\windows\system32\sysprep\sysprep.exe /oobe /generalize /shutdownIn‘. Alternatively, if we run the Sysprep GUI in audit mode, we can use these options:
- Enter System Out Of Box Experience (OOBE) (from the System Cleanup Action list)
- Check the Generalize option
- Shutdown (from the Shutdown Options list)
- Click OK
Our referenced computer is now prepared and turned off. Now we need to boot that computer using WInPE CD which we created earlier. WinPE runs from the command line. It boots the system with a limited version of Windows 7, which provides disk access and limited networking support. It has two different architectures: a 32-bit version and a 64-bit version. The version must match the intended installation version of Windows 7. Once we enter WinPE we can go to the root folder so that we can run ImageX which we copied earlier.
Image 185.1 – WinPE Root Folder
In WinPE we have access to our network. This is great because we can transfer images to the shared folder on our network. In our case we have a shared folder named ‘shared-images’ on computer named ‘nx7300’. We will map a network drive to our shared folder using a net use command: ‘net use z: \\nx7300\shared-images‘.
Image 185.2 – Net Use Command
Our shared folder is password protected, so we have to provide our credentials. Notice that we had to provide the computer name in front of our user name. If we had a domain account, we would provide a domain name instead of computer name.
Image 185.3 – Net Use Completed Successfully
The shared folder is now mounted as our Z drive. Before we use ImageX command we have to see on which partition our Windows 7 installation is on. To do that we can use diskpart command.
Image 185.4 – Diskpart Command
Once in diskpart we can use a ‘list disk‘ command.
Image 185.5 – List Disk Command
In our case we only have one disk. Let’s select it and list partitions on that disk. To select it enter the ‘select disk 0‘ command.
Image 185.6 – Selected Disk
To list partitions on disk enter the ‘list partition‘ command.
Image 185.7 – List Partition Command
We do that because we might have multiple disks with multiple boot partitions. We have to capture the proper image. In our case we only have one partition. In Windows 7, if we use BitLocker, we will always have at least two partitions when looking disks with diskpart. The first partition, size of 100MB would be BitLocker partition. Letters for partitions in WinPE can be different from those in regular Windows 7. While running Windows PE on a machine with BitLocker, the first logical partition is already used as drive C: (i.e., Partition 1) and does not contain the reference computer’s Windows 7 installation. We can always check the content of our partitions.
Image 185.8 – Check Partition Content
Let’s go back to our WinPE disk (x: drive) and run the ImageX command to capture our Windows 7 image. ImageX is a command line tool that creates an image from a reference computer. We will use the command ‘imagex /capture c: z:\win7.wim “Win7 Image” /compress fast /verify‘. The /capturemeans that we are capturing Windows image, c: is the drive we are capturing, z:\win7.wim will be the exported file on the z: drive that we mapped to, “Win7 Image” will be the image name, /compress fastwill perform fast compression, and we will also verify the image (/verify switch).
Image 185.9 – ImageX Command
Image 185.10 – ImageX Scanning…
ImageX will first scan all files that are on our C: partition and then create an image out of all that files. Once the process is complete we will have win7.wim file which we can deploy to other computers, or which we can use to perform recovery if our computer brakes down. If we intend to transfer that image to different computer, we must run Sysprep on the reference computer before we capture the image.
If we intend to transfer captured image to different computer, we must run Sysprep on the reference computer before we capture the image. Once in WinPE, we can mount shared folder using Net Use command, which we will then use to store our captured image. Before capturing we also have to check which partition exactly contains Windows 7 installation files using diskpart command.
Commands that are mentioned in this article
- c:\windows\system32\sysprep\sysprep.exe /oobe /generalize /shutdown – run sysprep with the /generalize option to remove hardware-specific information from the Windows installation, and the /oobe option to configure the computer to boot to Windows Welcome upon the next restart
Capture image using WinPE:
- net use z: \\nx7300\shared-images – map a network drive to our shared folder using a net use command
- diskpart – used to check on which partition our Windows 7 installation is on
- list disk – used inside of diskpart to list all disks on our computer
- select disk 0 – used inside of diskpart to select disk 0
- list partition – used inside of diskpart to list all partitions on selected disk
- imagex /capture c: z:\win7.wim “Win7 Image” /compress fast /verify – commend which we used to capture Windows 7 image to the z:\win7.wim image, with the name “Win7 Image”, using fast compression. The image will be verified.
Paths that are mentioned in this article
- c:\windows\system32\sysprep\sysprep.exe – location of the Sysprep tool
- \\nx7300\shared-images – UNC path to our shared folder in which we stored captured image