This section provides low-level reference material covering the internal mechanics shared across all MAS scripts: the common execution architecture, Windows service and component dependencies, and the diagnostic patterns that govern error detection and reporting.
dk_ subroutine family and script structure in detail, see Script Architecture.Every MAS script — whether the all-in-one MAS_AIO.cmd or any individual script in Separate-Files-Version/ — follows the same startup sequence before any activation logic runs. This sequence is not optional or configurable; it runs unconditionally on every launch.
Shared startup sequence diagram:
Sources: MAS/All-In-One-Version-KL/MAS_AIO.cmd29-130 MAS/All-In-One-Version-KL/MAS_AIO.cmd218-300 MAS/All-In-One-Version-KL/MAS_AIO.cmd305-396
dk_ Subroutine FamilyAll activation scripts share a set of labeled subroutines prefixed dk_. These routines implement the common infrastructure. The table below maps each subroutine to its location and function.
| Subroutine | Location (line) | Purpose |
|---|---|---|
dk_setvar | MAS/All-In-One-Version-KL/MAS_AIO.cmd1155-1205 | Initialize winbuild, psc, _slexe/_slser, _NCS, color variables, eline, nceline, _exitmsg, _fixmsg |
dk_showosinfo | MAS/All-In-One-Version-KL/MAS_AIO.cmd1209-1223 | Print OS name, full build string, and processor architecture |
dk_checksku | MAS/All-In-One-Version-KL/MAS_AIO.cmd1227-1259 | Detect osSKU, slcSKU, wmiSKU, regSKU; detect Windows Subscription via ClipGetSubscriptionStatus |
dk_chkmal | MAS/All-In-One-Version-KL/MAS_AIO.cmd1508-1547 | Check for KMSpico, antivirus host blocking, file infector signatures (error 577/225 from sc start sppsvc) |
dk_errorcheck | MAS/All-In-One-Version-KL/MAS_AIO.cmd1551-1660 | Run all pre-activation checks: sandboxing, WinPE, safe mode, ImageState, corrupt/disabled services |
dk_sppissue | MAS/All-In-One-Version-KL/MAS_AIO.cmd1446-1462 | Start SPP service; warn if stuck or slow (30s timeout via Start-Job) |
dk_checkperm | MAS/All-In-One-Version-KL/MAS_AIO.cmd1282-1286 | Query SoftwareLicensingProduct for LicenseStatus=1, GracePeriodRemaining=0 to detect permanent activation |
dk_actids | MAS/All-In-One-Version-KL/MAS_AIO.cmd1338-1360 | Enumerate all activation IDs for an ApplicationID via SoftwareLicensingProduct |
dk_actid | MAS/All-In-One-Version-KL/MAS_AIO.cmd1364-1370 | Enumerate only installed (keyed) activation IDs |
dk_inskey | MAS/All-In-One-Version-KL/MAS_AIO.cmd1298-1322 | Install a product key via SoftwareLicensingService.InstallProductKey |
dk_act | MAS/All-In-One-Version-KL/MAS_AIO.cmd1326-1334 | Trigger activation via SoftwareLicensingProduct.Activate |
dk_refresh | MAS/All-In-One-Version-KL/MAS_AIO.cmd1290-1294 | Call SoftwareLicensingService.RefreshLicenseStatus |
dk_reeval | MAS/All-In-One-Version-KL/MAS_AIO.cmd1374-1388 | Delete SPP PersistedSystemState keys; trigger SLpTriggerServiceWorker('reeval') via sppc.dll |
dk_product | MAS/All-In-One-Version-KL/MAS_AIO.cmd1466-1495 | Get OS display name via BrandingFormatString from winbrand.dll; fall back to registry ProductName |
dk_reflection | MAS/All-In-One-Version-KL/MAS_AIO.cmd1499-1504 | Emit common $AssemblyBuilder/$ModuleBuilder/$TypeBuilder PowerShell P/Invoke setup code |
dk_ckeckwmic | MAS/All-In-One-Version-KL/MAS_AIO.cmd1435-1442 | Set _wmic=1 if wmic.exe is functional; _wmic=0 otherwise (affects all WMI calls in the script) |
dk_color | MAS/All-In-One-Version-KL/MAS_AIO.cmd1173-1194 | Print one colored line; uses ANSI escape sequences if _NCS=1, else PowerShell Write-Host |
dk_color2 | (inline in script) | Print two colored segments on one line |
dk_color3 | MAS/All-In-One-Version-KL/MAS_AIO.cmd505-512 | Print three colored segments on one line |
dk_done | (inline, goto dk_done) | Display final result, wait for keypress, exit |
Process relaunch and elevation diagram:
Sources: MAS/All-In-One-Version-KL/MAS_AIO.cmd53-68 MAS/All-In-One-Version-KL/MAS_AIO.cmd218-224
The re1 and re2 flags are passed as literal arguments so that relaunched processes do not enter infinite loops. The -el flag prevents the elevation loop from repeating. The variable _PSarg is built to pass all original arguments through the runas call, with single-quotes escaped for PowerShell compatibility.
All WMI interactions use a dual-path pattern: if wmic.exe is functional (_wmic=1), the legacy wmic command-line tool is used. If it is absent or broken (_wmic=0), direct PowerShell [WMISEARCHER] / [WMICLASS] calls are used instead. The dk_ckeckwmic subroutine sets this flag at initialization.
Sources: MAS/All-In-One-Version-KL/MAS_AIO.cmd1435-1442 MAS/All-In-One-Version-KL/MAS_AIO.cmd1282-1334 MAS/All-In-One-Version-KL/MAS_AIO.cmd1338-1370
The diagram below maps each runtime dependency to the specific code entity that uses it.
Sources: MAS/All-In-One-Version-KL/MAS_AIO.cmd727-730 MAS/All-In-One-Version-KL/MAS_AIO.cmd1157-1165 MAS/All-In-One-Version-KL/MAS_AIO.cmd1282-1322 MAS/All-In-One-Version-KL/MAS_AIO.cmd1384-1388 MAS/All-In-One-Version-KL/MAS_AIO.cmd1466-1495 MAS/All-In-One-Version-KL/MAS_AIO.cmd1538-1543 MAS/Separate-Files-Version/Check_Activation_Status.cmd1134-1246
The Software Protection Platform service name differs between Windows versions. The dk_setvar subroutine selects the correct executable and service name at runtime:
| Condition | _slexe | _slser | _vis |
|---|---|---|---|
winbuild > 6300 | sppsvc.exe | sppsvc | (unset) |
winbuild ≤ 6300 | SLsvc.exe | SLsvc | 1 |
winbuild < 7600 and SLsvc.exe exists | SLsvc.exe | SLsvc | 1 |
The _vis flag (Vista) is used downstream in several routines to choose Vista-specific code paths, e.g., in Check_Activation_Status.cmd where SLGetWindowsInformation is called from slc.dll instead of newer API paths.
Sources: MAS/All-In-One-Version-KL/MAS_AIO.cmd1162-1165 MAS/Separate-Files-Version/Check_Activation_Status.cmd1479-1483
Scripts require Windows PowerShell (not PowerShell Core) in FullLanguage mode. The check at startup embeds a PowerShell block delimited by :pstst markers within the batch file itself. The script reads its own text via [System.IO.File]::ReadAllText, splits on the :pstst delimiter, and executes the embedded block using [scriptblock]::Create.
This same self-reading pattern is used elsewhere in the scripts:
:getactivationid: block — scans .xrm-ms licensing files for productSkuId GUIDs (MAS/All-In-One-Version-KL/MAS_AIO.cmd1392-1406):xrm: block — installs license files via SoftwareLicensingService.InstallLicense (MAS/All-In-One-Version-KL/MAS_AIO.cmd1410-1431):winsubstatus: block — calls ClipGetSubscriptionStatus from Clipc.dll (MAS/All-In-One-Version-KL/MAS_AIO.cmd1263-1278):sppmgr: block — the entire PowerShell body of Check_Activation_Status.cmd (MAS/Separate-Files-Version/Check_Activation_Status.cmd53-1587)The general pattern used is:
$f=[System.IO.File]::ReadAllText('path_to_script') -split ':blockname\:.*'
. ([scriptblock]::Create($f[1]))
Sources: MAS/All-In-One-Version-KL/MAS_AIO.cmd232-299 MAS/All-In-One-Version-KL/MAS_AIO.cmd827-828 MAS/Separate-Files-Version/Check_Activation_Status.cmd43-46
The following registry paths are referenced across multiple scripts:
| Path | Used By | Purpose |
|---|---|---|
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment /v PROCESSOR_ARCHITECTURE | dk_showosinfo | OS architecture display |
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion /v UBR, /v BuildLabEx, /v ProductName | dk_showosinfo, dk_product | Build number, revision, OS name fallback |
HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions /v OSProductPfn | dk_checksku | Extract regSKU from product family name |
HKCU\Control Panel\International\Geo /v Name, /v Nation | HWID activation | Save/restore Windows region before/after activation |
HKCU\Console /v QuickEdit | Startup | Disable QuickEdit during script run |
HKU\S-1-5-19\SOFTWARE\Microsoft\IdentityCRL | HWID activation | Clear store identity to force refresh |
HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState | dk_reeval | Delete State/SuppressRulesEngine before SPP reevaluation |
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform | Check_Activation_Status.cmd | SPKeyPath — KMS client/server registry info |
HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform | Check_Activation_Status.cmd | OPKeyPath — Office SPP equivalent |
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE /v InstRoot | dk_errorcheck | Detect WinPE environment |
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State /v ImageState | dk_errorcheck | Detect non-complete Windows setup state |
HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /v DisableWindowsUpdateAccess | HWID activation | Detect Windows Update block policies |
HKLM\SYSTEM\CurrentControlSet\Services\<service> | dk_errorcheck | Check for corrupt or missing service registry keys |
Sources: MAS/All-In-One-Version-KL/MAS_AIO.cmd882-888 MAS/All-In-One-Version-KL/MAS_AIO.cmd1209-1222 MAS/All-In-One-Version-KL/MAS_AIO.cmd1380-1382 MAS/All-In-One-Version-KL/MAS_AIO.cmd1574-1623 MAS/All-In-One-Version-KL/MAS_AIO.cmd1629-1638 MAS/All-In-One-Version-KL/MAS_AIO.cmd1044-1058 MAS/Separate-Files-Version/Check_Activation_Status.cmd1449-1452
All scripts follow the same output convention for errors and fixes. The eline variable expands to a red ==== ERROR ==== banner. The fixes variable accumulates space-separated URLs that are printed at completion. The _fixmsg message differs depending on whether the user is running the all-in-one or separate-files version:
| Context | _fixmsg text |
|---|---|
All-In-One (~z0 ≥ 200000) | Go back to Main Menu, select Troubleshoot and run Fix Licensing option. |
| Separate files | In MAS folder, run Troubleshoot script and select Fix Licensing option. |
This size-based detection (%~z0 GEQ 200000) is the mechanism by which the shared dk_setvar subroutine knows which version is running.
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.