Creating a customised Windows PE 3.0 image
Microsoft Windows PE 3.0 is a stripped-down version of Windows 7 based on the 7100 kernel. Capable of running Windows-32 applications, Windows PE can be used for deploying, servicing and repairing Windows installations, as well as running other tools, such as Norton Ghost. Windows PE 3.0 is created using the Windows Automated Installation Kit (AIK) for Windows 7, a free application suite available on the Microsoft website. The Windows AIK for Windows 7 must be installed on a machine running Windows Vista or Windows 7.
Writing a guide for this sort of product is a bit odd for me, however I have been working on making a Ghost-based pre-installed environment recently and was asked to create an article as to what I did.
First, we have to install the Windows Automated Installation Kit (AIK) for Windows 7 (henceforth know as WAIK). WAIK can be downloaded from the Microsoft site here.
Run the Deployment Tools Command Prompt (from the Start Menu) as an administrator.
copype.cmdto copy the required Windows PE files to our working directory (here c:\winpe).
copype.cmd x86 c:\winpe
Next, we want to customise our image. In the WAIK for Windows 7, many of the commands present in previous versions of the WAIK have been all rolled into one utility, named
dism. To mount the image (stored in the working directory in the Windows Imaging Format, extension .wim), we will use
dism /mount-wim /wimfile:c:\winpe\winpe.wim /index:1 /mountdir:c:\winpe\mount
A note on
dism– by using the
/?modifier at any stage, more information can be found about the tool and its options.
Now, the image has been mounted to the c:\winpe\mount directory, and can be modified. All
dismcommands during the image manipulation phase will refer to the image, by immediately proceeding the
To add drivers (for devices such as network cards), the
/add-driverwill be used. Using
/add-driver /driver, individual drivers can be specified, by their .inf files, or entire directories (such as c:\drivers in the example), and even directory trees (with the
/recurseoption) can also be searched. Note that installing display drivers to your Windows PE image will cause the completed operating system to crash during boot.
dism /image:c:\winpe\mount /add-driver /driver:c:\drivers
The filesystem and registry can also be modified while the image is mounted, however these steps are done outside of the Deployment Tools Command Prompt in their respective tools (i.e. Explorer and the Registry Editor).
To change registry settings, open up regedit.exe, and use the Load Hive function to open up the image’s registry files, located in the mount directory’s system32\config folder (therefore, in our case, c:\winpe\mount\windows\system32\config). Of particular interest are the DEFAULT and SYSTEM hives.
To make modifications to the filesystem, simply browse to the mount directory in explorer and copy your files across. Note that you can’t “install” programs to the PE installation – to do so you would have to install it on a Windows 7 machine and copy the required program files and registry settings across – something not covered in this guide. Also, note that files can be loaded into Windows PE from storage media at runtime, however if you copied the files to the image, then they will be loaded into memory along with the OS and the continued presence of the boot device would not be necessary.
Now, our image is ready, and we can unmount it. By setting the
/commitswitch, we tell
dismthat we want to make our changes permanent – in contrast, if you make a horrible mistake, then you can call the unmount with
/discardto roll back your changes.
dism /unmount-wim /mountdir:c:\winpe\mount /commit
Hooray, our image is ready! However, at the moment, it is still stored in the Windows Imaging Format file we mounted earlier (at c:\winpe\winpe.wim). To create a working bootable image, we need to copy that file into the ISO directory, nicely created for us in step three at c:\winpe\ISO.
copy c:\winpe\winpe.wim c:\winpe\iso\sources\boot.wim
Now, we have the right files for a bootable ISO. With these, we can either create a bootable USB device or CD.
To create a bootable USB Flash drive, two steps are required.
First, the Flash drive needs to be formatted with a default FAT32 filesystem with a single active partition. This can be done in the
diskpartutility (Windows Vista / 7 only) using the following commands (replacing
disk 1with your Flash drive’s number as shown when running
select disk 1 clean create partition primary select partition 1 active format fs=fat32 assign
Then we just have to copy all the files from the ISO (c:\winpe\iso) directory to the USB device. You will probably need at least a 256MB drive.
To create a bootable CD, we just have to turn the ISO directory into an actual ISO. The Deployment Tools Command Prompt provides a utility,
oscdimg, to do this. Note that the
–bswitch indicates where the boot sector for the CD will be, and the last parameter tells it where to create the image. Then, you can burn the ISO to CD using your favourite burning utility.
oscdimg –n –bc:\winpe\etfsboot.com c:\winpe\iso c:\winpe\winpe.iso
You are done! Remember that Windows PE loads itself into RAM when it boots, so you can take out the Flash drive / CD as soon as the system loads.