Partager via


Advanced Unattended Installation Scenarios

Applies To: Windows Server 2008, Windows Server 2008 R2

This topic contains information about advanced tasks that you can implement with Windows Deployment Services.

In This Topic

  • Passing Unattend Files to Setup by Using the Command Line

  • Using Implicit Unattend Files

  • Embedding an Unattend File in an Image

  • Understanding Unattend File Precedence

  • Setting Command-Line Precedence for Image Unattend Files

  • Using Variables to Obtain Information from the Client

Passing Unattend Files to Setup by Using the Command Line

It is possible to pass a Windows Deployment Services client unattend file directly to Setup.exe instead of obtaining the unattend file from the server. You can do this using /unattend:<unattend file> and /wds (for example, Setup.exe /WDS /Unattend:X:\WDSClientUnattend.xml). If you are booting Windows PE by using a CD, DVD, or hard disk drive, you must also invoke the Windows Deployment Services client in discover mode by using the /WDSDiscover option. Note, however, that in this scenario you must use an unattend file that combines the settings for the client and the image phases of Setup. To see an example of a combined file, see the “Combined Image and Client Unattend File” section of Sample Unattend Files (https://go.microsoft.com/fwlink/?LinkId=122642).

For more information about Windows Deployment Services mode, see the “When Setup Is Started in Windows Deployment Services Mode” section in How the Windows Deployment Services Client Works (https://go.microsoft.com/fwlink/?LinkID=147067).

The following is an example scenario:

  1. A client computer boots into a version of Windows PE that contains the necessary Setup files. The boot can be performed over the network, from a CD or DVD, or from the hard disk drive.

  2. A custom application is invoked, which has a customized user interface (UI).

  3. The application detects the computer’s MAC address and contacts a database to get the specified Windows Deployment Services client unattend file.

  4. The application uses the Windows Deployment Services to retrieve a list of available images that are stored on a Windows Deployment Services server, and then it displays this list to the user.

  5. The user selects an image.

  6. The application takes the selected image and inserts the appropriate data into the Windows Deployment Services client unattend file.

  7. The application invokes Setup.exe in Windows Deployment Services mode, and then it passes Setup.exe a Windows Deployment Services client unattend file.

  8. The installation proceeds.

Using Implicit Unattend Files

You can use implicit unattend files, which means that if an unattend file is not specified (through the command line or from the Windows Deployment Services server), Windows Deployment Services searches for an unattend file in several locations. The most common scenario involves using a file called AutoUnattend.xml, which is at the root of removable media (such as a CD, DVD, or USB flash drive). For more information about implicit search paths, see Methods of Running Windows Setup at https://go.microsoft.com/fwlink/?LinkId=120686.

Embedding an Unattend File in an Image

In general, it is a best practice to store unattend files outside of the images. The main reason for this is flexibility; it is easier to modify an image that is on a file share on the Windows Deployment Services server than it is to disable, export, and mount the image, then modify the unattend file, and finally reimport the image. However, there are some cases where you may want to include an unattend file in a boot or install image. The following is an example of a scenario in which you may want to do this.

There are two types of computers in your organization — laptops and desktops. Your company policy states that all laptops should be configured with two partitions to support BitLocker Drive Encryption, and desktops should have a single partition and do not need BitLocker support. You create a custom boot image that is configured to run a simple script. The first action in the script is to use Windows Management Instrumentation (WMI) calls to determine whether a particular booted client computer is a laptop or a desktop.

  • If the computer is a laptop, the script calls Setup.exe by using the /wds option and then passes an Unattend.xml file for laptop use (one that creates two hard disk partitions).

  • If the computer is a desktop, the script calls Setup.exe by using the /wds option and then explicitly passes an Unattend.xml file for desktop use (one that creates only a single partition).

Understanding Unattend File Precedence

The following table outlines the precedence for unattend files. Note that you cannot change this precedence order.

Windows Deployment Services client unattend file Image unattend file

A Windows Deployment Services client unattend file that is defined always overrides an implicit unattend file. The order of precedence for this file is as follows:

  1. Unattend files that are passed explicitly from the command line (for example, setup.exe /wds /unattend:<unattend file>)

  2. Unattend files that are defined on the server

  3. An implicit unattend file (AutoUnattend.xml)

The order of precedence for this file is as follows:

  1. Image unattend files that you have associated with an image using WDSUTIL or the MMC snap-in. This does not apply to operating systems released prior to Windows Vista.

  2. Image unattend files located in the $OEM$ structure. This only applies to operating systems released prior to Windows Vista. For more information, see the second section of the How Unattended Installation Works topic.

  3. Template unattend files (used as part of a domain join). For more information about this file, see the “Modifying Your Unattend Files” section of Automating the Domain Join.

  4. Windows Deployment Services client unattend files if it contains sections for the additional phases of Setup. To see an example of a combined file, see the “Combined Image and Client Unattend File” section of Sample Unattend Files (https://go.microsoft.com/fwlink/?LinkId=122642).

Setting Command-Line Precedence for Image Unattend Files

There are installation scenarios in which you may want to use the same Unattend.xml file for automating the Windows Deployment Services client and subsequent phases of Setup when performing a custom deployment solution. Note that command-line precedence does not apply to Windows Deployment Services client unattend files that are obtained from the Windows Deployment Services server. By setting the command-line precedence value, you can specify whether another unattend file (either an implicit unattend file such as AutoUnattend.xml, or an unattend file passed by using the /Unattend option) will be used instead of the image unattend file when installing a client computer. To override an existing image unattend file that is associated with an image, first enable unattend installations by running the command wdsutil /set-server /wdsunattend /Policy:Enabled. Next, run one of the following:

  • To allow an unattend file on the client computer to override the unattend file sent from the server, run WDSUTIL /Set-Server /WDSUnattend /CommandLinePrecedence:Yes.

  • To force the unattend file from the server to be used, run WDSUTIL /Set-server /WDSUnattend /CommandLinePrecedence:No.

The following is an example scenario:

There are two types of computers in your organization — laptops and desktops. Your company policy states that all laptops should be configured with two partitions and should contain the proper Bluetooth drivers and software. It also states that desktops should have a single partition and do not need Bluetooth support. Because the majority of the computers in your organization are desktops, you create a Windows Deployment Services client unattend file that creates a single disk partition. Then you create a Windows Vista image with an image unattend file that does not install the Bluetooth drivers and software. Next, you create a single Unattend.xml file that performs all of the custom actions needed for laptop installations. Finally, you create a custom boot image that is configured to run a script. The first action in the script is to use WMI calls to determine whether a booted client computer is a laptop or a desktop.

  • If the computer is a laptop, the script calls Setup.exe by using the /wds option and then explicitly passes the custom Unattend.xml file for laptop use. To ensure that this unattend is used throughout the process, you set the command-line precedence value appropriately. This action causes the unattend file that is passed to the Windows Deployment Services client through the command line to override the existing image unattend file that is associated with the image on the server.

  • If the computer is a desktop, the script invokes the client normally, enabling the typical installation to continue (the client will obtain both the Windows Deployment Services client unattend file and, later, the image unattend file from the server).

Using Variables to Obtain Information from the Client

Windows Deployment Services can obtain information during an installation, which you can use as part of a custom deployment scenario. Windows Deployment Services will insert the proper values into your unattend file automatically as long as the file is formatted correctly. The variables that the client can use for this purpose are:

  • %USERDOMAIN%. The name of the user's domain, which was specified either by credentials or in the Windows Deployment Services client unattend file.

  • %USERNAME%. The user's name, which was specified either by credentials or in the Windows Deployment Services client unattend file.

  • %USERPASSWORD%. The user's password, which was specified either by credentials or in the Windows Deployment Services client unattend file. We do not recommend using this variable because it may pose a security risk. The password will be written to the unattend file in plain text.

  • %MACHINEDOMAIN%. The domain that contains the computer account that represents the physical client computer.

  • %MACHINENAME%. The computer name of the computer account that represents the physical client computer.

  • %TIMEZONE%. The time zone of the Windows Deployment Services server.

  • %ORGNAME%. The organization name of the Windows Deployment Services server.

To see an example file that uses these variables, see Sample Unattend Files.