Synook

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.

  1. 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.

  2. Run the Deployment Tools Command Prompt (from the Start Menu) as an administrator.

  3. Now, use copype.cmd to copy the required Windows PE files to our working directory (here c:\winpe).

     copype.cmd x86 c:\winpe
    
  4. 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.

     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.

  1. Now, the image has been mounted to the c:\winpe\mount directory, and can be modified. All dism commands during the image manipulation phase will refer to the image, by immediately proceeding the dism call with /image: c:\winpe\mount.

    1. To add drivers (for devices such as network cards), the dism option /add-driver will 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 /recurse option) 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
      
  2. 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).

    1. 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.

    2. 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.

  3. Now, our image is ready, and we can unmount it. By setting the /commit switch, we tell dism that we want to make our changes permanent – in contrast, if you make a horrible mistake, then you can call the unmount with /discard to roll back your changes.

     dism /unmount-wim /mountdir:c:\winpe\mount /commit
    
  4. 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
    
  5. Now, we have the right files for a bootable ISO. With these, we can either create a bootable USB device or CD.

    1. To create a bootable USB Flash drive, two steps are required.

      1. First, the Flash drive needs to be formatted with a default FAT32 filesystem with a single active partition. This can be done in the diskpart utility (Windows Vista / 7 only) using the following commands (replacing disk 1 with your Flash drive’s number as shown when running list disk).

         select disk 1  
         clean
         create partition primary  
         select partition 1  
         active  
         format fs=fat32  
         assign  
        
      2. 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.

    2. 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 –b switch 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
      
  6. 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.