Run a Custom Script (Standard 7 SP1)
7/8/2014
Image Builder is the program that installs Standard 7. Image Builder is also the basis for the following installation methods: Image Builder Wizard, Image Builder in unattended mode, and Windows Deployment Services (WDS).
Image Builder Installation Types
Image Builder can perform two types of installations:
- Interactive installation using Image Builder Wizard.
- Unattended mode using the Unattend.xml file produced by Image Configuration Editor.
Image Builder Process
Image Builder program starts and restarts the computer, collects information, copies files, and creates or adjusts configuration settings. The following table shows the overall process for Image Builder.
Image Builder Phase |
Image Builder Actions |
---|---|
Windows Preinstallation Environment (Windows PE) 3.0 (for starting one of the Standard 7 DVDs or starting a custom Windows PE image) |
|
Online configuration |
Creates specific configurations. This makes the Standard 7 installation unique. |
Windows Welcome |
|
Starting in Windows Welcome or Starting in Audit Mode
There are two modes in which a Standard 7 installation can start:
- Windows Welcome
Windows Welcome, previously known as Machine OOBE (out-of-box experience), is the first user experience and enables end-users to customize their Standard 7 installation. Users can create user accounts, read and accept the Software License Terms, and choose their language and time zones.
By default, all Standard 7 installations start Windows Welcome first. - Audit Mode
Audit mode is used by OEMs and IT professionals to add customizations to their Standard 7 images. Audit mode does not require settings in Windows Welcome to be applied. By bypassing Windows Welcome, you can access the desktop more quickly and make your customizations. You can add device drivers, install applications, and test the validity of the installation.
For more information about audit mode, see Customize in Audit Mode.
Oobe.xml Content File
In addition to the unattended Image Builder answer file, you can use the Oobe.xml content file to configure what a customer sees when they start Standard 7 for the first time. Settings in an Oobe.xml content file are applied after the oobeSystem configuration pass, before Windows Welcome starts.
Oobe.xml is a file that is used to collect additional text and images for customizing Windows Welcome, Welcome Center, and ISP Sign-Up. If you build a single Standard 7 image that contains multiple languages and can be delivered to more than one country/region, you can add multiple Oobe.xml files to customize the content based on the language and country/region selections of the end-user.
For more information about how to use the Oobe.xml answer file, see the Oobe.xml Technical Reference.
Automatically Running Scripts after Image Builder Is Complete
You can make additional customizations to the Standard 7 installation by adding commands to the %WINDIR%\Setup\Scripts\SetupComplete.cmd file. This file enables you to install additional applications or make other modifications to the system before a user logs on. You can use the SetupComplete.cmd file to run custom Standard 7 scripts (CScript/WScript).
In addition, if Image Builder encounters a fatal error, you can configure the system to automatically run a script. For more information, see Add Custom Scripts and Registry Keys to an Answer File.
There are several "states" assigned to a Standard 7 image during installation. This state information can be used to automatically detect the different states and stages of Image Builder.
The Standard 7 image state is stored in two locations, in the registry and in a file.
- In the registry:
KEY: HKLM\SOFTWARE\Microsoft\Windows Embedded Standard 7\CurrentVersion\Setup\State
TYPE: REG_SZ
VALUE: StateName - In a file:
FILE: %WINDIR%\Setup\State\State.ini
SECTION: [State]
VALUE: StateName
The following table describes the different values that exist for StateName.
State Name |
Description |
---|---|
IMAGE_STATE_COMPLETE |
The image has successfully been installed. The specialize and oobeSystem passes are completed. This image is not deployable to alternative hardware because it is now hardware-dependent. |
IMAGE_STATE_UNDEPLOYABLE |
This is the default state for an image in a given phase of Image Builder that is not yet completed. If a process queries the IMAGE_STATE value and IMG_UNDEPLOYABLE is returned, the image is in one of the following states:
|
IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE |
The image has successfully completed the generalize pass and continues to oobeSystem when Image Builder is started. |
IMAGE_STATE_GENERALIZE_RESEAL_TO_AUDIT |
The image has successfully completed the generalize pass and continues to audit mode when Image Builder is started. |
IMAGE_STATE_SPECIALIZE_RESEAL_TO_OOBE |
The image has successfully completed the specialize pass and continues to oobeSystem when Image Builder is started. |
IMAGE_STATE_SPECIALIZE_RESEAL_TO_AUDIT |
The image has successfully completed the specialize pass and continues to audit mode when Image Builder is started. |
The following examples show you how to access state information.
To access state information from the registry, type the following registry query command at a command prompt:
C:\>reg query HKLM\SOFTWARE\Microsoft\Windows Embedded Standard 7\CurrentVersion\Setup\State /v ImageState
The device will return the image state, as listed in the preceding table.
To access state information from a file, type the following to output the contents of the State.ini file:
C:\>type %windir%\Setup\State\State.ini
The [State] section of the State.ini file will contain the image state, as shown in the preceding table.
Image Builder Log Files
Image Builder logs all image-based setup actions in the following directories.
Log File Location |
Description |
---|---|
$windows.~bt\Sources\Panther |
Log location before Image Builder can access the drive. |
$windows.~bt\Sources\Rollback |
Log location when Image Builder rolls back if there is a fatal error. |
%WINDIR%\Panther |
Log location of setup actions after disk configuration. |
%WINDIR%\Inf\Setupapi*.log |
Used to log Plug and Play device installations. |
%WINDIR%\Memory.dmp |
Location of memory dumps from bug checks. |
%WINDIR%\Minidump\*.dmp |
Location of log minidumps from bug checks. |
%WINDIR%\System32\Sysprep\Panther |
Location of Sysprep logs. |
Review the log files in these directories to help troubleshoot installations.