About

These notes describe the creation of a custom WinPE ISO, including adding drivers to the WIM image file and creating startup scripts, in order to be able to install Windows remotely over the network. The procedure is based on Windows 7 but the instructions should be similar or identical to newer Windows releases.

One of the motivations is that, contrary to most Linux ISOs, such as the Debian net-installer, Windows is distributed as a DVD, which would be impossible to load via PXE's MEMDISK driver as described in our networking section.

Note that this tutorial proceeds by building the WinPE image on Windows. Although Linux has the mkwinpeimg command that can generate a WinPE image, the mkwinpeimg command does not support injecting drivers (just overlaying them) which will not make the booted WinPE image auto-load the installed drivers.

Requirements

Launching the Command Shell

For the rest of the tutorial the Deployment Tools Command Prompt is needed. It can be launched by going to Start→All Programs→Microsoft Windows AIK and then right-click the Deployment Tools Command Prompt and select Run as administrator.

Creating the WinPE Root and Mounting the Image (WIM)

in the newly opened command shell, we first create the WinPE root:

copype amd64 c:\winpe_amd64

Next, to modify the WinPE boot image (WIM) we need to mount it:

dism /Mount-Wim /WimFile:"C:\WinPE_amd64\winpe.wim" /index:1 /MountDir:"C:\WinPE_amd64\mount"

Installing and Removing Drivers

In order to list the current installed drivers, issue:

dism /image:"c:\winpe_amd64\mount" /get-drivers

The following a sample output of the kvm virtio network drivers installed in the WIM:

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Image Version: 6.1.7600.16385

Obtaining list of 3rd party drivers from the driver store...

Driver packages listing:

Published Name : oem0.inf
Original File Name : netkvm.inf
Inbox : No
Class Name : Net
Provider Name : Red Hat Inc.
Date : 4/29/2014
Version : 61.70.104.8100

The operation completed successfully.

In order install a driver (INF) in the WinPE image, issue:

dism /image:"c:\winpe_amd64\mount" /add-driver /driver:"C:\drivers\netkvm.inf"

To remove drivers, first list the drivers and capture the OEM INF name (not the driver INF) and then issue:

dism /image:"c:\winpe_amd64\mount" /remove-driver /driver:oem0.inf

You can also batch-install a bunch of drivers from a directory. Suppose you create a directory c:\drivers where you store all the drivers you want to install onto the WIM image, you would then issue:

for /R c:\drivers %i in (*.inf) do dism /image:"c:\winpe_amd64\mount" /add-driver /driver:"%i"

which recurses the c:\drivers folder and installs all the drivers (.inf files) into the WIM image. You can get a bundle of popular network drivers from our WinPE asset page.

Set a Start-Up Script

Create a file named winpeshl.ini in c:\winpe_amd64\mount\windows\system32 with the following contents:

[LaunchApp]
AppPath = %SYSTEMDRIVE%\install.cmd

this will run c:\windows\system32\install.cmd on boot.

Now we can create c:\winpe_amd64\mount\windows\system32\install.cmd to contain some commands. For example, to mount a samba share and start an installation, the install.cmd file would contain:

wpeinit.exe
netcfg.exe -winpe
ping.exe -n 11 127.0.0.1 > nul
net.exe use i: \\samba.server\tftp\install\windows
i:\setup.exe

Which performs in order:

  • initialises the WinPE environment.
  • tries to start the network.
  • uses ping to pause for 10 seconds (sleep, timeout, etc… Are not available).
  • mount the windows install files on drive i:.
  • start the windows install.

Finalising the Image

Unmount image and commit the changes:

dism /Unmount-Wim /MountDir:"C:\WinPE_amd64\mount" /commit

Or, you can unmount and discard the changes:

dism /Unmount-Wim /MountDir:"C:\WinPE_amd64\mount" /discard

Now, copy the customised image:

copy c:\winpe_amd64\winpe.wim c:\winpe_amd64\ISO\sources\boot.wim

Create ISO from the customised image:

oscdimg -n -bc:\winpe_amd64\etfsboot.com c:\winpe_amd64\ISO c:\winpe_amd64\winpe_amd64.iso

Kitchen

A complete kitchen for generating Windows 7 PE images can be created by writing a script that will pull all the relevant ISO files, allow the user to create or edit a startnet.cmd script and then generate a WinPE image for use with PXE.

To use the kitchen simply type:

./winpe7.sh

and the process will be started.


windows/customized_windows_pre-installation_environment_image.txt · Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.