@echo off
title MAS Version Checker and Activator
:: Devloper https://massgrave.dev/
:: Modified by Al3mer
color 0A
if "%~1" neq "restart" (
powershell -Command "Start-Process '%~f0' -ArgumentList 'restart' -Verb RunAs"
exit /b
)
:: Set console properties for better display
mode con: cols=80 lines=30
setlocal enabledelayedexpansion
:: Core Variables
:: Set working directory to a folder on the user's Desktop
set "SCRIPT_DIR=%USERPROFILE%\Desktop\Active\"
:: Create the folder if it doesn't exist
if not exist "%SCRIPT_DIR%" (
mkdir "%SCRIPT_DIR%"
)
set "KMS_FILE=KMS38_Activation.cmd"
set "OHOOK_FILE=Ohook_Activation_AIO.cmd"
set "GITHUB_BASE=https://git.activated.win/massgrave/Microsoft-Activation-Scripts/raw/branch/master/MAS/Separate-Files-Version/Activators"
cls
echo =====================================
echo MAS Activation Script v2.0
echo Modified by Al3mer
echo =====================================
echo.
echo [i] Microsoft Activation Scripts
echo [i] Auto-Update and Activation Tool
echo.
:: Check Internet Connection
call :CheckInternet
if !ONLINE!==1 (
call :DownloadLatestFiles
) else (
echo [WARNING] No internet connection - using local files
)
:: Run Activation Process
call :RunActivation
echo.
echo [SUCCESS] Activation process completed
goto :eof
:: ==================== FUNCTIONS ====================
:CheckInternet
echo [INFO] Testing internet connection...
ping -n 1 -w 3000 8.8.8.8 >nul 2>&1
if errorlevel 1 (
set "ONLINE=0"
echo [WARNING] No internet connection detected
) else (
set "ONLINE=1"
echo [OK] Internet connection available
)
goto :eof
:DownloadLatestFiles
echo [INFO] Downloading latest files...
:: Remove read-only attribute and set write permissions for KMS38 file
if exist "%SCRIPT_DIR%%KMS_FILE%" (
attrib -r "%SCRIPT_DIR%%KMS_FILE%" >nul 2>&1
icacls "%SCRIPT_DIR%%KMS_FILE%" /grant "%USERNAME%":F >nul 2>&1
)
:: Download KMS38 file
echo [INFO] Downloading %KMS_FILE%...
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GITHUB_BASE%/%KMS_FILE%' -OutFile '%SCRIPT_DIR%%KMS_FILE%' -TimeoutSec 30 -UseBasicParsing; Write-Host '[OK] Downloaded %KMS_FILE%'; exit 0 } catch { Write-Host '[ERROR] Failed to download %KMS_FILE%: ' $_.Exception.Message; exit 1 }"
:: Remove read-only attribute and set write permissions for Ohook file
if exist "%SCRIPT_DIR%%OHOOK_FILE%" (
attrib -r "%SCRIPT_DIR%%OHOOK_FILE%" >nul 2>&1
icacls "%SCRIPT_DIR%%OHOOK_FILE%" /grant "%USERNAME%":F >nul 2>&1
)
:: Download Ohook file
echo [INFO] Downloading %OHOOK_FILE%...
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%GITHUB_BASE%/%OHOOK_FILE%' -OutFile '%SCRIPT_DIR%%OHOOK_FILE%' -TimeoutSec 30 -UseBasicParsing; Write-Host '[OK] Downloaded %OHOOK_FILE%'; exit 0 } catch { Write-Host '[ERROR] Failed to download %OHOOK_FILE%: ' $_.Exception.Message; exit 1 }"
goto :eof
:RunActivation
echo.
echo =====================================
echo ACTIVATION PROCESS
echo =====================================
:: Check if files exist
if not exist "%SCRIPT_DIR%%KMS_FILE%" (
echo [ERROR] %KMS_FILE% not found
echo Please ensure the file exists in the script directory
goto :eof
)
if not exist "%SCRIPT_DIR%%OHOOK_FILE%" (
echo [ERROR] %OHOOK_FILE% not found
echo Please ensure the file exists in the script directory
goto :eof
)
:: Run KMS38
echo.
echo [INFO] Running KMS38 Activation...
echo =====================================
setlocal
call "%SCRIPT_DIR%%KMS_FILE%" /KMS38
endlocal
timeout /t 7 >nul
:: Run Ohook
echo.
echo [INFO] Running Ohook Activation...
echo =====================================
setlocal
call "%SCRIPT_DIR%%OHOOK_FILE%" /Ohook
endlocal
goto :eof