Partilhar via


Update Windows settings and scripts: Create your own answer file

So far in this guide we've provided a few sample answer files that show how to change system settings (such as automating the Windows installation and setting your technical support information) and how to provide additional instructions (such as copying the built-in-administrator profile settings to the default user account).

In this section, we'll show you how to create your own answer file which you can use in the same way. We'll show you how to inject the answer file into an offline image, so that you can efficiently make changes without ever booting the image. To verify that the setting changes took place, we'll boot the image and make sure everything looks OK.

You’ll need Windows System Image Manager (Windows SIM), which is part of the Windows Assessment and Deployment Kit (Windows ADK), and is installed together with the Deployment Tools.

You’ll also need a copy of the Windows installation USB key you created earlier in the section: Install Windows automatically from a USB drive.

Windows settings overview

Many Windows settings, such as the Internet Explorer home page, can be set by using audit mode and CopyProfile. For more info, see Build to order: Use online servicing to make final updates to individual PCs.

Some settings, such as setting the manufacturer’s support information, can only be set by using an answer file. A full list of answer file settings (also known as Unattend settings) is in the Unattended Windows Setup Reference.

If you're manufacturing PCs for enterprises, those enterprises can control a number of settings by using Group Policy. For more info, see Group Policy.

When you add new settings, you’ll have a choice of which configuration pass to add the settings. Almost all of these settings can be added to one of these three configuration passes:

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

  • 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 PC again and add another batch of settings in the Specialize Configuration pass.

  • 7 oobeSystem: Use sparingly. These settings run after the user has completed OOBE, and can't be verified in audit mode.

    We'll show you two common settings:

    • Microsoft-Windows-Shell-Setup\FirstLogonCommands: Runs scripts after OOBE is complete. These scripts are commonly used to install apps that rely on the user to have already selected a default language. Again, use these scripts sparingly because long scripts can prevent the user from reaching the Start screen quickly. For retail versions of Windows, additional restrictions apply to these scripts. For info, see the Licensing and Policy guidance on the OEM Partner Center.

    • Microsoft-Windows-Deployment\Reseal\Mode = Audit: Use this to prepare the PC for build-to-order customizations. Later, when you boot the image, the PC will go directly into audit mode. Because we're setting up a script, this command is necessary to keep the script from accidentally running too early. Later, we'll need to make sure the PC is set to boot to OOBE - we'll show you how to do this in the next section, Build to order: Use online servicing to make final updates to individual PCs.

  • For info on the other configuration passes, see Windows Setup Configuration Passes.

Create and modify an answer file

Create a catalog file

  1. Start Windows System Image Manager.

  2. On the File menu, click Select Windows Image.

  3. In the Select a Windows Image dialog, browse to and select the base-image file. Next, select an edition of Windows, for example, Windows 8.1 Pro, and click OK. Click Yes to create the catalog file. Windows SIM creates the file based on the base-image file, and saves it to the Windows desktop. This process can take several minutes.

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

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

    • Make sure you are using a Windows 8.1 version of the Windows Assessment and Deployment Kit (Windows ADK) tools.

    • To create a catalog file for either 32-bit or ARM-based PCs, use a 32-bit PC.

    • Make sure the Windows base-image file (\Sources\Install.wim) is in a folder that has read-write privileges, such as a USB flash drive or on your hard drive.

Create an answer file

  1. On the File menu, click New Answer File.

    The new answer file appears in the Answer File pane.

Note

If you open an existing answer file, you might be prompted to associate the answer file with the image. Click Yes.

Add new answer file settings

  1. Set the Internet Explorer home page:

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

    In the Answer File pane, select Components\4 specialize\amd64_Microsoft-Windows-Microsoft-Windows-IE-InternetExplorer_neutral.

    In the IE-InternetExplorer Properties pane, in the Settings section, click Home_Page and add the URL of your web site.

  2. Prepare a script to run after OOBE is complete.

    In the Windows Image pane, right-click amd64_ Microsoft-Windows-Shell-Setup_(version) and then click Add Setting to Pass 7 oobeSystem.

    In the Answer File pane, expand Components\7 oobeSystem\amd64_ Microsoft-Windows- Shell-Setup _neutral\FirstLogonCommands. Right-click FirstLogonCommands and click Insert New SynchronousCommand.

    In the SynchronousCommand Properties pane, in the Settings section, add the following values:

    CommandLine = C:\Fabrikam\SampleCommand.cmd

    Description = Sample command to run a system diagnostic check.

    Order = 1

  3. Prepare your PC to boot to audit mode after the Windows installation is complete.

    In the Windows Image pane, expand Components, right-click amd64_ Microsoft-Windows-Deployment_(version), and click Add Setting to Pass 7 oobeSystem.

    In the Answer File pane, select Components\7 oobeSystem\amd64_ Microsoft-Windows-Deployment _neutral\Reseal.

    In the Reseal Properties pane, in the Settings section, change Mode = OOBE to Mode = Audit.

Create a script

  • Copy the following sample script into Notepad, and save it as E:\AnswerFiles\SampleCommand.cmd, where E is the drive letter of the external USB drive.

    md C:\Fabrikam
    C:\Windows\System32\dxdiag /t C:\Fabrikam\DxDiag-TestLogFiles.txt
    

Save the answer file

  • Save the answer file as E:\AnswerFiles\BootToAudit-x64.xml, where E is the drive letter of the external USB drive.

Note

Windows SIM will not allow you to save the answer file into the mounted image folders.

Add the answer file and script to a Windows image

  1. Mount the Windows image.

    Dism /Mount-Image /ImageFile:"C:\Images\ModelSpecificImage.wim" /Name:"Fabrikam" /MountDir:"C:\mount\windows
    
  2. Copy the file to the C:\Mount\Windows\Panther folder, replacing the existing Unattend.xml file if necessary.

    copy E:\AnswerFiles\BootToAudit-x64.xml C:\mount\windows\Windows\Panther\Unattend.xml
    

    where E is the drive letter of the external USB drive.

  3. Copy the sample command into the image.

    Md C:\mount\windows\Fabrikam
    
    copy E:\AnswerFiles\SampleCommand.cmd C:\mount\windows\Fabrikam\SampleCommand.cmd
    

    where E is the drive letter of the external USB drive.

  4. Commit the changes and unmount the Windows image:

    Dism /Unmount-Image /MountDir:"C:\mount\windows" /Commit
    
  5. Copy the changes to the USB key.

Verify your customizations in audit mode

  1. Boot a test PC to Windows PE, and run the scripts to apply a Windows image. For example:

    diskpart /s E:\Deployment\CreatePartitions-UEFI.txt
    
    E:\Deployment\ApplyImage-UEFI E:\Images\ThinImage.wim
    

    where E is the drive letter of the external USB drive.

  2. After the image is applied, disconnect the external USB drive and restart the PC by typing exit. After the PC reboots, if the Start screen appears, then you have correctly configured the settings to boot to audit mode.

Note

Troubleshooting: If the PC boots and OOBE starts, Windows is not in audit mode. Check the answer file to make sure that the Microsoft-Windows-Deployment\Reseal setting is set to Audit.

  1. Open the Desktop. If the System Preparation Tool (Sysprep) window is open, close it.

  2. In File Explorer, right-click This PC and then click Properties.

    If the System application from Control Panel appears and displays your manufacturer support information, you have correctly configured the settings that provide support information.

  3. From the Desktop, click the Internet Explorer icon in the taskbar. If your company web site appears, you have correctly configured the Internet Explorer settings.

Note

Windows Store apps, Internet Explorer and PC settings do not work in audit mode. Use Internet Explorer for the desktop and the desktop Control Panel settings instead.

  1. To check to see if your sample script ran, you'll need to set the PC to boot to OOBE, then complete OOBE like an end user. After that, you can check to see if the file: C:\Fabrikam\DxDiag-TestLogFiles.txt exists.

See Also

Concepts

OEM Windows Deployment and Imaging Walkthrough