Answer files (unattend.xml) | Microsoft Learn

Table of Contents0.1 In this article1 Windows settings overview2 Answer file settings3 Create and modify an answer file3.1 Step 1: Create a catalog file3.2 Step 2: Create an answer file3.3 Step 3: Add new answer file settings3.4 Step 4: Save the answer file3.5 Step 5: Create a script4 Add the […]

Answer files (or Unattend files) can be used to modify Windows settings in your images during Setup. You can also create settings that trigger scripts in your images that run after the first user creates their account and picks their default language.

Windows Setup will automatically search for answer files in certain locations, or you can specify an unattend file to use by using the /unattend: option when running Windows Setup (setup.exe).

Windows settings overview

While you can set many Windows settings in audit mode, some settings can only be set by using an answer file or Windows Configuration Designer, such as adding manufacturer’s support information. A full list of answer file settings (also known as Unattend settings) is in the Unattended Windows Setup Reference.

Enterprises can control other settings by using Group Policy. For more info, see Group Policy.

Answer file settings

You can specify which configuration pass to add new settings. Each configuration pass represents an installation phase where settings can be configured:

  • 1 windowsPE: These settings are used by the Windows Setup installation program. If you’re modifying existing images, you can usually ignore these settings.

  • 2 offlineServicing: These settings are applied to offline images where you apply an Unattend file with DISM using the Apply-Unattend option. When you apply an Unattend file with DISM to an offline image, only the settings in this configuration pass are processed.

  • 4 specialize: Most settings should be added here. These settings are triggered both at the beginning of audit mode and at the beginning of OOBE. If you need to make multiple updates or test settings, generalize the device again and add another batch of settings in the Specialize Configuration pass.

  • 6 auditUser: Runs as soon as you start audit mode.

    This is a great time to run a system test script – we’ll add Microsoft-Windows-DeploymentRunAsynchronousCommand as our example. To learn more, see Add a Custom Script to Windows Setup.

  • 7 oobeSystem: Use sparingly. Most of these settings run after the user completes OOBE. The exception is the Microsoft-Windows-DeploymentResealMode = Audit setting, which we’ll use to bypass OOBE and boot the PC into audit mode.

    If your script relies on knowing which language the user selects during OOBE, you’d add it to the oobeSystem pass.

  • To learn more, see Windows Setup Configuration Passes.

Create and modify an answer file

This section walks through how to create and modify an Unattend file using tools available in the Windows Assessment and Deployment Kit. When creating an Unattend file for your deployment, you can configure different or additional settings than what is described below.

Step 1: Create a catalog file

  1. Start Windows System Image Manager.

  2. Click File > Select Windows Image.

  3. In Select a Windows Image, browse to and select the image file (D:install.wim). Next, select an edition of Windows, for example, Windows 10 Pro, and click OK. Click Yes to create the catalog file. Windows SIM creates the file based on the image file, and saves it to the same folder as the image file. This process can take several minutes.

    The catalog file appears in the Windows Image pane. Windows SIM lists the configurable components and packages in that image.

    Tip

    If Windows SIM does not create the catalog file, try the following steps:

    • To create a catalog file for either 32-bit or Arm-based devices, use a 32-bit device.
    • Make sure the Windows base-image file (SourcesInstall.wim) is in a folder that has read-write privileges, such as a USB flash drive or on your hard drive.

Step 2: Create an answer file

Step 3: Add new answer file settings

  1. Add OEM info:

    1. In the Windows Image pane, expand Components, right-click amd64_Microsoft-Windows-Shell-Setup_(version), and then select Add Setting to Pass 4 specialize.

    2. In the Answer File pane, select Components4 specializeamd64_Microsoft-Windows-Shell-Setup_neutralOEMInformation.

    3. In the OEMInformation Properties pane, in the Settings section, select:

      • Manufacturer=Fabrikam
      • Model=Notebook Model 1
      • Logo=C:FabrikamFabrikam.bmp
    4. Create a 32-bit color graphic/logo with a maximum size of 120×120 pixels and save it as D:AnswerFilesFabrikam.bmp file on your local PC.

      We’ll copy the logo into the Windows image in a few steps.

  2. Set the device to automatically boot to audit mode:

    1. In the Windows Image pane, expand Components, right-click amd64_Microsoft-Windows-Deployment_(version), and then select Add Setting to Pass 7 oobeSystem.

    2. In the Answer File pane, select Components7 oobeSystemamd64_Microsoft-Windows-Deployment_neutralReseal.

    3. In the Reseal Properties pane, in the Settings section, select Mode=Audit.

  3. Prepare a script to run after Audit mode begins.

    1. In the Windows Image pane, right-click amd64_ Microsoft-Windows-Deployment_(version) and then click Add Setting to Pass 6 auditUser.

    2. In the Answer File pane, expand Components6 auditUseramd64_Microsoft-Windows-Deployment_neutralRunAsynchronous. Right-click RunAsynchronousCommand Properties and click Insert New AsynchronousCommand.

    3. In the AsynchronousCommand Properties pane, in the Settings section, add the following values:

      • Path = C:FabrikamSampleCommand.cmd
      • Description = Sample command to run a system diagnostic check.
      • Order = 1 (Determines the order that commands are run, starting with 1.)
  4. Add a registry key. In this example, we add a REG_SZ key called ABCD into HKLMSoftwareSample with a value of 10. This command will call CMD /c REG ADD, just as if you were creating a registry key from the Command prompt.

    Add RunAsynchronousCommands for each registry key to add. (Right-click RunAsynchronousCommand Properties and click Insert New AsynchronousCommand).

    Path = CMD /c REG ADD HKEY_LOCAL_MACHINESoftwareSample /v 10 /t REG_SZ ABCD
    Description = Adds a OEM registry key
    Order = 2
    RequiredUserInput = false
    

See the Unattended Windows Setup Reference for a full list of configuration options.

Step 4: Save the answer file

Step 5: Create a script

Since we specified a script to run in Step 3.3, let’s create that script now.

  • Copy the following sample script into Notepad, and save it as D:AnswerFilesSampleCommand.cmd.

    @rem Scan the integrity of system files 
    @rem (Required after removing the base English language from an image)
    sfc.exe /scannow
    
    @rem Check to see if your drivers are digitally signed, and send output to a log file.
    md C:Fabrikam
    C:WindowsSystem32dxdiag /t C:FabrikamDxDiag-TestLogFiles.txt
    

Add the answer file and script to the image

Step 6: Mount an image and add the answer file

  1. Use DISM to mount a Windows image. To learn how to mount an image, see Mount and modify a Windows image using DISM

  2. Copy the answer file into the image into the WindowsPanther folder, and name it unattend.xml. The Panther folder is one of the folders where Windows searches for an answer file. Create the folder if it doesn’t exist. If there’s an existing answer file, replace it or use Windows System Image Manager to edit/combine settings if necessary.

    MkDir c:mountwindowsWindowsPanther
    Copy D:AnswerFilesBootToAudit-x64.xml  C:mountwindowsWindowsPantherunattend.xml
    MkDir c:mountwindowsFabrikam
    Copy D:AnswerFilesFabrikam.bmp    C:mountwindowsFabrikamFabrikam.bmp
    Copy D:AnswerFilesSampleCommand.cmd    C:mountwindowsFabrikamSampleCommand.cmd
    
  3. Unmount the image, committing the changes. For example:

    Dism /Unmount-Image /MountDir:"C:mountwindows" /Commit
    

    where C is the drive letter of the drive that contains the mounted image.

    This process may take several minutes.

When you apply your image, Windows will process your unattend file and will configure your settings based on what you specified in the unattend.

Source Article

Next Post

RGL Home Page

Tue Nov 22 , 2022
Table of Contents1 Web Policies2 Government Sites3 Contact Us Skip to page content United States Department of Transportation FAA Home Federal Aviation Administration […]