The WinPE system provides three ways to start custom scripts: Winpeshl.ini, Startnet.cmd, and Unattend.xml. The default interface for WinPE is the command Prompt window. However, you can create a custom Winpeshl.ini file to run your own shell application. You can also create your own Startnet.cmd batch file to run a specific set of commands, batch files, or scripts. Unattend.xml is the new answer file format for WinPE 2.0, which replaces Winbom.ini and Winpeoem.sif.
Before adding any custom scripts, you must first apply or mount a basic WinPE image (Winpe.wim) using ImageX.
1. Add custom scripts using Winpeshl.ini, you can start a custom shell application using a file named Winpeshl.ini. Winpeshl.exe will process the settings in Winpeshl.ini during startup. Use a text editor, such as Notepad, to create an Winpeshl.ini text file with the following structure. For example:
[Launchapp]
AppPath =%systemdrive%myshell.exe
[Launchapps]
%systemdrive%mydirapplication1.exe,-option1-option2
Application2.exe,-option1-option2
Note: Set the AppPath entry as the path to the shell application. This path can be a fully qualified path, or you can use an environment variable, such as%systemroot%system32myshell.exe. command line options are not supported for apppath items. Save this file to the%systemroot%system32 of the WinPE image.
2. Add custom scripts using Startnet.cmd, and use Startnet.cmd to add custom command-line scripts to WinPE. By default, WinPE includes the Startnet.cmd script, which is located in the%systemroot%system32 of the WinPE image. Currently, Startnet.cmd starts Wpeinit.exe. Wpeinit.exe is used to install Plug and Play (PnP) devices, process Unattend.xml settings, and load network resources. Edit Startnet.cmd to include custom commands.
Note: For PNP and network support, make sure that you include a call to Wpeinit in your custom Startnet.cmd script.
3, run Imagex/info d:boot.wim, view the WinPE image information. We should pay attention to this line:
Image Count:2
Description This WinPE image file contains two images in fact. The details of each image are shown in detail later. The special point here is that we need to edit a second image called WDS because WDS uses this image to boot the computer.
MOUNTRW the *.wim into the Pemount directory by using the ImageX command plus the parameters:
IMAGEX/MOUNTRW C:winpe2pe2.wim 2 C:pemount
Use the peimg command to add third-party drivers to WinPE 2.0, repeat this step if you need to add multiple device drivers.
Peimg/inf=c:winpe2netdrvxxx.inf c:pemountwindows
Use the ImageX command plus parameters unmount and commit to write the modifications to the *.wim
Imagex/unmount C:pemount/commit