Making a custom WinPE image

There are many different guides on the Internet which describe how to make your own WinPE image (.wim or .iso). However, the instructions are different depending on which version of WinPE you are using. I’m writing this guide for WinPE version 5, which is part of Windows ADK 8.1. If you are completely new to WinPE, have a look at http://en.wikipedia.org/wiki/Windows_Preinstallation_Environment for example.

I’m using this image with WDS to pxe-boot computers. With WinPE (and WinRE) I can get details about the computer or do some minor troubleshooting etc. It’s convenient having pxe-boot enabled on the computers so you don’t have to worry about cd/dvd/usb boot media. I’m also using this WinPE image to boot my Windows-image-making virtual machine after I have sysprepped  it. After booting with WinPE I’m using imagex to capture my image. Example:

imagex.exe /compress maximum /capture c:\ z:\myimage.wim “myownimage”

(z:\ in this case is my manually mounted network share where I will store the image. Normally I’ll just mount my MDT Deployment share). More about integrating imagex in WinPE later on in the text. I’ll also write a couple of lines about making a (custom) WinRE image.

 

Creating the custom WinPE:

First, start of by downloading and installing Windows Assessment and Deployment Kit (Windows ADK) v. 8.1. Then run Deployment and Imaging Tools Environment (from Start Menu/Windows Kits/Windows ADK) with administrator rights. Once fired up, navigate to:

C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment. From here enter:

copype.cmd x86 d:\winpe (for x86 architecture). This will automatically copy all of the needed WinPE files to the d:\winpe –directory.

We will now copy and mount the boot image (wimpe.wim). Copy it from the ADK installation folder (for example, <Installation path>\Windows Kits\<version>\Assessment and Deployment Kit\Windows Preinstallation Environment\<x86 or amd64>\<locale>) to a destination folder on the computer from which you will customize the boot image. I’ll copy it to my newly created d:\winpe directory, like so:

C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\en-us>copy winpe.wim d:\winpe

Now it’s time to mount the boot image so we can make modifications to it. I’ll use the directory d:\winpe\mount.

dism /mount-wim /wimfile:d:\winpe\winpe.wim /index:1 /mountdir:d:\winpe\mount

Deployment Image Servicing and Management tool
Version: 6.3.9600.16384

Mounting image
[==========================100.0%==========================]
The operation completed successfully.

Image is now mounted and it’s time to make some changes to it. I’ll be adding the WMI package and the ImageX & BgInfo executables. I’ll also change system locale and replace the background picture. I won’t add any drivers at the moment (not needed).

 

Adding WMI package:

dism /image:d:\winpe\mount /add-package /packagepath:”C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\WinPE_OCs\WinPE-WMI.cab”

I also added the Scripting, MDAC, and HTA packages in the same matter (needed for WMI).

WMI is handy if you want to get details about the computer model or manufacturer, among other things. Example query:

“WMIC computersystem get manufacturer” or WMIC “computersystem get model”

This information can then be used to inject drivers in MDT based on computer model or manufacturer.

 

Checking locale:

Dism /image:D:\winpe\mount /Get-Intl

Deployment Image Servicing and Management tool
Version: 6.3.9600.16384

Image Version: 6.3.9600.16384

Reporting offline international settings.

Default system UI language : en-US
System locale : en-US
Default time zone : Pacific Standard Time
User locale for default user : en-US
Location : United States (GEOID = 244)
Active keyboard(s) : 0409:00000409
Keyboard layered driver : PC/AT Enhanced Keyboard (101/102-Key)

Installed language(s): en-US
  Type : Fully localized language.

The operation completed successfully.

Adding swedish locale etc:

dism /image:D:\winpe\mount /Set-SysLocale:sv-se
dism /image:D:\winpe\mount /Set-UserLocale:sv-se
dism /image:D:\winpe\mount /Set-InputLocale:041d:0000041d

checking settings again:

dism /image:D:\winpe\mount /Get-Intl

Deployment Image Servicing and Management tool
Version: 6.3.9600.16384

Image Version: 6.3.9600.16384

Reporting offline international settings.

Default system UI language : en-US
System locale : sv-SE
Default time zone : Pacific Standard Time
User locale for default user : sv-SE
Location : Sweden (GEOID = 221)
Active keyboard(s) : 041d:0000041d
Keyboard layered driver : PC/AT Enhanced Keyboard (101/102-Key)

Installed language(s): en-US
  Type : Fully localized language.

Good! I’m happy with these 🙂

 

Adding imagex (for capturing an image from WinPE):

Create a folder in which the tool(s) are stored:

mkdir d:\winpe\mount\Tools

Copy imagex.exe to this directory:

copy “c:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\x86\DISM\imagex.exe” d:\winpe\mount\Tools

Then we add a custom script to the same directory. The script tells which files should be saved in the process and which files should be compressed and so on:

notepad d:\winpe\mount\Tools\Wimscript.ini

In my case, I have this information in the ini-file:

[ExclusionList]
ntfs.log
hiberfil.sys
pagefile.sys
“System Volume Information”
RECYCLER
Windows \ CSC

[CompressionExclusionList]
*. Mp3
*. Zip
*. Cab
\ WINDOWS \ inf \ *. Pnf

I also copied the BgInfo program to the Tools dir just for fun.

d:\temp\bg>copy Bginfo.exe d:\winpe\mount\Tools
        1 file(s) copied.

 

Changing the background image:

Change the security permissions of the Windows PE background image file (d:\winpe\mount\Windows\System32\winpe.jpg). This allows you to modify or delete the file.

  • In Windows Explorer, navigate to d:\WinPE\mount\windows\system32.
  • Right-click the d:\WinPE\mount\windows\system32\winpe.jpg file, and select Properties > Security tab > Advanced.
  • Next to Owner, select Change. Change the owner to Administrators.
  • Apply the changes, and exit the Properties window to save changes.
  • Right-click the d:\WinPE\mount\windows\system32\winpe.jpg file, and select Properties > Security tab > Advanced.
  • Modify the permissions for Administrators to allow full access.
  • Apply the changes, and exit the Properties window to save changes.

Replace the winpe.jpg file with your own image file. I replaced mine with this one 🙂

http://bfarber.com/screens/%5B2476%5DWindows_1.JPG

Source: http://technet.microsoft.com/en-us/library/hh824972.aspx#AddWallpaper

 

Commit all changes back to the image:

dism /unmount-wim /mountdir:d:\winpe\mount /commit

Deployment Image Servicing and Management tool
Version: 6.3.9600.16384

Image File : d:\winpe\winpe.wim
Image Index : 1
Saving image
[==========================100.0%==========================]
Unmounting image
[==========================100.0%==========================]
The operation completed successfully.

Done.

Now just copy this image to your WDS server (or make a bootable cd/usb stick).

If you feel like creating a (bootable) iso file, here’s the step:

OSCDimg.exe -n -bD:\winpe\fwfiles\etfsboot.com D:\winpe\media D:\winpe\winpe5_x86.iso

 

Here are some screenshots of my custom WinPE running in a virtual machine (pxe-booted from the wds server):

winpe_customized1

Fig 1. Look at that sexy Windows 1.01 background image 🙂 Also notice my Tools in the “Tools” directory.

 

winpe_customized2

Fig 2. Demonstrating WMI query. Very useful for scripting etc. in MDT.

 

winpe_customized3

Fig 3. BgInfo in action (with default settings). Can’t have too much information, right? 🙂

 

Making a WinRE image:

I’ll also add a WinRE image to my wds server. This is handy for minor troubleshooting or if you have to restore a computer from a Windows backup. WinRE uses the same troubleshooting tools that you get when you boot from a Windows 7/8 DVD (on the opening Windows 7/8 screen, clicking Repair Your Computer). Same tools are also available if you have created a Windows System Repair Disc. Anyways, on to the creation of the image.

Start off in the same way as with WinPE (instructions above), that is:

copype.cmd x86 d:\winpe (for x86 architecture). This will automatically copy all of the needed WinPE files to the d:\winpe –directory.

Then we need to copy the boot image from a Windows 7/8 DVD, because WinRE isn’t part of Windows ADK. First, mount your Windows 7/8 DVD (G:\ in my case), and then copy/export the boot.wim from it:

imagex.exe /export /boot G:\sources\boot.wim 2 d:\winpe\winre.wim “Windows Recovery Environment”

then we mount the image:

imagex.exe /mountrw d:\winpe\winre.wim 1 d:\winpe\mount

After this we add a script so that the WinRE-environment (recenv.exe) will auto-start.

  • Create a file called Winpeshl.ini. Save it wherever you like. Add the following information to the file:

[LaunchApp]
AppPath=X:\sources\recovery\recenv.exe

  • Copy the file to the \Windows\System32 directory in your working Windows PE directory, in my case, d:\winpe\mount\Windows\System32

Capture the image:

imagex.exe /unmount /commit d:\winpe\mount

Copy the winre.wim to your wds server and use it 🙂 (I created one WinRE image for Windows 7 and one for Windows 8).

Source: http://technet.microsoft.com/en-us/library/cc749147%28v=ws.10%29.aspx

 

Here are some screenshots of my WinRE images running in a virtual machine (pxe-booted from the wds server):

winre_win81__1

Fig 4. WinRE (Windows 8.1- version) running pxe-booted from wds.

 

winre_win81__2

Fig 5. WinRE (Windows 8.1- version) running pxe-booted from wds (advanced options).

 

winre_win7

Fig 6. WinRE (Windows 7- version) running pxe-booted from wds.

 

Now go enjoy your newly created custom WinPE & WinRE images 🙂

 

Sources:

http://technet.microsoft.com/en-us/library/dn387582.aspx
http://technet.microsoft.com/en-us/library/hh824972.aspx
http://technet.microsoft.com/en-us/library/hh824926.aspx
http://forum.acronis.com/forum/9892
http://msdn.microsoft.com/en-US/goglobal/bb964664.aspx
http://www.gtkdb.de/index_27_1812.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s