Edit the Answer File – Unattend.xml

The answer file for Setup, typically called Unattend.xml, is used along with the System Preparation tool (Sysprep) to prepare an installation of Windows operating system for duplication or imaging by capturing a customized Windows master image that we can reuse throughout our organization.

The following is an example of running Syprep with the answer file:

Sysprep /generalize /oobe /shutdown /unattend: Unattend.xml

When you run Sysprep /generalize /oobe command, on the next reboot after you run this command, Windows runs the Specialize configuration pass, Plug and Play, and other Setup tasks before Windows starts OOBE. In order to get past the OOBE screens, an unattend file is used to specify values that apply to the 3, 4 and 7 installation passes, such as the names of user accounts, display settings, how to partition disks, the location of the Windows image to install, and the product key to apply. The Sysprep /unattend option in the above command allows us to use an answer file to automate this process and address Generalize, Specialize and OOBE settings.

The following sections in this blog will demonstrate my way to modify a ‘Generic Answer File’ and change the values such as the Computer Name, User Password, Language settings and Product Key. It should be noted that this can be done for any values in the ‘Generic Answer File’ for as long as there are unique strings to search and replace on.

Generic Answer File

The generic answer file described in this blog has certain characteristics.

Firstly, I am using Imagex.exe tool to apply a captured image and therefore the WinPE pass settings are removed from the sample answer file. In addition, I want to use in my example the AdministratorPassword/AutoLogon feature, and since I am deploying into a workgroup, I have to either specify an extra account in the unattend.xml, or the Windows 7 setup will prompt for a user account creation. Since I have enabled the administrator account and specified that user as an extra account, there is no need for creating an extra user which later may have to be deleted.

Secondly, in the example provided here, my generic answer file has the following unique strings:

  • ‘TEST-123’
  • ‘TEST-ORG’
  • ‘TEST-OWNER’
  • ‘Pacific Standard Time’
  • ‘0409:00000409’
  • ‘en-US’
  • ‘XXXXX-XXXXX-XXXXX-XXXXX-XXXXX’
  • ‘P@ssw0rd’

Form-UnattendFile

Picture 1: Generic answers file with unique strings

How Generic Answer File is used?

1. Reference Computer – run Sysprep

The generic file is used in the process of building a master image on a reference computer.

This building process comprises the following stages:

  • You install Windows OS on a reference computer.
  • After the installation is complete, you boot the computer and install any additional device drivers or applications. Copy the generic answer file into Sysprep directory and name it EditUnattend.xml
  • After you update the Windows installation, you run the Sysprep /generalize /oobe /shutdown /unattend: EditUnattend.xml command. The answer file is validated and then cached to the computer’s %WINDIR%\panther directory where the name of the answer file must be Unattend.xml.
  • After the reference computer shuts down, you can boot to WinPE (in my example: WinPE-DualBootExternalUSBDrive or WinPE-UEFI-BootExternalUSBDrive) to capture the Windows installation with ImageX.exe.

 2. Destination Computer – Edit and Apply Answer File

Boot the destination computer by using your bootable Windows PE media or in my example: WinPE-DualBootExternalUSBDrive or WinPE-UEFI-BootExternalUSBDrive.  If you use my aforementioned WinPE bootable media, you know that default disk formatting option for a destination computer’s hard drive creates two new partitions: the first one with the letter S: for active and hidden System partition and the second one with the letter W: for a partition labelled Windows. This means when you apply the master image, it will be applied to the Windows partition and therefore the location of the Generic Answer File is: W:\Windows\Panther\Unattend.xml.

The form shown in the picture 2 – Edit/Update Unattend File by default looks into the W:\Windows\Panther folder. When you click ‘Read File’ button the form reads the Unattend.xml file and displays all unique strings.

FormEditAnswerFile

 

 

 

 

 

 

 

 

 

 

Picture 2: Edit/Update Unattend File form read the file and displays all unique strings.

The last step as shown in the picture 3 is to change the values in the Unattend .xml file for settings such as the computer name, register organization and owner, product key, etc. To update values in the Unatted.xml file, click the ‘Update File’ button.

CompareTwoForms

Picture 3: change the values in the Unattend .xml file and click ‘Update File’ button.

Note: This is the last step before restarting a destination computer. Once you restart a destination computer the windeploy.exe will finish setup with the changed settings in the Unattend .xml file. This process could be observed if you open and check these log files: setupact.log and setuperr.log, both located in this folder: C:\Windows\Panther\UnattendGC.

WinPE Bootable Media

I have updated my PowerShell scripts in order to include ‘Edit/Update Sysprep Form’ in two WinPE downloads available from my previous posts about USB bootable media:  WinPE – Dual Boot External USB Drive and UEFI Bootable External USB Drive.

The new ‘Apply Image’ portion comprises three tabs as shown in the picture below.

ApplyImage_Partitions

Picture 4: Select MBR or UEFI partition scheme prior to selecting and applying image file.

ApplyImage_SelectOne

Picture 5: Select image file and click on ‘Apply’ button to start the process of applying image on the computer’s hard drive.

Note: selecting desired partition scheme and an installation image as shown in the picture 4 and 5 are mandatory steps.

ApplyImage_Sysprep

Picture 6: Once the image file has been applied to the computer’s hard drive, you can use third tab ‘Sysprep’ to read and update the unattend.xml file.

IMPORTANT: The above Sysprep addition is optional and could be done only in the case that you applied an image previously created with Sysprep /generalize /oobe /shutdown /unattend: EditUnattend.xml command where EditUnattend.xml is a generic answer file. You cannot use this option with a non-sysprepped image or an image that is prepared with a Sysprep command, but the answer file does not have the unique strings to search and replace on.

To download the updated scripts and generic answer file, please go to the site’s download section, expand the Application folder and select: WinPE-Sysprep.

 


 

Leave a Reply

Your email address will not be published. Required fields are marked *