Windows preinstallation environment (windows PE) is a bootable tool that provides a minimal set of operating system features for installation, troubleshooting, and recovery. In this post I am going to explain how you can setup a windows PE environment to boot from a USB drive in 5 simple steps:

  1. Download and install windows AIK from Microsoft
  2. Prepare WinPE image
  3. Add drivers to your WinPE image
  4. Setup USB drive to be able to boot
  5. Copy the files to USB drive

Download and install windows AIK from Microsoft

Windows AIK is a set of tools and documentation that support the configuration and deployment of Windows® operating systems. You can download WAIK from Microsoft download center (search term WAIK) and install it to your computer for free.

After WAIK installation a set of folders will be created by default under program filesWindows AIK that contain the appropriate files and tools to create and manage WinPE images, unattended installation files, a volume activation management tool, SDKs and some sample files.

Prepare the WinPE USB image

After installing WAIK you are ready to prepare your WinPE image. In order to do so you have to go to program filesWindows AIKToolsPETools (default location) and copy your candidate WinPE image files to a temporary location. To do that you issue the command:

copype.cmd <x86|amd64|ia64> <temporary location>


for example

copype.cmd x86 c:tempWinPEx86 (x86 is the 32bit architecture).


As a final step you need to copy and rename the base image file c:tempWinPEx86winpe.wim (based on the above example) to the ISOSources subdirectory of this temporary folder as boot.wim. To do this, issue the command

copy c:tempWinPEx86winpe.wim c:tempWinPEx86ISOsourcesboot.wim


Add drivers to your WinPE USB image (optional)

In case you need to preload any drivers to your WinPE image or add optional components you have to follow some additional steps outlined below. In case you don’t you skip to the next section.

First step is to create a directory, for example c:tempWinPEx86Drivers, and download your drivers in this location. Note that the drivers must be fully extracted with their .inf files exposed in order to be added to the WinPE image.


Second step is to mount the base WinPE image copied previously. To do that execute

"c:Program FilesWindows AIKToolsServicingDism.exe" /mount-Wim /WimFile:c:tempWinPEx86ISOSourcesboot.wim /index:1 /MountDir:c:tempWinPEx86Mount


Third step is to add the downloaded drivers to the Image by executing

"c:Program FilesWindows AIKToolsServicingDism.exe" /image:c:tempWinPEx86Mount /Add-Driver /Driver:c:tempWinPEx86drivers /recurse /ForceUnsigned


By including the /recurse switch you tell to the command to recurse the drivers’ subfolders for valid .inf drivers and by including the /ForceUnsigned you tell the command to ignore driver signing requirements.

Fourth step is to unmount and commit the WinPE image by executing

"c:Program FilesWindows AIKToolsServicingDism.exe" /unmount-wim /MountDir:c:tempWinPEx86Mount /commit


Note, that you can add additional files and folders to your custom WinPE image simply by copying your files to the c:tempWinPEx86Mount. These files will be loaded to the RAM drive after WinPE boot (c:). If you don’t want these files to be loaded to the RAM Drive (consumes RAM) and be available to the USB drive instead, just copy them to a structure under c:tempWinPEx86ISO folder.

Setup the WinPE USB drive to be able to boot

In this step you need to use the diskpart utility (windows Vista and above O/S) to create a bootable partition to your usb drive as outlined below.

Use Diskpart to identify the disk ID of your usb drive:

list disk

WinPE USB diskpart

After you have identified your usb disk ID (based on size), you can wipe your partition information, create a new one and mark it as active.

select disk 1
create partition primary
select partition 1
format quick fs=ntfs

Copy the files to USB drive

Final step is to copy the files included under your ISO subfolder to your USB drive:

xcopy /E c:tempWinPEx86ISO*.* f: (where f: is your USB drive)


Note that you may need to alter your PC’s BIOS settings in order to be able to boot from USB drives and of course it needs to be USB boot capable.


Final Thoughts

In case you want to load drivers after WinPE boot you can use the drvload.exe command (drvload.exe inf_path).

To manipulate winPE environment you need to use the wpeutil <command> <argument> command. Most usable commands of wpeutil: EnableFirewall, DisableFirewall, Reboot, ShutDown, Initializenetwork.