Making a WinPE CD

A WinPE CD is a boot CD based on Vista. It allows you to boot from a CD and get a command prompt, so it's a bit like Server Core, though more restricted. WinPE is very useful for using apps like Drive Snapshot to rebuild servers.

This document describes my method for building a WinPE CD. I include extra stuff like a VNC server, but you can omit this if you need a simpler environment. I don't cover adding extra drivers because so far Vista has all the drivers I need included. Adding drivers isn't hard and is documented in the Windows AIK. In fact everything here is documented in the AIK, but the documentation is a bit verbose. This gives you a quick and easy recipe for the CD.

Start by downloading and installing the AIK. When I last looked it was available here. If MS have moved it just goto and search for "Automated Installation Kit".

Step1: Create the base CD image

Once the AIK is installed open the Windows PE Tools Command Prompt from the start menu. In this example I'm going to build the CD image in D:\WinPE. Whatever directory you use it must not exist when you start this process, so if the directory already exists delete it now.

In the command prompt type:

copype x86 D:\WinPE

At this point copy anything extra into the ISO folder if you want it to appear on the CD.

xcopy whatever D:\WinPE\ISO /S

At this point I copy VNC4 files so I can launch a VNC server when WinPE boots. With one exception (RunUserMode.bat) these files were simply copied from a VNC installation on my PC. The files copied are:

c:\temp>dir D:\Software\CD\WAIK\ISO\win32app\VNC4

and to copy the files I use:

md D:\WinPE\ISO\win32app\VNC4
xcopy D:\Software\CD\WAIK\ISO\win32app\VNC4\* D:\WinPE\ISO\win32app\VNC4 /S

My RunUserMode.bat is used to start the VNC server and contains:

rem ********************************************************************
rem RunUserMode.bat
rem ===============
rem ********************************************************************

regsetvalue -o -kREG_DWORD hkey_current_user\software\RealVNC\WinVNC4 QueryConnect 0
regsetvalue -o -kREG_DWORD hkey_current_user\software\RealVNC\WinVNC4 QueryOnlyIfLoggedOn 0
regsetvalue -o -kREG_SZ hkey_current_user\software\RealVNC\WinVNC4 ReverseSecurityTypes None
regsetvalue -o -kREG_SZ hkey_current_user\software\RealVNC\WinVNC4 SecurityTypes None

start winvnc4 -noconsole

regsetvalue.exe is an app I wrote back in the days of NT3.50 to set registry keys from the command line. These days Windows includes apps like reg.exe that will do this, or you can get a copy of regsetvalue.exe from

Once you've copied anything you need apply the standard WinPE WIM

imagex /apply winpe.wim 1 D:\WinPE\mount

Update startnet.cmd

startnet.cmd is an equivalent of the old DOS autoexec.bat. WinPE executes this script when it starts. My startnet.cmd looks like:


wpeutil DisableFirewall

cd \win32app\VNC4
call RunUserMode.bat

cd \win32app\winfile
copy winfile.ini \Windows
start winfile.exe

cd \

I include the old NT 3.51 File Manager for nostalgic reasons. Just omit the three lines that start winfile.exe if you don't want to use it. Copy the startnet.cmd into the image using:

copy D:\Software\CD\WAIK\ISO\startnet.cmd D:\WinPE\mount\Windows\System32

Add any extras you want

Copy anything you want to appear on the RAMDisk (X:) into D:\WinPE\mount. In my case I have various applets like Drive Snapshot in win32app\stdutils and scripts in win32app\stdbatch so I'd use:

xcopy D:\Software\CD\WAIK\ISO\win32app D:\WinPE\mount\win32app /S

If you want extra drivers they can be added using (I've never tested this):

peimg /inf= D:\WinPE\mount\Windows

And there are some standard extra packages provided by the AIK. For details search Technet. To add extra packages use:

peimg /install=package-name D:\WinPE\Mount

Finalise the image

To finalise the image: no changes after this point:

peimg /image=D:\WinPE\mount /prep

Create the WIM of the built image:

imagex /capture /boot /compress max "D:\WinPE\mount" "D:\WinPE\iso\sources\boot.wim" "My PE Image"

And create a bootable ISO:

oscdimg -n -bD:\WinPE\ D:\WinPE\ISO D:\WinPE\WinPE.iso

And that's it. Just burn D:\WinPE\WinPE.iso and you have a bootable WinPE CD.

Making a bootable USB key

The WinPE CD can be converted into a bootable USB key very easily. There are various tools for converting bootable ISOs to bootable USB keys, but you can do very easily from Vista (or by booting the WinPE CD if you don't have Vista). Just use diskpart to delete any existing partitions on the key, create a new partition and make it active, then copy everything from the CD onto it. Note that the version of diskpart in XP and Server 2003 won't create partitions on USB keys, so you need to use the version of diskpart in Vista. Booting off a USB key is usually faster than a CD, and you can copy any extra files you want straight onto the key instead of having to go though the process of making a new CD.

John Rennie
3rd June 2009