Ugly Stool Rotating Header Image

April 22nd, 2011:

How to Create a WinPE ISO

Download the Windows Automated Installation Kit, or WAIK (pronounced “wake”) from Microsoft.  WAIK’s are versioned by the OS they are based on.  For example, there is WAIK for Vista/Server 2008, and another for WAIK for Windows 7/Server 2008 R2.  (WAIK for Windows 7/Server 2008 R2 SP1 was recently released.)

After installing WAIK execute the following instructions to build a WinPE x86 (32-bit) ISO image.  (You need to run as an administrator to execute some of these commands.)  WinPE is a stripped down Windows 7 OS and only supports the architecture it is built against.  For example, the amd64 (64-bit) does not support running 32-bit binaries even though the full OS does.  If the application you want to run is strictly 64-bit use amd64, likewise if it is a 32-bit application use x86.  (ia64 support is available too.).

cd "\Program Files\Windows AIK\Tools\PETools"
copype.cmd x86 c:\windowspe-x86
cd "\Program Files\Windows AIK\Tools\Servicing"
dism /Mount-Wim /WimFile:c:\windowspe-x86\winpe.wim /Index:1 /MountDir:c:\windowspe-x86\mount
copy ..\x86\imagex.exe c:\windowspe-x86\mount\Windows\System32\
dism /Add-Package /PackagePath:..\PETools\x86\WinPE_FPs\ /image:c:\windowspe-x86\mount
dism /Add-Package /PackagePath:..\PETools\x86\WinPE_FPs\ /image:c:\windowspe-x86\mount
dism /Unmount-Wim /Commit /MountDir:c:\windowspe-x86\mount
copy c:\windowspe-x86\winpe.wim c:\windowspe-x86\ISO\sources\boot.wim
..\x86\oscdimg.exe -n -bc:\windowspe-x86\ c:\windowspe-x86\ISO c:\windowspe-x86\windowspe-x86.iso

This is a basic WinPE with two packages added via the dism command.  The package installs code to run WSH scripts – think VBscript and JScript.  The package supports the execution of the WMI commands.  WMI is useful for interrogating the system’s resource from the command line.  Documentation for other WinPE packages is available at MSDN.

Step 6 copies the imagex.exe executable into the WinPE because it is not installed by default.  ImageX is used to copy disk/OS images from an existing machine, and for applying disk/OS images.  (Not sure why the default image does not include ImageX as it is the OS deployment tool.)

Device drivers can be installed into a WinPE image using the dism command.  For example, if the drivers have been unzip’ed into c:\drivers, the following command would install all drivers found into the WinPE mount point.  (The WinPE image must still be mounted, step 5, for this command to work.)  WAIK for Windows 7 includes the drivers for Hyper-V, such as the synthetic NIC.

dism /Add-Driver /Driver:c:\drivers /Recurse /ForceUnsigned /image:c:\windowspe-x86\mount

Installing other programs into WinPE is as simple as copying the binaries into the mounted WinPE image.  The program must be compiled for the target architecture (32 vs. 64).  The deployment process can be scripted using VBscript or JScript, but I think ruby is more expressive.  Download the ruby-1.9.1p378 binary for windows, and extract the contents into the mount point.  Rebuild the CD using oscdimg, and viola!


If you want to start a program when WinPE boot, simply start it from the startnet.cmd file located in \Windows\System32.

I would also recommend adding the UnxUtils because they are small and you get useful command line utilities (find and grep) in a limited WinPE environment.

It is interesting that WAIK includes an ISO creation tool – oscdimg.exe.  Unfortunately, the license is rather strict.

C:\Program Files\Windows AIK\Tools\Servicing>..\x86\oscdimg.exe ISO -help

OSCDIMG 2.55 CD-ROM and DVD-ROM Premastering Utility

Copyright (C) Microsoft, 1993-2007. All rights reserved.

Licensed only for producing Microsoft authorized content.

Page optimized by WP Minify WordPress Plugin