How MAS Detects Script Updates and Determines Its Version: Inside Microsoft Activation Scripts
MAS determines its current version using a local masver variable, fetches the latest release from a remote version.txt file via PowerShell's Invoke-WebRequest, and compares the two values using batch arithmetic operators to notify users when updates are available.
Microsoft Activation Scripts (MAS) is an open-source Windows and Office activation toolkit maintained by the massgravel organization. Understanding how MAS detects script updates and determines its version reveals a lightweight, self-contained mechanism that operates entirely within batch files without requiring external update utilities or package managers.
Local Version Storage via the masver Variable
Every entry-point script in the MAS repository defines its current release through a masver environment variable declared at the top of the file. In MAS/All-In-One-Version-KL/MAS_AIO.cmd, MAS/Separate-Files-Version/Troubleshoot.cmd, and MAS/Separate-Files-Version/Change_Windows_Edition.cmd, you will find this exact pattern:
@set masver=3.10
This variable serves as the local script version identifier. Because all scripts are generated from a single source, they share identical masver values, ensuring consistency across the All-in-One edition and separate file versions.
Remote Version Retrieval from version.txt
To determine whether the local installation is current, MAS queries a dedicated version file hosted in the repository root. The script uses a PowerShell one-liner executed via powershell -NoProfile -Command to download the content from:
https://raw.githubusercontent.com/massgravel/Microsoft-Activation-Scripts/master/version.txt
The batch code captures this remote value into a latestver variable:
for /f "delims=" %%A in ('
powershell -NoProfile -Command ^
"(Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/massgravel/Microsoft-Activation-Scripts/master/version.txt').Content.Trim()"
') do set "latestver=%%A"
This approach leverages Invoke-WebRequest to fetch the raw text content, using .Content.Trim() to remove any whitespace or newline characters before comparison.
Version Comparison and Update Notification
Once both values are populated, MAS performs a numeric comparison using batch file conditional logic. The script evaluates whether the local masver is less than (LSS) the remote latestver:
if %masver% LSS %latestver% (
echo Your version of MAS [%masver%] is outdated.
echo Visit %github% to download the newest release.
)
If the condition evaluates to true, the script outputs an outdated version warning and provides navigation options to the user. The comparison relies on standard batch arithmetic operators, treating the version strings as decimal numbers for evaluation purposes.
Distribution Links and Mirror Support
MAS defines two URL variables to direct users to download sources when updates are detected. These are defined as variables to prevent accidental execution and support multiple distribution channels:
selfgit→ Points to the mirror repository athttps://git.activated.win/Microsoft-Activation-Scriptsgithub→ Points to the official GitHub repository athttps://github.com/massgravel/Microsoft-Activation-Scripts
When the version check determines that masver is outdated, the script can launch the user's default browser to either of these locations, ensuring users can always reach the latest release even if one domain is inaccessible.
Implementation Across the MAS Codebase
The version detection logic is replicated consistently across all entry points in the Microsoft Activation Scripts repository. Key files implementing this mechanism include:
MAS/All-In-One-Version-KL/MAS_AIO.cmd– The primary unified interface containing themasverdefinition and update check.MAS/Separate-Files-Version/Troubleshoot.cmd– Standalone troubleshooting utility with identical version validation.MAS/Separate-Files-Version/Change_Windows_Edition.cmd– Edition changer implementing the same update detection.MAS/Separate-Files-Version/Change_Office_Edition.cmd– Office edition modification script with version checking.MAS/Separate-Files-Version/Activators/*.cmd– Individual activation components that also carry themasvervariable and outdated warnings.
The version.txt file located at the repository root serves as the single source of truth for the latest release number, referenced by all script variants during their initialization routines.
Summary
Microsoft Activation Scripts implements a lightweight, self-contained update detection system that operates entirely within Windows batch files:
- Local versioning relies on the
masverenvironment variable defined at the start of every script. - Remote checking uses PowerShell's
Invoke-WebRequestto fetch the current version fromversion.txtin the GitHub repository. - Comparison logic employs batch arithmetic operators (
LSS) to determine if the local installation is outdated. - User notification provides direct links to both primary and mirror repositories when updates are available.
This architecture ensures users receive timely update notifications without requiring external package managers or background services.
Frequently Asked Questions
How does MAS check for updates without installing additional software?
MAS performs update checks using native Windows components. The script calls powershell.exe with the -NoProfile flag to execute Invoke-WebRequest, which downloads the remote version.txt file from GitHub. This approach requires no third-party update utilities or background agents, relying solely on built-in Windows batch and PowerShell capabilities.
What happens if GitHub is blocked or the version.txt file is unreachable?
If the PowerShell command fails to retrieve the remote version, the for /f loop in the batch file will not populate the latestver variable, or it may remain empty. In this scenario, the comparison logic if %masver% LSS %latestver% will not trigger the outdated warning, allowing the script to continue executing with the local version. Users can still manually navigate to the mirror site defined in the selfgit variable if they suspect an update is available.
Why does every MAS script contain the same masver variable?
All MAS scripts are generated from a single source template maintained by the massgravel organization. This ensures consistency across the All-in-One edition (MAS_AIO.cmd) and all separate file versions (Troubleshoot, Change_Windows_Edition, Activators, etc.). By embedding the same masver value in every file, the project guarantees that any entry point can accurately report its version and check against the central version.txt repository.
Can users disable the automatic update check in MAS?
The update check is integrated into the script's initialization routine and executes automatically when the batch file runs. There is no configuration flag or command-line switch within the standard MAS distribution to disable this behavior. However, advanced users could modify the local .cmd file to comment out or remove the PowerShell Invoke-WebRequest block and the subsequent if %masver% LSS %latestver% comparison, though this would require manual maintenance of the modified script.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →