WinPE is a light version of Windows 7 (command line version). To be able to make a WinPE, you need to install Windows AIK (Automated Installation Kit) from Microsoft. With this professional series of tools, we can create our personalized WinPE 3.0 environment.
What can WinPE do for me?
WinPE contains very useful tools to…
- Deploy desktop and server operating systems
- Patch the existent OS with the newest updates, hot fix and patch
- Backup your computer!
- Add and Remove hardware drivers
Steps to create a WINPE environment
1- Start the “Deployment Tools Command Prompt” with the “Administrator” rights!
2- Enter the following command.
“copype.cmd (architecture) Destination Path”
[Copype.cmd X86 C:\WinPE] or [copype.cmd amd64 C:\WinPE64]
3- You can add additional customizations by copying your favorite tools into the created C:\WinPE\ISO folder. Like “ImageX + Sysinternal Tools + GImageX + etc.” To do that, simply copy these tools in C:\WinPE\ISO folder that you created.
Copy “C:\Program Files\Windows AIK\Tools\x86\ImageX.exe” C:\WinPE\ISO
4- Copy the base image (WinPE.wim) into the \WinPE\ISO\Sources folder and rename the file to Boot.wim
Copy C:\WinPE\WinPe.wim C:\WinPE\ISO\Sources\boot.wim
If you are finished with your WinPE image, you can create a bootable .ISO to burn it on a DVD or CD or you can make a bootable USB flash disk! To do that, look at the “Creating a Bootable USB Flash Disk” title.
If you want to add some drivers, activate features; add packages, updates, hot fixes… Look at the “Customizing the WinPE Image” title.
Creating a Bootable USB Flash Disk / ISO image
To create a bootable ISO image for your WinPE environment, type the following command from “Deployment Tools Command Prompt” with “Administrator” rights!
Oscdimg –n –bc:\WinPE\ISO\boot\etfsboot.com C:\WinPE\ISO C:\imagename.iso
Defines the boot sector! - Root of the desired image - Path to new ISO file!
This command creates a bootable image of the WinPE environment that you just created. You can than burn this ISO into a CD/DVD and boot your computers with this media. Usually, this is the last step to do after customizing and tweaking your WinPE image.
Bootable UFD (USB)
After finishing our WinPE image, we can now use a USB stick to boot on WinPE. To do that, follow the steps above and prepare your USB Flash Drive with “Diskpart” utility.
Open an elevated command prompt with “Administrator” rights! It doesn’t have to be “Deployment Tools Command Prompt”, we can use the normal “cmd” in Windows 7. Type the following commands…
List disk (shows the connected disks with their I.D.)
Select Disk 1 (1 represents your USB KEY)
Clean (wipes the selected drive)
Create partition primary size=7500 (creates a partition on selected disk. The value is in MB)
Select partition 1 (selects the partition that is newly created)
Format fs=FAT32 quick label=”WinPE”
These steps prepare the UFD to be bootable! It still needs the boot files and environment in it. You can copy the content of WinPE into the root of your UFD! To do that, enter the following command…
Xcopy C:\WinPE\ISO\*.* /e F:\ (F:\ is the USB Drive)
Customizing the WinPE Image
With the WIM files, we can add drivers, updates, packages, patches, hot fixes, enable/disable features, etc… The easiest way to do these operations is to use the “DISM” and “IMAGEX” command line tools. In this tutorial, I’ll only show how to add drivers in a WinPE environment. But the potential to do things with this tool is much more than just adding the drivers…
First thing to do when playing around with WIM images is to “Mount” the WIM image. Mounting is like putting a CD into your CD-ROM. As WIM files are image based files, they contain a structure of folders and files… By mounting the “WIM” image, we can access to the content of the image and make changes if we want to.
To mount a WIM image, enter the following command in the “Deployment Tools Command Prompt” with the “Administrator” rights.
Dism.exe /Mount-Wim /WimFile:C:\Images\myimage.wim /index:1 /MountDir:C:\MountedImages
Imagex /Mountrw C:\Images\Myimage.wim 1 C:\MountedImages
(/Mountrw = this switch mounts the images with the re-write attributes.
/Mount = this switch mounts the images with the read-only attributes.
Imagex.exe /? = will display the detailed information about “Imagex” and its options.)
Note: If you have the possibility to mount the image on a different physical hard drive, this helps a lot in terms of performance while working with mounted images.
Once we have the “MountedImage”, we can now add or remove the additional options or packages. I will only provide the commands to manipulate your mounted image and it’s all up to you to make all the changes needed.
Dism Driver Commands:
Dism /image:C:\Mountedimages[ /get-drivers | /get-driverinfo | /add-driver | /remove-driver]
To add a driver for WinPE:
Dism /image:C:\MountedImages /add-driver:C:\NewDrivers\mydriver.inf
(Optionally you can add the “-forceunsigned” (without quotes) option at the end of this command to force the installation of unsigned drivers)
Dism /image:C:\MountedImages /add-driver:C:\newdrivers\mydriver.inf /forceunsigned
(Optionally you can use the “-recurse” (without quotes) option to add all the drivers with in a folder. Let’s say you have 5 new drivers in a folder (C:\NewDrivers) and you want to install all these drivers with a single command)
Dism /image:C:\MountedImages /add-driver:C:\NewDrivers\ -recurse –forceunsigned
To Servicing Applications and Application Patches
dism /image:path_to_directory [/check-apppatch | /get-apppatchinfo: | /get-apppatches |
/get-appinfo | /get-apps]
Ex: dism /image:C:\MountedImages /get-apppatches
If you want to display information about specific .msp patches applicable to the offline image, you can use the /check-apppatch parameter. You use /patchlocation to specify the path to the MSP patch file. You can specify multiple patch files by using /patchlocation more than once in the command. For example, to display information about two patch files, 30880d0. msp and 8c82a.msp (both in C:\Windows\Installer) in the mounted image, you would enter the following command:
dism /image:c:\mountedimages /check-apppatch /patchlocation:c:\windows\installer\30880d0.msp
If you need detailed information about all installed MSP patches applicable to the offline image, you would enter a command similar to the following:
dism /image:c:\mountedimages /get-apppatchinfo
Boot Problems – Bootmgr is missing – BCDBoot
You can try the “BCDboot.exe”. After applying a WIM image to the new computer, use the following command to recover the missing Boot files.
X:\>C:\Windows\System32\bcdboot.exe C:\Windows /s C:
(In this example, C: is the drive that contains Win7 with the defective boot files.)
Microsoft IT Professional
Windows 7 Enterprise Desktop Administrator