Go to ...

RSS Feed

Windows 10 – MAK Activation using Answer File


A week and a half ago I saw an interesting post on Ten Forums: it concerned image customization and deployment of that custom image. The case started with CopyProfile issues, during which phase custom settings were not being applied on target devices. Finally, when that was resolved, another issue appeared: target devices were not activated as they should have been, although a valid and correct MAK key was included in that answer file.

The most common mistake around automatic MAK activation failure occurs when the MAK key in the answer file is used in the wrong way and in an inapplicable Settings pass. When creating an answer file, the UserData > ProductKey component can only be added during Settings pass 1, WindowsPE (which appears in the list below as the first item under Components):

Click to open enlarged in a new tab.

Its only purpose is to select an OS edition to install, using a generic product key. Here, a generic Windows 10 PRO key in UserData > ProductKey is added to Settings pass 1 WindowsPE (click expand source to view the code):

       <UserData>
                <AcceptEula>true</AcceptEula>
                <Organization>Win10.guru</Organization>
                <ProductKey>
                    <Key>VK7JG-NPHTM-C97JM-9MPGT-3V66T</Key>
                </ProductKey>
            </UserData>

This would select the PRO edition for use during installation. Using a MAK or Retail key here would not activate Windows on the target device. Rather, it only tells Windows Setup which edition to install.

We can use Synchronous commands in another pass, Settings pass 4 Specialize to activate Windows. Synchronous commands are commands run during the OOBE phase. Also, they represent commands which must run to completion before the next command in the sequence is run. For commands that can started simultaneosly, or whose execution can overlap, we use Asynchronous commands instead. Both Synchronous and Asynchronous commands belong to the Microsoft-Windows-Deployment component. They may be invoked either during Settings pass 6 AuditUser, or Settings pass 4 Specialize. Which pass to use depends on whether the command is run for a specific user (run during the AuditUser pass), or whether it is a global, system command (run during the Specialize pass).

I use the following component in Settings pass 4 Specialize with two commands to activate Windows on a target device using a MAK key:

        <component name="Microsoft-Windows-Deployment" 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">
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Description>Insert MAK key</Description>
                    <Order>1</Order>
                    <Path>cscript slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX</Path>
                </RunSynchronousCommand>
                <RunSynchronousCommand wcm:action="add">
                    <Description>Activate Windows</Description>
                    <Order>2</Order>
                    <Path>cscript slmgr.vbs /ato</Path>
                </RunSynchronousCommand>
            </RunSynchronous>
        </component>

The fist synchronous command runs Windows Software License Manager (slmgr.vbs) script installs the supplied MAK key. The second command activates Windows 10 using that key.

Here’s the standard unattend.xml answer file I use when sysprepping a reference machine, with both synchronous commands added to Settings pass 4 Specialize. You can use this basic answer file yourself, too. Please, just remember to edit the locale settings (in my case EN-GB OS, Finnish keyboard), initial admin user and organizational data:

<?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>0809:0000040b</InputLocale>
            <SystemLocale>EN-GB</SystemLocale>
            <UILanguage>EN-GB</UILanguage>
            <UILanguageFallback>EN-GB</UILanguageFallback>
            <UserLocale>EN-GB</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>
                <VMModeOptimizations>
                    <SkipAdministratorProfileRemoval>false</SkipAdministratorProfileRemoval>
                </VMModeOptimizations>
                <HideEULAPage>true</HideEULAPage>
                <HideLocalAccountScreen>true</HideLocalAccountScreen>
                <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
                <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
                <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
                <ProtectYourPC>1</ProtectYourPC>
                <UnattendEnableRetailDemo>false</UnattendEnableRetailDemo>
            </OOBE>
            <UserAccounts>
                <LocalAccounts>
                    <LocalAccount wcm:action="add">
                        <Description>Local admin account</Description>
                        <DisplayName>Kari</DisplayName>
                        <Group>Administrators</Group>
                        <Name>Kari</Name>
                    </LocalAccount>
                </LocalAccounts>
            </UserAccounts>
            <RegisteredOrganization>Win10.guru</RegisteredOrganization>
            <RegisteredOwner>Kari</RegisteredOwner>
            <TimeZone>W. Europe Standard Time</TimeZone>
        </component>
    </settings>
    <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">
            <OEMInformation>
                <Manufacturer>Win10.guru</Manufacturer>
                <SupportHours>24/7</SupportHours>
                <SupportPhone>+49 176 XXXXXXXX</SupportPhone>
                <SupportProvider>Win10.guru</SupportProvider>
                <SupportURL>https://win10.guru</SupportURL>
            </OEMInformation>
            <ComputerName>*</ComputerName>
            <OEMName>Win10.guru</OEMName>
            <RegisteredOrganization>Win10.guru</RegisteredOrganization>
            <RegisteredOwner>Kari</RegisteredOwner>
            <TimeZone>W. Europe Standard time</TimeZone>
            <CopyProfile>true</CopyProfile>
        </component>
        <component name="Microsoft-Windows-Deployment" 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">
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Description>Insert MAK key</Description>
                    <Order>1</Order>
                    <Path>cscript slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX</Path>
                </RunSynchronousCommand>
                <RunSynchronousCommand wcm:action="add">
                    <Description>Activate Windows</Description>
                    <Order>2</Order>
                    <Path>cscript slmgr.vbs /ato</Path>
                </RunSynchronousCommand>
            </RunSynchronous>
        </component>
    </settings>
</unattend>

That’s it. It is easy to use synchronous commands to run the Windows Software Licence Manager (slmgr.vbs) to activate Windows 10 automatically without user interaction on devices without an existing digital license. Notice that, of course, Windows must have Internet connection for this to work.

Kari

Author: Kari Finn

A former Windows Insider MVP, Kari started in computing in the mid 80’s writing code for VAX / VMS systems. Since then, he’s worked in a variety of IT positions. He specializes in Windows image capture, customization, repair and deployment as well as Hyper-V virtualization. Kari is a proud Team Member at number #1 Windows site TenForums.com.

Leave a Reply