Windows Sysprep and OOBE Automation by Unattend File

A Step-by-Step Guide of How to Automate Windows OOBE with an Unattend File using Sysprep.

a portrait of a male man on a computer drinking coffee and looking from the window - UFOtechs

Deploying Windows across multiple machines can be a repetitive and time-consuming task. However, by using an unattend file with Sysprep, you can automate the Windows Out-Of-Box Experience (OOBE) and ensure a consistent setup on all your devices. In this post, I'll guide you through the process of creating an unattend file and using it with Sysprep to prepare a master image for deployment.


What is an Unattend File?

An unattend file is an answer file that automates the OOBE process. It allows you to pre-configure settings and skip certain setup screens, making the deployment process faster and more efficient. This is especially useful in enterprise environments where you need to deploy Windows to multiple computers with the same configuration.


Ready-to-Use Unattend File

Below is a ready-to-use unattend file I have prepared that automates several parts of the Windows OOBE, including setting up locales, creating a local admin account, and hiding setup screens to finish the configuration without any human interaction. This file works for both Windows 10 and Windows 11.

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <InputLocale>en-US;ar-EG</InputLocale>
            <SystemLocale>en-US</SystemLocale>
            <UILanguage>en-US</UILanguage>
            <UILanguageFallback>en-US</UILanguageFallback>
            <UserLocale>en-US</UserLocale>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <OOBE>
                <HideEULAPage>true</HideEULAPage>
                <HideLocalAccountScreen>true</HideLocalAccountScreen>
                <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
                <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
                <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
                <NetworkLocation>Work</NetworkLocation>
                <ProtectYourPC>3</ProtectYourPC>
            </OOBE>
            <UserAccounts>
                <LocalAccounts>
                    <LocalAccount wcm:action="add">
                        <Password>
                            <Value>Admin123</Value>
                            <PlainText>true</PlainText>
                        </Password>
                        <Name>Admin</Name>
                        <Group>Administrators</Group>
                    </LocalAccount>
                </LocalAccounts>
            </UserAccounts>
            <TimeZone>Egypt Standard Time</TimeZone>
            <RegisteredOrganization>Windows User</RegisteredOrganization>
        </component>
    </settings>
    <cpi:offlineImage cpi:source="wim:d:/wims/win11.wim#Windows 11 Pro (Default official install) - Sysprepped" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>{codeBox}

You can edit, add, or remove some parts of the code depending on your requirements.


Explanation of the Unattend File Contents

Locale Settings:

  • InputLocale: Sets input languages to English (US) and Arabic (Egypt).
  • SystemLocale, UILanguage, UILanguageFallback, UserLocale: Sets system and UI languages to English (US).
You can change the language/region tag depending on your country. Check Microsoft language/region tags.

OOBE Settings:

This section automates the OOBE process (Keep it unchanged for automation).

User Account Setup:

Creates a local administrator account named "Admin" with the password "Admin123" and adds it to the Administrators group. You can change the username and password to anything you want.

Other Settings:

Sets the time zone to "Egypt Standard Time".

You can change the time zone depending on your country. Check Microsoft Time Zones.


Alternative Unattend File for Pre-Personalized Systems

If you’ve already customized the user settings on your Windows system before running Sysprep, you can use the following unattend answer file. This file ensures that your current settings are preserved while skipping the Out-Of-Box Experience (OOBE) entirely.

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="specialize">
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <CopyProfile>true</CopyProfile>
        </component>
    </settings>
    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <OOBE>
                <HideEULAPage>true</HideEULAPage>
                <SkipMachineOOBE>true</SkipMachineOOBE>
                <SkipUserOOBE>true</SkipUserOOBE>
            </OOBE>
        </component>
    </settings>
</unattend>{codeBox}


Explanation of this Unattend File

CopyProfile:
Setting this to true ensures that your customized user profile is copied to the default profile. This is especially useful when you have personalized settings, desktop arrangements, or configurations that you want replicated across all users.


OOBE Settings:
<HideEULAPage> Skips the End User License Agreement (EULA) page during setup.
<SkipMachineOOBE> Bypasses machine-specific OOBE steps.
<SkipUserOOBE> Skips user-specific OOBE steps, completing the setup process automatically.


Steps to Use Sysprep with the Unattend File

Step 1: Create the Unattend File

Copy the XML code into a text editor and save it as unattend.txt, and make your edits before using it.

Step 2: Place the Unattend File

Move the unattend.txt file to the root of the C: drive.

Step 3: Run Sysprep

  • Open Command Prompt as an administrator.
  • Run the following command to execute Sysprep with the unattend file
    sysprep /oobe /shutdown /unattend:c:\unattend.txt{codeBox}

    This command prepares the system for OOBE, applies the unattend file settings, and then shuts down the computer.


Conclusion

Automating Windows OOBE with an unattend file and Sysprep can significantly reduce the time and effort needed to set up multiple machines. Try creating your own unattend file using the example above and see how it can streamline your Windows installations. For a simpler alternative, try WUG (Windows Unattend Generator) tool.

The WUG Tool eliminates the need for scripting. Just copy and paste the bellow command to PowerShell then press Enter and it will generates the unattend file and automatically saves it to c:\ drive (must have internet access).
irm https://bit.ly/WUG | iex{codeBox}

Or download the tool (for offline use).


If you have any questions or need further assistance, feel free to leave a comment!

The provided unattend XML code is tested on Windows 10 version 22H2 and Windows 11 all versions, but not verified on older versions of windows 10.{alertInfo}

Post a Comment

Previous Post Next Post

Contact Form