Windows PE 2.0 Tutorial

Do you want to create a custom boot CD, or run your Windows application in such an environment such as Vista installation, or build a image running like a Vista installation, or re-pack the Vista installation? If so, Windows PE is a good choice.

If you have no idea about Windows PE, please see Windows PE 2.0 for Windows Vista Overview and Windows Preinstallation Environment for more information. Please pay attention on the "Windows PE Limitations" section of Windows PE 2.0 for Windows Vista Overview.

Now, let me build a PE image and set up iSCSI network on PE step by step.

Create a Simple Boot Image

First, install AIK. You can download from the Microsoft official web site: Windows Automated Installation Kit (AIK). AIK is released as an image file, you will need a tool such as a daemon to mount it as a CD. Here, I installed AIK under c:\Program Files\Windows AIK.

Second, you can create a PE image by the steps said on Walkthrough: Create a Custom Windows PE Image if you never have done it. Here, I create a batch file as below, so that I don't need to keyin the same commands every time.

title Win PE 2.0 Auto-building
@echo off
:: Variables
Set PE_FOLDER=c:\vistape
Set VMNETWORK_DRIVERS=c:\VMTools_Driver\vmxnet\*.inf
Set PE_BASIC_FILES=c:\vista_wim_initial
Set AIKTOOL_PATH="c:\Program Files\Windows AIK\Tools\PETools"
  • PE_FOLDER is the path where the PE image will be stored. You don't need to create this folder; this batch will create it.
  • VMNETWORK_DRIVERS is the path where VMWare network drivers are stored. Because I will run the PE image on a VMWare virtual machine, I have to insert required network drivers of VMWare. To get drivers from VMWare Tools, select [VM/Install VMWare Tools] on the toolbar of VMWare Server Console, and then open the CD-ROM in your guest virtual machine. You will see the drivers on CD-ROM:\program files\VMware\VMware Tools\Drivers. In this case, copy the drivers to c:\VMTools_Driver.
  • PE_BASIC_FILES is the path that stores some windows applications that will run on a PE boot; some others required configurations. It includes two folders: "ISO" and "mount".
    In the ISO folder: Including peimage.exe that was copied manually; in this case, from c:\Program Files\Windows AIK\Tools\PETools.
    In the mount folder: Nothing is included.
  • AIKTOOL_PATH is the path where AIK was installed.
::Create PE directory

rd /s/q %PE_FOLDER%
cd \
call copype.cmd x86 %PE_FOLDER%

:: Install all required packages and drivers in WIM

imagex /mountrw %PE_FOLDER%\winpe.wim 1 %PE_FOLDER%\mount

peimg /inf=%VMNETWORK_DRIVERS% %PE_FOLDER%\mount\windows

imagex /unmount %PE_FOLDER%\mount /commit

:: Create PE bootable image

del %PE_FOLDER%\ISO\sources\boot.wim
copy %PE_FOLDER%\winpe.wim %PE_FOLDER%\ISO\sources\boot.wim
oscdimg -n -b%PE_FOLDER%\ %PE_FOLDER%\
   iso %PE_FOLDER%\vistape.iso

The above is the required command as said in Walkthrough: Create a Custom Windows PE Image. Where peimg /inf=%VMNETWORK_DRIVERS% %PE_FOLDER%\mount\windows is to import and install VMWare network drivers to the PE image.

Right-clicking the batch file and clicking Run As Administrator, the PE boot image will be created under C:\vistape named vistape.iso. Mount vistape.iso to the CD-ROM of a empty virtual machine; then, start up the virtual machine. You will see that it boots like Vista Installation at the beginning; it then displays a command promty and brings up the network; it needs several minutes. You can type "ipconfig" to find the IP:

You can read How Windows PE Works if you are interested.

Windows PE 2.0 Tutorial

Insert the Windows Application

I suggest that you read Windows PE Customization How-To Topics before continuing, especially the Add an Application to a Windows PE Image topic.

I created a MFC application, named it HelloPE, using Visual Studio 2005 with SP1 installed. Then, select [Project -> HelloPE Properties] on the toolbar and do the following configurations:

  1. [Configuration properties]/[General], set [Use of MFC] as "Use MFC in a Static Library".
  2. [Configuration properties]/[C/C++]/[Code Generation], set [Runtime Library] as "Multi-threaded (/MT)".

Then, build in Release mode to generate HelloPE.exe.

Go back to the C:\vista_wim_initial\mount folder, and create two folders named "Program Files" and "windows". In Program Files/MyApp, you can input any Windows application you want to run. Here, I insert the HelloPE.exe.

Note: Sometimes, you have to input Microsoft.VC80.ATL, Microsoft.VC80.CRT and Microsoft.VC80.MFC folders under the same folder with your application to guarantee your application will work well on the PE environment. You can find those folders in the directory where Visual Studio 2005 installed.

In windows/system32, these three files should be inserted : MFC42D.DLL, MSVCRTD.DLL, and oledlg.dll. You can find them in the directory where Visual Studio 2005 installed.

Re-run the batch file to create the PE image. When PE boots up, go to X:\Program Files\MyApp, run HelloPE, and you will get like this:


If you want, PE can auto-runup HelloPE when it boots up, create a winpeshl.ini under windows/system32, (See Include a Custom Script in a Windows PE Image for more information) which the content is:

"%SYSTEMDRIVE%/Program Files/MyApp/HelloPE.exe"

When PE boots up, you will get something like this:


Windows PE 2.0 Tutorial

(Optional) Setup iSCSI Initiator of PE

This is a hot topic on many discussion forum; however, there has been no solution until now. Here, let me show you how to start up the iSCSI initiator if you need. iSCSI initiator is installed by default in Vista, so I prepare a virtual Windows XP machine to find the difference after iSCSI initiator been installed.

Then, I export the Registry and install Microsoft iSCSI Software Initiator that was downloaded from Microsoft Download Center. After iSCSI initiator is installed, I exported the Registry and compared with the original ones. Then, save the difference as a new file, named winpe_iscsi.reg. You can download it.

It took me a lot of time to figure out all the needed driver files needed to start up iSCSI on PE environment. Here is the required drivers list; please copy them to as the following destination, and download from Microsoft if the file is not found on your system:


Modify the batch file to add the Registry to PE:

:: Install all required packages and drivers in WIM
imagex /mountrw %PE_FOLDER%\winpe.wim 1 %PE_FOLDER%\mount

xcopy %PE_BASIC_FILES%\mount\windows %PE_FOLDER%\mount\windows\
   /a /e /k
md "%PE_FOLDER%\mount\Program Files\MyApp"
xcopy "%PE_BASIC_FILES%\mount\Program Files\MyApp" "%PE_FOLDER%\
  mount\Program Files\MyApp"  /a /e /k
peimg /inf=%VMNETWORK_DRIVERS% %PE_FOLDER%\mount\windows

reg load HKLM\winpe-system %PE_FOLDER%\mount\windows\system32\
reg import %PE_BASIC_FILES%\winpe_iscsi.reg
reg unload HKLM\winpe-system

imagex /unmount %PE_FOLDER%\mount /commit

Don't forget to remove winpeshl.ini form windows/system32 before you run the batch. When PE boots up, start iSCSI initiator by using the command:

net start msiscsi

Then, you will get something like this:


More Information

Re-pack Vista Installation

This is a big topic; please refer to Windows Vista Deployment Step by Step Guide for more detail. Windows System Image Manager (Windows SIM) allows you to add/remove language packages, drivers, or other things for you to/from *.wim. The following figure is components and packages list shown on SIM after I load install.wim from Vista Installation CD.


About the Author

Reta Pan

A R&D Software Engineer in Taiwan.
International High IQ Society Member, New York.
MCSD(Microsoft Certified Solution Developer (for Microsoft .NET))
Web Site: Anpino's Circle
English is not my primary language, I will be glad to receive your response, especially the advises that you can provide regarding my poor English.



  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Enterprises are increasingly looking to platform as a service (PaaS) to lower their costs and speed their time to market for new applications. Developing, deploying, and managing applications in the cloud eliminates the time and expense of managing a physical infrastructure to support them. PaaS offerings must deliver additional long-term benefits, such as a lower total cost of ownership (TCO), rapid scalability, and ease of integration, all while providing robust security and availability. This report …

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date