1st, download and install the Windows Automated Installation Kit for Windows 7.
Start, Open Programs, expand Windows AIK, highlight “Deployment Tools Command Prompt”. Right click and "Run As Administrator".
Create a new folder at the root of C:\ We need a place to extract and mount the install.wim and the winRE.wim from the install.wim. We need a root directory and two sub directories. Some names we can use: win7pe, win7re, win7_64, etc.
Create two new folders; mount and mountre in the root of the folder above.
We need the installation DVD. I am using the 64 bit version of Windows 7 Ultimate. It really doesn't matter so long as the architecture bit size is followed. The recovery environment is available in the install.wim image, and what we are now going to do is extract it from the install.wim. The install.wim file is huge; almost 3 GBs, so the copy will take 8-10 minutes.
copy d:\sources\install.wim c:\win7pe (where d:\ is the drive letter of your DVD device)
When the file completes its copying, then we can mount it and extract the recovery environment wim.
We’ll use DISM to do so, rather than imagex.exe If you check the Microsoft TechNet article on making a recovery environment iso, it uses imagex.exe. Use the dism tool because it is designed to be the replacement for this feature (mounting, etc). DISM is superior to imagex and is several tools rolled into one.
dism /mount-wim /wimfile:c:\win7pe\install.wim /index:1 /mountdir:c:\win7pe\mount
This will mount the install.wim into the mount directory. We can see the file format in Windows Explorer. The winRE.wim is located in \windows\system32\recovery. This is the file we’re after and why we’ve used the installation DVD in the first place. In fact, after we copy out this file we’ll discard the install.wim.
copy c:\win7pe\mount\windows\system32\recovery\winre.wim c:\win7pe
Now that we done so successfully, we can unmount the install.wim and discard any changes we’ve made to it. We’ll do so using DISM again:
dism /unmount-wim /mountdir:c:\win7pe\mount /discard
And then we’ll mount the winre.wim using DISM:
dism /mount-wim /wimfile:c:\win7pe\winre.wim /index:1 /mountdir:c:\win7pe\mountre
Use Windows Explorer to look at the various directories. Note that windows\system32 does not have the imagex.exe program. We need it for latter. To that end, we’re going to copy imagex.exe into the mounted winre.wim. We need to ensure we select the imagex.exe program from the correct architecture: 32-bit, 64-bit, or Itanium. So open up windows explorer and look in c:\program files\windows aik\tools. You’ll notice the x86 folder (32bit); amd64 (64-bit) and ia86 (Itanium). Each folder has an imagex.exe in it. Since we used the installation DVD for Windows 7 Ultimate, 64-bit edition, we need to copy over the imagex.exe file from the amd64 directory, as follows:
copy “c:\program files\windows aik\tools\amd64\imagex.exe” c:\win7pe\mountre\windows\system32
Since that is all we need for this WinPE/RE UFD (USB Flash Disk), we can now unmount the winre.wim file. Since we want to make the inclusion of imagex.exe a permanent thing, we’ll commit the changes, using DISM:
dism /unmount-wim /mountdir:c:\win7pe\mountre /commit
This will save all changes back to the c:\win7pe\winre.wim file. We can now proceed to the final step.
Since it was the recovery environment we wanted to have on the UFD, in addition to WinPE, we’ll follow the steps outlined in TechNet to create a WinPE UFD. The first step is to extract the everyday WinPE 3.0 that comes with the Windows AIK:
copype amd64 c:\peufd
I chose the directory name peufd, but you can use whatever name you desire.
This will create a multi-directory structure with WinPE in it
We will now copy over our WinRE.wim we extracted and updated earlier. We’re going to rename it boot.wim when we copy it, so it will fit nicely onto the typical iso for WinPE:
copy c:\win7pe\winre.wim c:\peufd\iso\sources\boot.wim
Our next step will be to clean and partition our UFD and place the ISO on it.
Insert a USB Flash Disk (UFD) into a USB port. I’m going to use a 2GB UFD. The next few steps will wipe out any data on it, so do not use one that has data you need to keep. We’ll be using the DISKPART command line tool to wipe and format the UFD.
In the Deployment Tools Command Prompt (still running "As Administrator"), enter:
If more than one HDD is on the host machine, select the proper number! Since HDD are numbered cardinally (starts with 0) the UFD will be the last drive number. I have only one hard drive, so the UFD will be disk 1. If you have two HDD, use disk 2 for your UFD.
At the diskpart prompt type:
(SHOW DISKS MAKE SURE YOU USE THE CORRECT ONE!)
select disk 1
(This really wipes out the disk! Careful!)
create par prim
sel par 1
format quick fs=ntfs
I chose to give it drive letter f but you can skip that. Simply use assign
Now we simply xcopy over the iso files from the iso root to our ufd.
xcopy c:\peufd\iso\*.* /e f:\
And we now have a functioning UFD WinPE/RE! We can boot to it (on motherboards that allow USB booting—most modern motherboards do). So we’ll now take the UFD to a machine we can boot from USB and boot it. You can use the various recovery options or go into the command prompt (which is Windows PE) and run imagex to capture and deploy images or whatever you use imagex for.