Поделиться через


How Sysprep Works

The System Preparation tool, Sysprep.exe, is used to prepare an installation of Windows for imaging or delivery to a customer.

This topic includes:

  • Sysprep Executable
  • Sysprep Processes
  • Using an Answer File with Sysprep
  • Resetting Windows Activation
  • Detecting the State of a Windows Image
  • Sysprep Log Files

Sysprep Executable

Sysprep.exe is the main program that calls other executable files that prepare the Windows installation. Sysprep.exe is located in the %WINDIR%\system32\sysprep directory on all installations. Sysprep must always be run from the %WINDIR%\system32\sysprep directory and must run on the version of Windows with which it was installed.

Sysprep Process

When Sysprep runs, it goes through the following process:

  1. Verifies that Sysprep can run. Only an administrator can run Sysprep, and only one instance of Sysprep can run at a given time. Also, Sysprep must run on the version of Windows with which it was installed.
  2. Initializes logging.
  3. Parses command-line arguments.
    If no command-line arguments were provided, the Sysprep window appears that enables users to specify Sysprep actions.
  4. Processes Sysprep actions, calls appropriate .dll files and executable files, and adds actions to the log file.
  5. Verifies that all .dll files have processed all their tasks, and then either shuts down the system, restarts the system, or exits Sysprep.

Using Answer Files with Sysprep

You can use an answer file with Sysprep to configure unattended Setup settings. The following sections describe some of the considerations and processes for using answer files with Sysprep.

Applying Settings in the generalize, auditSystem and auditUser passes

Not all configuration passes run during Windows Setup. Some configuration passes are only available when you run Sysprep. The generalize, auditSystem and auditUser passes are available only by running Sysprep. If you add settings to your answer file in these configuration passes, you must run Sysprep to apply these settings:

  • To apply the settings in auditSystem and auditUser, you must boot to Audit mode by using the sysprep/audit command.
  • To apply the settings in the generalize pass, you must generalize the Windows image by using the sysprep/generalize command.

For more information, see How Configuration Passes Work. For more information about Sysprep command-line options, see Sysprep Command-Line Syntax.

Caching Answer Files to the Computer

If you install Windows by using an answer file, that answer file is cached to the system so when subsequent configuration passes run, settings in the answer file are applied to the system.

Because this answer file is cached, when you run Sysprep, settings in the cached answer file are applied. If you use the settings in a different answer file, you can specify a separate Unattend.xml file by using the **sysprep /unattend:**filename option. For more information, see Sysprep Command-Line Syntax.

For more information about using implicit answer file search, see How Windows Setup Works.

Persisting Plug and Play Device Drivers during generalize

You can persist device drivers when you run the sysprep /generalize command by specifying the PersistentAllDeviceInstalls setting in the Microsoft-Windows-PnPSysprep component. During the specialize pass, Plug and Play scans the computer for devices and installs device drivers for the detected devices. By default, these device drivers are removed from the system when you generalize the system. If you set PersistAllDeviceInstalls to True in an answer file, Sysprep will not remove the detected device drivers. For more information, see the Unattended Windows Setup Reference.

Displaying RunSynchronous Actions in an Answer File

In Audit mode, you can view the status for RunSynchronous commands that run during auditUser. The AuditUI window displays the status for commands and provides:

  • Visual progress to indicate that an installation is continuing and not suspended.
  • Visual indication of when and where failures occur. This provides quick diagnosis if log files are not created by the command.

If there are RunSynchronous commands in the answer file in the auditUser configuration pass, a list of the commands are displayed in the AudiUI window in the order specified by RunSynchronous/RunSynchronousCommand/Order. Each list item in the UI is either the string from:

  • RunSynchronous/RunSynchronousCommand/Description (if present)
    -OR-
  • RunSynchronous/RunSynchronousCommand/Path

All RunSynchronous commands are processed in order. If the command succeeds, then its related list item is annotated with a green checkmark. If the command fails, then its related list item is annotated with a red X. If a reboot is requested, the AuditUI is redisplayed after the boot but only unprocessed list items are displayed. Previously processed items no longer appear in the AuditUI. If the list of items in the AuditUI exceeds the height of the display, then the list is clipped to the display and does not scroll. As a result, some items might not be visible.

Windows Setup interprets the zero and nonzero return codes as status values in the AuditUI. A zero value indicates a success, while a nonzero value indicates a failure. The return value of the command might affect the behavior of the Setup, depending on the value of the RunSynchronous/RunSynchronousCommand/WillReboot command.

If RunSynchronous/RunSynchronousCommand/WillReboot is set to Always, then:

  • If the command returns 0, its related list item is annotated with a green checkmark. A reboot immediately occurs.
  • If the command returns nonzero, its related list item is annotated with a red X. A reboot immediately occurs.

If RunSynchronous/RunSynchronousCommand/WillReboot is set to Never, then:

  • If the command returns 0, its related list item is annotated with a green checkmark.
  • If the command returns nonzero, its related list item is annotated with a red X. A nonzero return value is not treated as a fatal error when WillReboot is set either to Always or Never.

If RunSynchronous/RunSynchronousCommand/WillReboot is set to OnRequest, then:

  • If the command returns 0, its related list item is annotated with a green check mark.
  • If the command returns 1, its related list item is annotated with a green check mark. A reboot immediately occurs.
  • If the command returns 2, its related list item is temporarily annotated with a green checkmark. A reboot immediately occurs. Following the reboot, the related list item is displayed again in the AuditUI without annotation because the command is still in process.
  • If the command returns other values, then a fatal error occurs and a blocking dialog is displayed. If the Errorhandler.cmd file is present, no dialog is displayed. For more information about Errorhandler.cmd, see Add a Custom Script to Windows Setup.

Resetting Windows Activation

When you install Windows with a single license product key, you have 30 days during which you must activate that installation of Windows. If you do not activate Windows within the 30 day period and do not reset the activation clock, Windows will enter RFM (Reduced Functionality Mode). This mode prevents users from logging on to the computer until Windows is activated.

There is no limit to the number of times Sysprep can run on a computer. However, the clock for Windows Product Activation begins its countdown the first time Windows starts. You can use the sysprep /generalize command to reset Windows Product Activation a maximum of three times. After the third time you run the sysprep /generalize command, the clock can no longer be reset.

When you run the sysprep /generalize command, the activation clock will automatically reset. You can bypass resetting the activation clock by using the SkipRearm setting in the Microsoft-Windows-Security-Licensing-SLC component. This enables you to run Sysprep multiple times without resetting the activation clock. For more information about this setting, see the Unattended Windows Setup Reference.

Important

If you anticipate running Sysprep multiple times on a single computer, you must use the SkipRearm setting in the Microsoft-Windows-Security-Licensing-SLC component to postpone resetting the activation clock. Because you can reset the activation clock only three times, if you run Sysprep multiple times on a computer, you might run out of activation clock resets. Microsoft recommends that you use the SkipRearm setting if you plan on running Sysprep multiple times on a computer.

Volume License and OEM Activation Requirements

For volume licenses, activation clock reset behavior is different, depending on the type of license.

  • Activation can be reset an unlimited number of times for an activated Key Management Service (KMS) clients. For non-activated KMS clients, the activation clock can be reset only up to three times, the same as a single license.
    Microsoft recommends that KMS clients use the sysprep /generalize command where the value of the SkipRearm setting is equal to 1. After capturing this image, use the sysprep /generalize command where the value of the SkipRearm setting is equal to 0.
  • For Multiple Activation Keys (MAK) clients, the recommendation is to install the MAK immediately before running Sysprep the last time before delivering the computer to a customer.

For OEM Activation licenses, activation is not required. OEM Activation is available only to royalty OEMs.

Activating Windows before Shipping to a Customer

Most customers can easily manage activation after receiving their computers. But if you prefer, you can activate the software on behalf of your customers, making it easier for them to start using their new computers. After activation is completed, most users will not need to activate their installation again.

To activate Windows for your customer, use the unique Product Key from the certificate of authenticity (COA) label that is affixed to the specific computer, and activate the computer on behalf of the end user. Run the sysprep /oobe command to prepare the computer for delivery to the customer.

Note

You cannot make an image of an activated Windows installation and duplicate that image to another computer. If you do, Windows fails to recognize the activation and forces the end user to reactivate the installation manually.

Booting to Audit Mode or Windows Welcome

When Windows Vista boots, there are two modes in which the computer will start:

  • Windows Welcome Windows Welcome, also called Machine OOBE (out-of-box experience), is the first user experience and enables end users to customize their Windows installation. End users can create user accounts, read and accept the Microsoft Software License Terms, and choose their language and time zones.
    By default, all Windows installations boot to Windows Welcome first.
    The oobeSystem configuration pass runs immediately before Windows Welcome starts. For more information about this configuration pass, see oobeSystem.
  • Audit Mode. Audit mode enables OEMs and corporations to add customizations to their Windows images. Audit mode does not require settings in Windows Welcome to be applied. By bypassing Windows Welcome, you can access the desktop quicker and perform your customizations. You can add additional device drivers, install applications, and test the validity of the installation.
    In Audit mode, settings in an unattended answer file in the auditSystem and auditUser configuration passes are processed. For more information about these configuration passes, see auditSystem and auditUser.
    If you are running in Audit mode, to configure the installation to boot to Windows Welcome, run the sysprep /oobe command. OEMs are required to run sysprep /oobe before shipping a computer to an end user. In a default Windows Vista installation, after installation completes, Windows Welcome starts. However, you can skip Windows Welcome and boot directly to Audit mode by pressing Ctrl+Shift+F3 at the first Windows Welcome screen.
    For unattended installation, you can configure Windows to boot to Audit mode by using the Microsoft-Windows-Deployment | Reseal setting in an answer file. For more information, see the Unattended Windows Setup Reference.

For more information about Audit mode, see Customize Windows in Audit Mode.

Detecting the State of a Windows Image

You can identify the state of a Windows image, whether it will boot to Audit mode, Windows Welcome, or if the image is still in the process of installation. For more information, see Windows Setup Installation Process.

Sysprep Log Files

Sysprep logs Windows setup actions in different directories, depending on the configuration pass. Because the generalize pass deletes certain Windows Setup log files, Sysprep logs generalize actions outside the standard Windows Setup log files. The following table shows the different log file locations that are used by Sysprep.

Item Log Path

generalize

%WINDIR%\System32\Sysprep\Panther

specialize

%WINDIR%\Panther\

Unattended Windows setup actions

%WINDIR%\Panther\Unattendgc

See Also

Concepts

What is Sysprep?
Sysprep Command-Line Syntax