Open a WinPE Tools command prompt by clicking Start:All Programs: Microsoft Windows AIK:Windows PE Tools Command Prompt.
Copy the WinPE source files to a temporary directory by typing the following command in the PE Tools command prompt
copype.cmd x86 c:\winPE_x86
Note that if you want to build a 64-bit WinPE disk, you use x64 instead of x86 throughout. We will use x86 in the remainder of these instructions for simplicity.
Next, you want to mount your image to a directory so you can customize it. You do that with the following command:
imagex /mountrw c:\winpe_x86\winpe.wim 1 c:\winpe_x86\mount
The mount directory is essentially a link to what is in the WIM file that allows you to read and write its contents. You use that to add additional tools and packages to the image.
Add features. WinPE comes with a number of features that are not installed by default to save space. This includes language packs and additional features. If you have enough space, say half a gigabyte, it is worth it to install all of them. Table 1 lists the packages that are included with WinPE.
HTML application support
Microsoft Data Access Component support
Windows Script Host support
Microsoft XML (MSXML) parser support
Windows Management Instrumentation support
Japanese font support
Korean font support
Chinese simplified (People's Republic of China) font support
Chinese traditional, Hong Kong SAR font support
Chinese traditional, Republic of China font support
To install the packages, run the following command once for each package:
peimg /install= c:\winpe_x86\mount\Windows
You can install all the packages by using * instead of :
If you need to install custom drivers this would be the time to do it. You can do that with the peimg command as well, using the /inf switch. You should do this, for example, if you want a network-ready WinPE image using a network card that does not have a driver in the standard image.
You can add your own custom tools by copying them into the c:\winpe_x86\ISO directory. You may also want certain other tools, such as the imagex tool used to capture and apply installation images just as you did before, and the Package Manager tool that is used to service those images. Copy those latter two using these commands:
copy "c:\Program Files\Windows AIK\Tools\x86\imagex.exe"
xcopy "c:\Program Files\Windows AIK\Tools\x86\Servicing"
copy %windir%\system32\msxml6*.dll c:\winpe_x86\iso\Servicing
If you so desire, you can put the utilities in Step 6 in the mount directory instead of the iso directory. The iso directory is mounted using the first available drive letter when you boot into WinPE. If you put the tools in the mount directory instead, they will be loaded into the RAM disk that WinPE is loaded into and will be accessible using the X: drive under WinPE just like the tools included by default. This obviously increases the size of the image in memory, however. Because you are planning to run WinPE from a USB flash drive, the speed difference is so marginal, we see no need to increase the memory footprint further.
Prepare your image. Preparing your image optimizes it and removes any options that you do not need. For example, in our test used to develop these instructions, the image was 1.1GB on disk before running the prep command:
peimg /prep c:\winpe_x86\mount\Windows
After running peimg /prep, the image size is down to 685MB.
Commit your changes and finalize the image. You do that using this command:
imagex /unmount c:\winpe_x86\mount /commit
This makes your changes permanent and unmounts the image. If you do not do this you will lose all the changes you have made and you will leave a large number of files in the mount directory locked open so that you cannot delete them.
Finalize your ISO directory by taking the changes you have made to the original image and copying them into the ISO directory where all your source files for your WinPE image now sit:
copy c:\winpe_x86\winpe.wim c:\winpe_x86\ISO\sources\boot.wim
You now have a complete WinPE image. You can do a number of things with it
Create an ISO image. Having an ISO image with WinPE is convenient because it is an easy way to distribute the image. You can also use it to boot virtual machines by mounting the ISO image as a CD. To create an ISO image, run this command:
oscdimg -n -bc:\winpe_x86\etfsboot.com c:\winpe_x86\ISO
As you are probably aware, to have a bootable ISO image you must have a boot sector. Fortunately, the boot sector comes with WinPE; it is the http://www.etfsboot.com file.
If you are of the old school and want a CD copy of your WinPE image you can burn the ISO image to CD with your favorite CD burning program.
Create a bootable WinPE image on a USB flash drive. This is by far the coolest way to use WinPE. You need a 256MB or larger flash drive to do this. The steps for how start in Step 11.
Plug your USB flash drive into a computer running Windows Vista. It is very important that the computer run Windows Vista. Diskpart in Windows Server 2003 and earlier does not support manipulating USB flash drives.
You need to prepare the USB flash drive using diskpart, the disk partitioning tool. Start that tool by typing diskpart at a command line. If you have not elevated the command prompt already, you will be asked to do so now.
Partition and prepare your USB flash drive using these commands
List disk: This lists the disks in your computer. You do this only to ensure that you know which one is your USB flash drive. Take care here. The next few steps will completely erase the drive! You do not want to do this with the wrong drive.
Select disk : Substitute the disk number shown for your USB flash drive in Step 13 a for . Again, make sure you get this one right!
Clean: This command zeros every sector on the disk. In other words, it is a completely destructive wipe so you need to be careful in Step 13 b.
Create partition primary: This creates a primary (bootable) partition on the USB flash drive.
Select partition 1: Selects your partition so you can manipulate it further.
Active: Marks the partition as active (the partition holding the boot files).
Format fs=fat32: Formats the partition using the Fat32 file system.
Assign: Assigns a drive letter to your new partition in case it had not already been done. Usually it is already done.
Exit: Quits diskpart. You now have a formatted, empty, bootable USB flash drive. Only the files you want to put on it are missing.
Copy the files in the ISO folder to the USB flash drive. You can do this via Windows Explorer, or by using this command in the command prompt you already have open:
xcopy c:\winpe_x86\iso\*.* /s /e \iwhere is the drive letter assigned to your USB flash idrive.
Congratulations! You now have a bootable Windows PE image. This is one of the most useful little tools you can have in your bag for troubleshooting or repairing Windows. You can also use it to flash BIOS files, prepare disks, and for a host of other tasks. We're sure you will think of things we had not imagined.