Include a Custom Script in a Windows PE Image
Published: October 22, 2009
Updated: April 5, 2013
Applies To: Windows 7, Windows Server 2008 R2
|This content applies to Windows 7. For Windows 8 content, see Windows Deployment with the Windows ADK.|
The following procedure demonstrates how to add a customized script to an offline Windows® PE image. Windows PE provides three methods for launching custom scripts: Winpeshl.ini, Startnet.cmd, and Unattend.xml. The Windows PE default interface is a Command Prompt window. However, you can create a customized Winpeshl.ini file to run your own shell application. You can also create your own version of Startnet.cmd to run a specific set of commands, batch files, or scripts.
Before you can add customized scripts, you must first apply or mount the base Windows PE image by using the ImageX tool.
Add a Customized Script Using Winpeshl.ini
You can launch a customized shell application by using a file called Winpeshl.ini. Winpeshl.exe will process the settings in Winpeshl.ini during boot. If you create a customized Winpeshl.ini and require Plug and Play or network support, you must include a call to Wpeinit.exe. Wpeinit.exe specifically installs Plug and Play devices, processes answer file settings, and loads network resources.
Create a customized Windows PE image as shown in Walkthrough: Create a Custom Windows PE Image
Create a text file called Winpeshl.ini by using a text editor (such as Notepad) with the following structure. For example,
[LaunchApp] AppPath = %SYSTEMDRIVE%\myshell.exe [LaunchApps] %SYSTEMDRIVE%\mydir\application1.exe, -option1 -option2 application2.exe, -option1 -option2
AppPathentry to the path to your shell application. The path can either be fully qualified or use environment variables, such as %SYSTEMROOT%\System32\Myshell.exe. The
AppPathentry does not support command-line options.
Save the file to %SYSTEMROOT%\System32 of your customized Windows PE image.
Recapture your Windows PE image as described in Walkthrough: Create a Custom Windows PE Image.
Add a Customized Script Using Startnet.cmd
You can add customized command-line scripts in Windows PE by using Startnet.cmd. By default, Windows PE includes a Startnet.cmd script located at %SYSTEMROOT%\System32 of your customized Windows PE image. Startnet.cmd currently starts Wpeinit.exe. Wpeinit.exe specifically installs Plug and Play devices, processes answer file settings, and loads network resources.
|If winpeshl.ini is present in %windir%\System32 folder, the startnet.cmd script is ignored.|
Create a customized Windows PE image as described in Walkthrough: Create a Custom Windows PE Image.
Edit Startnet.cmd to include your customized commands.
Note For Plug and Play or networking support, ensure that you include a call to wpeinit in your customized Startnet.cmd script.
Save your changes and recapture your Windows PE image as described in Walkthrough: Create a Custom Windows PE Image.
Add Customizations Using Unattend.xml
You can use an answer file with Windows PE to specify various settings and actions. When Windows PE starts, it searches for a file called unattend.xml at the root of any bootable device (for example, a USB flash drive or a floppy disk). You can also specify an unattend.xml file by using Startnet.cmd and Wpeinit.exe.
To learn more about creating an answer file, see Work with Answer Files.
To learn more about Wpeinit, see Wpeinit Command-Line Options and the previous section on using Startnet.cmd.