Compare commits

..

No commits in common. "master" and "2.7" have entirely different histories.
master ... 2.7

15 changed files with 3061 additions and 22040 deletions

6
.gitattributes vendored
View file

@ -1,4 +1,4 @@
# MAS export-ignore MAS export-ignore
# LICENSE export-ignore LICENSE export-ignore
# README.md export-ignore README.md export-ignore
.gitattributes export-ignore .gitattributes export-ignore

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
@set masver=3.2 @set masver=2.7
@echo off @echo off
@ -44,28 +44,26 @@ set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%Syste
set "ComSpec=%SysPath%\cmd.exe" set "ComSpec=%SysPath%\cmd.exe"
set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules"
set re1=
set re2=
set "_cmdf=%~f0" set "_cmdf=%~f0"
for %%# in (%*) do ( for %%# in (%*) do (
if /i "%%#"=="re1" set re1=1 if /i "%%#"=="r1" set r1=1
if /i "%%#"=="re2" set re2=1 if /i "%%#"=="r2" set r2=1
) )
:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows
:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows
if exist %SystemRoot%\Sysnative\cmd.exe if not defined re1 ( if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* re1" start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1"
exit /b exit /b
) )
:: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows :: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows
if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined re2 ( if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined r2 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* re2" start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* r2"
exit /b exit /b
) )
@ -109,7 +107,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%fix_service echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -124,7 +122,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%troubleshoot echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -145,8 +143,6 @@ set _unattended=0
set _args=%* set _args=%*
if defined _args set _args=%_args:"=% if defined _args set _args=%_args:"=%
if defined _args set _args=%_args:re1=%
if defined _args set _args=%_args:re2=%
if defined _args ( if defined _args (
for %%A in (%_args%) do ( for %%A in (%_args%) do (
if /i "%%A"=="/HWID" set _act=1 if /i "%%A"=="/HWID" set _act=1
@ -161,29 +157,19 @@ for %%A in (%_act% %_NoEditionChange%) do (if "%%A"=="1" set _unattended=1)
call :dk_setvar call :dk_setvar
if %winbuild% EQU 1 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
if %winbuild% LSS 10240 ( if %winbuild% LSS 10240 (
%eline% %eline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo HWID Activation is only supported on Windows 10/11. echo HWID Activation is only supported on Windows 10/11.
echo: echo:
call :dk_color %Blue% "Use TSforge activation option from the main menu." call :dk_color %Blue% "Use Online KMS activation option."
goto dk_done goto dk_done
) )
if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
%eline% %eline%
echo HWID Activation is not supported on Windows Server. echo HWID Activation is not supported on Windows Server.
call :dk_color %Blue% "Use TSforge activation option from the main menu." call :dk_color %Blue% "Use KMS38 or Online KMS activation option."
goto dk_done goto dk_done
) )
@ -219,6 +205,32 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PowerShellTest: $ExecutionContext.SessionState.LanguageMode :PowerShellTest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PowerShellTest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
call :dk_color %Blue% "Check if your antivirus is blocking the script."
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -231,58 +243,6 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto dk_done
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto dk_done
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto dk_done
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -293,33 +253,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
set lines=0 %psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal=
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
start conhost.exe "!_batf!" %_args% -qedit set "launchcmd=start conhost.exe %psc%"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% ) else (
exit /b set "launchcmd=%psc%"
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -328,19 +288,9 @@ exit /b
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for %%A in ( for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do (
activ%-%ated.win if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1))
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -356,7 +306,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b)
) )
) )
@ -381,13 +331,8 @@ if not exist %SysPath%\%%# (
%eline% %eline%
echo [%SysPath%\%%#] file is missing, aborting... echo [%SysPath%\%%#] file is missing, aborting...
echo: echo:
if not defined results (
call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run DISM Restore and SFC Scan options."
call :dk_color %Blue% "After that, restart system and try activation again."
echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
)
goto dk_done goto dk_done
) )
) )
@ -412,6 +357,7 @@ cls
echo ___________________________________________________________________________________________ echo ___________________________________________________________________________________________
echo: echo:
call :dk_color2 %_White% " " %Green% "%winos% is already permanently activated." call :dk_color2 %_White% " " %Green% "%winos% is already permanently activated."
call :dk_color2 %_White% " " %Gray% "Activation is not required."
echo ___________________________________________________________________________________________ echo ___________________________________________________________________________________________
if %_unattended%==1 goto dk_done if %_unattended%==1 goto dk_done
echo: echo:
@ -430,10 +376,9 @@ reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2
echo [%winos% ^| %winbuild%] echo [%winos% ^| %winbuild%]
echo: echo:
echo Evaluation editions cannot be activated outside of their evaluation period. echo Evaluation editions cannot be activated outside of their evaluation period.
call :dk_color %Blue% "Use TSforge activation option from the main menu to reset evaluation period."
echo: echo:
set fixes=%fixes% %mas%evaluation_editions set fixes=%fixes% %mas%evaluation_editions
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions"
goto dk_done goto dk_done
) )
) )
@ -514,13 +459,13 @@ echo [%winos% ^| %winbuild% ^| SKU:%osSKU%]
if not defined skunotfound ( if not defined skunotfound (
echo This product does not support HWID activation. echo This product does not support HWID activation.
echo Make sure you are using the latest version of the script. echo Make sure you are using the latest version of the script.
echo If you are, then try TSforge activation option from the main menu. echo If you are, then try KMS38 activation option.
set fixes=%fixes% %mas% set fixes=%fixes% %mas%
echo %mas% echo %mas%
) else ( ) else (
echo Required license files not found in %SysPath%\spp\tokens\skus\ echo Required license files not found in %SysPath%\spp\tokens\skus\
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) )
echo: echo:
goto dk_done goto dk_done
@ -543,7 +488,6 @@ call :dk_color %Blue% "Windows Subscription [SKU ID-%slcSKU%] detected. Script w
echo: echo:
) )
set generickey=1
call :dk_inskey "[%key%]" call :dk_inskey "[%key%]"
::======================================================================================================================================== ::========================================================================================================================================
@ -593,14 +537,14 @@ echo Generating GenuineTicket.xml [Successful]
set "_xmlexist=if exist "%tdir%\GenuineTicket.xml"" set "_xmlexist=if exist "%tdir%\GenuineTicket.xml""
%_xmlexist% ( %_xmlexist% (
%psc% "Start-Job { Restart-Service ClipSVC } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Restart-Service ClipSVC } | Wait-Job -Timeout 10 | Out-Null"
%_xmlexist% timeout /t 2 %nul% %_xmlexist% timeout /t 2 %nul%
%_xmlexist% timeout /t 2 %nul% %_xmlexist% timeout /t 2 %nul%
%_xmlexist% ( %_xmlexist% (
set error=1 set error=1
if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul% if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul%
call :dk_color %Gray% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]" call :dk_color %Red% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]"
) )
) )
@ -655,18 +599,17 @@ goto :dl_final
set "_ident=HKU\S-1-5-19\SOFTWARE\Microsoft\IdentityCRL" set "_ident=HKU\S-1-5-19\SOFTWARE\Microsoft\IdentityCRL"
if %keyerror% EQU 0 if defined _int ( if defined _int (
reg delete "%_ident%" /f %nul% reg delete "%_ident%" /f %nul%
for %%# in (wlidsvc LicenseManager sppsvc) do (%psc% "Start-Job { Restart-Service %%# } | Wait-Job -Timeout 20 | Out-Null") reg query "%_ident%" %nul% && (
echo:
set error=1
call :dk_color %Red% "Deleting IdentityCRL Registry [Failed] [%_ident%]"
)
for %%# in (wlidsvc LicenseManager sppsvc) do (%psc% "Start-Job { Restart-Service %%# } | Wait-Job -Timeout 10 | Out-Null")
call :dk_refresh call :dk_refresh
call :dk_act call :dk_act
call :dk_checkperm call :dk_checkperm
reg query "%_ident%" %nul% || (
set error=1
echo:
call :dk_color %Red% "Generating New IdentityCRL Registry [Failed] [%_ident%]"
)
) )
::========================================================================================================================================== ::==========================================================================================================================================
@ -674,95 +617,79 @@ call :dk_color %Red% "Generating New IdentityCRL Registry [Failed] [%_ident%
:: Extended licensing servers tests incase error not found and activation failed :: Extended licensing servers tests incase error not found and activation failed
if %keyerror% EQU 0 if not defined _perm if defined _int ( if %keyerror% EQU 0 if not defined _perm if defined _int (
set resfail=
ipconfig /flushdns %nul% ipconfig /flushdns %nul%
set "tls=[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;" set "tls=[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;"
for %%# in ( for %%# in (
licensing.mp.microsoft.com/v7.0/licenses/content
login.live.com/ppsecure/deviceaddcredential.srf login.live.com/ppsecure/deviceaddcredential.srf
purchase.mp.microsoft.com/v7.0/users/me/orders purchase.mp.microsoft.com/v7.0/users/me/orders
) do if not defined resfail ( ) do if not defined resfail (
%psc% "try { !tls! irm https://%%# -Method POST } catch { if ($_.Exception.Response -eq $null) { Write-Host """"[%%#] $($_.Exception.Message)"""" -ForegroundColor Red -BackgroundColor Black; exit 3 } }" set "d1=Add-Type -AssemblyName System.Net.Http;"
if !errorlevel!==3 set resfail=1 set "d1=!d1! $client = [System.Net.Http.HttpClient]::new();"
set "d1=!d1! $response = $client.GetAsync('https://%%#').GetAwaiter().GetResult();"
set "d1=!d1! $response.Content.ReadAsStringAsync().GetAwaiter().GetResult()"
%psc% "!tls! !d1!" %nul2% | findstr /i "PurchaseFD DeviceAddResponse" %nul1% || set resfail=1
) )
if not defined resfail (
%psc% "!tls! irm https://licensing.mp.microsoft.com/v7.0/licenses/content -Method POST" | find /i "traceId" %nul1% || set resfail=1
) )
if defined resfail ( if defined resfail (
set error=1 set error=1
for %%# in ( echo:
live.com call :dk_color %Red% "Checking Licensing Servers [Failed to Connect]"
microsoft.com
login.live.com
purchase.mp.microsoft.com
licensing.mp.microsoft.com
) do (
findstr /i "%%#" "%SysPath%\drivers\etc\hosts" %nul1% && set "hosfail= [%%# Blocked in Hosts]"
)
call :dk_color %Red% "Checking Licensing Servers [Failed to Connect]!hosfail!"
set fixes=%fixes% %mas%licensing-servers-issue set fixes=%fixes% %mas%licensing-servers-issue
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%licensing-servers-issue" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%licensing-servers-issue"
)
) )
::========================================================================================================================================== ::==========================================================================================================================================
:: Windows update and store block check
if %keyerror% EQU 0 if not defined _perm if defined _int ( if %keyerror% EQU 0 if not defined _perm if defined _int (
reg query "%_ident%" %nul% || (
set error=1
echo:
call :dk_color %Red% "Generating New IdentityCRL Registry [Failed] [%_ident%]"
)
reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWindowsUpdateAccess %nul2% | find /i "0x1" %nul% && set wublock=1 reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWindowsUpdateAccess %nul2% | find /i "0x1" %nul% && set wublock=1
reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DoNotConnectToWindowsUpdateInternetLocations %nul2% | find /i "0x1" %nul% && set wublock=1 reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DoNotConnectToWindowsUpdateInternetLocations %nul2% | find /i "0x1" %nul% && set wublock=1
if defined wublock ( if defined wublock call :dk_color %Red% "Checking Update Blocker In Registry [Found]"
call :dk_color %Red% "Checking Update Blocker In Registry [Found]"
call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it."
)
reg query "HKLM\SOFTWARE\Policies\Microsoft\WindowsStore" /v DisableStoreApps %nul2% | find /i "0x1" %nul% && ( reg query "HKLM\SOFTWARE\Policies\Microsoft\WindowsStore" /v DisableStoreApps %nul2% | find /i "0x1" %nul% && (
set storeblock=1 set storeblock=1
call :dk_color %Red% "Checking Store Blocker In Registry [Found]" call :dk_color %Red% "Checking Store Blocker In Registry [Found]"
call :dk_color %Blue% "If you have used any tool to block Store, undo it."
) )
set wcount=0 for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type ServiceSidType RequiredPrivileges FailureActions) do if not defined wucorrupt (
for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type ServiceSidType RequiredPrivileges FailureActions) do ( reg query HKLM\SYSTEM\CurrentControlSet\Services\wuauserv /v %%G %nul% || set wucorrupt=1
reg query HKLM\SYSTEM\CurrentControlSet\Services\wuauserv /v %%G %nul% || (set wucorrupt=1&set /a wcount+=1)
) )
for %%G in (Parameters Security) do ( for %%G in (Parameters Security TriggerInfo) do if not defined wucorrupt (
reg query HKLM\SYSTEM\CurrentControlSet\Services\wuauserv\%%G %nul% || (set wucorrupt=1&set /a wcount+=1) reg query HKLM\SYSTEM\CurrentControlSet\Services\wuauserv\%%G %nul% || set wucorrupt=1
) )
if defined wucorrupt ( if defined wucorrupt (
set error=1
call :dk_color %Red% "Checking Windows Update Registry [Corruption Found]" call :dk_color %Red% "Checking Windows Update Registry [Corruption Found]"
if !wcount! GTR 2 (
call :dk_color %Red% "Windows seems to be infected with Mal%w%ware."
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
) else ( ) else (
call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it." %psc% "Start-Job { Start-Service wuauserv } | Wait-Job -Timeout 10 | Out-Null"
)
) else (
%psc% "Start-Job { Start-Service wuauserv } | Wait-Job -Timeout 20 | Out-Null"
sc query wuauserv | find /i "RUNNING" %nul% || ( sc query wuauserv | find /i "RUNNING" %nul% || (
set error=1
set wuerror=1 set wuerror=1
sc start wuauserv %nul% sc start wuauserv %nul%
call :dk_color %Red% "Starting Windows Update Service [Failed] [!errorlevel!]" call :dk_color %Red% "Starting Windows Update Service [Failed] [!errorlevel!]"
call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it."
)
) )
) )
::========================================================================================================================================== REM Check Internet related error codes
:: Check Internet related error codes if not defined wucorrupt if not defined wublock if not defined wuerror if not defined storeblock (
if %keyerror% EQU 0 if not defined _perm if defined _int (
if not defined wucorrupt if not defined wublock if not defined wuerror if not defined storeblock if not defined resfail (
echo "%error_code%" | findstr /i "0x80072e 0x80072f 0x800704cf 0x87e10bcf 0x800705b4" %nul% && ( echo "%error_code%" | findstr /i "0x80072e 0x80072f 0x800704cf 0x87e10bcf 0x800705b4" %nul% && (
call :dk_color %Red% "Checking Internet Issues [Found] %error_code%" call :dk_color %Red% "Checking Internet Issues [Found] %error_code%"
set fixes=%fixes% %mas%licensing-servers-issue set fixes=%fixes% %mas%licensing-servers-issue
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%licensing-servers-issue" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%licensing-servers-issue"
) )
) )
) )
@ -776,11 +703,11 @@ call :dk_color %Green% "%winos% is permanently activated with a digital license.
call :dk_color %Red% "Activation Failed %error_code%" call :dk_color %Red% "Activation Failed %error_code%"
if defined notworking ( if defined notworking (
call :dk_color %Blue% "At the time of writing, HWID Activation is not supported for this product." call :dk_color %Blue% "At the time of writing, HWID Activation is not supported for this product."
call :dk_color %Blue% "Use TSforge activation option from the main menu instead." call :dk_color %Blue% "Use KMS38 activation option instead."
) else ( ) else (
if not defined error call :dk_color %Blue% "%_fixmsg%" if not defined error call :dk_color %Blue% "%_fixmsg%"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) )
) )
@ -814,29 +741,20 @@ goto :dk_done
:dk_setvar :dk_setvar
set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
echo "%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%" | find /i "ARM64" %nul1% && (if %winbuild% LSS 21277 set ps32onArm=1)
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "Red="41;97m"" set "Red="41;97m""
set "Gray="100;97m"" set "Gray="100;97m""
set "Green="42;97m"" set "Green="42;97m""
set "Blue="44;97m"" set "Blue="44;97m""
set "White="107;91m""
set "_Red="40;91m"" set "_Red="40;91m""
set "_White="40;37m"" set "_White="40;37m""
set "_Green="40;92m"" set "_Green="40;92m""
@ -846,7 +764,6 @@ set "Red="Red" "white""
set "Gray="Darkgray" "white"" set "Gray="Darkgray" "white""
set "Green="DarkGreen" "white"" set "Green="DarkGreen" "white""
set "Blue="Blue" "white"" set "Blue="Blue" "white""
set "White="White" "Red""
set "_Red="Black" "Red"" set "_Red="Black" "Red""
set "_White="Black" "Gray"" set "_White="Black" "Gray""
set "_Green="Black" "Green"" set "_Green="Black" "Green""
@ -963,12 +880,11 @@ set keyerror=%errorlevel%
cmd /c exit /b %keyerror% cmd /c exit /b %keyerror%
if %keyerror% NEQ 0 set "keyerror=[0x%=ExitCode%]" if %keyerror% NEQ 0 set "keyerror=[0x%=ExitCode%]"
if defined generickey (set "keyecho=Installing Generic Product Key ") else (set "keyecho=Installing Product Key ")
if %keyerror% EQU 0 ( if %keyerror% EQU 0 (
if %sps%==SoftwareLicensingService call :dk_refresh if %sps%==SoftwareLicensingService call :dk_refresh
echo %keyecho% %~1 [Successful] echo Installing Generic Product Key %~1 [Successful]
) else ( ) else (
call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" call :dk_color %Red% "Installing Generic Product Key %~1 [Failed] %keyerror%"
if not defined error ( if not defined error (
if defined altapplist call :dk_color %Red% "Activation ID not found for this key." if defined altapplist call :dk_color %Red% "Activation ID not found for this key."
call :dk_color %Blue% "%_fixmsg%" call :dk_color %Blue% "%_fixmsg%"
@ -977,7 +893,6 @@ set showfix=1
set error=1 set error=1
) )
set generickey=
exit /b exit /b
:: Activation command :: Activation command
@ -1016,8 +931,6 @@ exit /b
:dk_reeval :dk_reeval
if %winbuild% LSS 7600 exit /b
:: This key is left by the system in rearm process and sppsvc sometimes fails to delete it, it causes issues in working of the Scheduled Tasks of SPP :: This key is left by the system in rearm process and sppsvc sometimes fails to delete it, it causes issues in working of the Scheduled Tasks of SPP
set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState" set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState"
@ -1027,7 +940,7 @@ reg delete "%ruleskey%" /v "SuppressRulesEngine" /f %nul%
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('SLpTriggerServiceWorker', 'sppc.dll', 22, 1, [Int32], @([UInt32], [IntPtr], [String], [UInt32]), 1, 3); set r2=%r1% [void]$TB.DefinePInvokeMethod('SLpTriggerServiceWorker', 'sppc.dll', 22, 1, [Int32], @([UInt32], [IntPtr], [String], [UInt32]), 1, 3);
set d1=%r2% [void]$TB.CreateType()::SLpTriggerServiceWorker(0, 0, 'reeval', 0) set d1=%r2% [void]$TB.CreateType()::SLpTriggerServiceWorker(0, 0, 'reeval', 0)
%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null; %d1%" %psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 10 | Out-Null; %d1%"
exit /b exit /b
:: Get Activation IDs from licensing files if not found through WMI :: Get Activation IDs from licensing files if not found through WMI
@ -1063,13 +976,13 @@ function InstallLicenseArr($Str) {
ForEach ($x in $a) {InstallLicenseFile "$x"} ForEach ($x in $a) {InstallLicenseFile "$x"}
} }
function InstallLicenseDir($Loc) { function InstallLicenseDir($Loc) {
Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName} dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"}
} }
function ReinstallLicenses() { function ReinstallLicenses() {
$Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens") $Oem = "$env:SysPath\oem"
foreach ($Path in $Paths) { $Spp = "$env:SysPath\spp\tokens"
if (Test-Path $Path) { InstallLicenseDir "$Path" } InstallLicenseDir "$Spp"
} If (Test-Path $Oem) {InstallLicenseDir "$Oem"}
} }
:xrm: :xrm:
@ -1077,7 +990,6 @@ function ReinstallLicenses() {
:dk_ckeckwmic :dk_ckeckwmic
if %winbuild% LSS 9200 (set _wmic=1&exit /b)
set _wmic=0 set _wmic=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1 cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1
@ -1088,16 +1000,16 @@ exit /b
:dk_sppissue :dk_sppissue
sc start %_slser% %nul% sc start sppsvc %nul%
set spperror=%errorlevel% set spperror=%errorlevel%
if %spperror% NEQ 1056 if %spperror% NEQ 0 ( if %spperror% NEQ 1056 if %spperror% NEQ 0 (
%eline% %eline%
echo sc start %_slser% [Error Code: %spperror%] echo sc start sppsvc [Error Code: %spperror%]
) )
echo: echo:
%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host '%_slser% is not working correctly. Check this webpage for help - %mas%troubleshoot'}" %psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 20)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}"
exit /b exit /b
:: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used)
@ -1105,7 +1017,7 @@ exit /b
:dk_product :dk_product
set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3); set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') -replace [string][char]0xa9, '' -replace [string][char]0xae, '' -replace [string][char]0x2122, '' set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%')
set winos= set winos=
for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s)
@ -1151,21 +1063,31 @@ exit /b
set w= set w=
set results= set results=
if exist "%ProgramFiles%\KM%w%Spico" set pupfound= KM%w%Spico if exist "%ProgramFiles%\KM%w%Spico" set pupfound1= KM%w%Spico
if not defined pupfound ( if exist "%SysPath%\Tasks\R@1n-KMS" set pupfound2= R@inKMS
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\taskcache\tasks" /f Path /s | find /i "AutoPico" %nul% && set pupfound= KM%w%Spico reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\taskcache\tasks" /f Path /s | find /i "AutoPico" %nul% && set pupfound1= KM%w%Spico
) reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\taskcache\tasks" /f Path /s | find /i "R@1n" %nul% && set pupfound2= R@inKMS
set pupfound=%pupfound1%%pupfound2%
set hcount=0 set hcount=0
for %%# in (avira.com kaspersky.com virustotal.com mcafee.com) do ( for %%# in (avira.com kaspersky.com virustotal.com mcafee.com) do (
find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1) find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1)
if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]" if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]"
sc start %_slser% %nul% set wucount=0
for %%# in (wuauserv) do (
set _corrupt=
for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type) do if not defined _corrupt (
reg query HKLM\SYSTEM\CurrentControlSet\Services\%%# /v %%G %nul% || (set _corrupt=1 & set /a wucount+=1)
)
)
if %wucount% GEQ 1 set "results=%results%[Windows Update registry is corrupt]"
sc start sppsvc %nul%
echo "%errorlevel%" | findstr "577 225" %nul% && ( echo "%errorlevel%" | findstr "577 225" %nul% && (
set "results=%results%[Likely File Infector]" set "results=%results%[Likely File Infector]"
) || ( ) || (
if not exist %SysPath%\%_slexe% if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]") if not exist %SysPath%\sppsvc.exe if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]")
) )
if not "%results%%pupfound%"=="" ( if not "%results%%pupfound%"=="" (
@ -1173,16 +1095,9 @@ if defined pupfound call :dk_color %Gray% "Checking PUP Activators
if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..." if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..."
if defined results call :dk_color %Red% "%results%" if defined results call :dk_color %Red% "%results%"
set fixes=%fixes% %mas%remove_mal%w%ware set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware"
echo: echo:
) )
:: Remove the scheduled task of R@1n-KMS (old version) that runs the activation command every minute, as it leads to high CPU usage.
if exist %SysPath%\Tasks\R@1n-KMS (
for /f %%A in ('dir /b /a:-d %SysPath%\Tasks\R@1n-KMS %nul6%') do (schtasks /delete /tn \R@1n-KMS\%%A /f %nul%)
)
exit /b exit /b
::======================================================================================================================================== ::========================================================================================================================================
@ -1245,7 +1160,6 @@ for %%# in (%serv_ste%) do (
if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%) if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%)
if /i %%#==wlidsvc sc config %%# start= demand %nul% if /i %%#==wlidsvc sc config %%# start= demand %nul%
if /i %%#==sppsvc (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "2" /f %nul% & sc config %%# start= delayed-auto %nul%) if /i %%#==sppsvc (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "2" /f %nul% & sc config %%# start= delayed-auto %nul%)
if /i %%#==SLsvc sc config %%# start= auto %nul%
if /i %%#==KeyIso sc config %%# start= demand %nul% if /i %%#==KeyIso sc config %%# start= demand %nul%
if /i %%#==LicenseManager sc config %%# start= demand %nul% if /i %%#==LicenseManager sc config %%# start= demand %nul%
if /i %%#==Winmgmt sc config %%# start= auto %nul% if /i %%#==Winmgmt sc config %%# start= auto %nul%
@ -1275,7 +1189,7 @@ set errorcode=
set checkerror= set checkerror=
sc query %%# | find /i "RUNNING" %nul% || ( sc query %%# | find /i "RUNNING" %nul% || (
%psc% "Start-Job { Start-Service %%# } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Start-Service %%# } | Wait-Job -Timeout 10 | Out-Null"
set errorcode=!errorlevel! set errorcode=!errorlevel!
sc query %%# | find /i "RUNNING" %nul% || set checkerror=1 sc query %%# | find /i "RUNNING" %nul% || set checkerror=1
) )
@ -1292,11 +1206,6 @@ echo %serv_e% | findstr /i "ClipSVC-1058 sppsvc-1058" %nul% && (
call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." call :dk_color %Blue% "Reboot your machine using the restart option to fix this error."
set showfix=1 set showfix=1
) )
echo %serv_e% | findstr /i "sppsvc-1060" %nul% && (
set fixes=%fixes% %mas%fix_service
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_service"
set showfix=1
)
) )
::======================================================================================================================================== ::========================================================================================================================================
@ -1310,21 +1219,14 @@ call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option
) )
:: https://learn.microsoft.com/windows-hardware/manufacture/desktop/windows-setup-states
for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B) for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B)
if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" ( if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" (
call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]"
echo "%imagestate%" | find /i "RESEAL" %nul% && (
set error=1 set error=1
call :dk_color %Red% "Checking Windows Setup State [%imagestate%]"
echo "%imagestate%" | find /i "RESEAL" %nul% && (
set showfix=1 set showfix=1
call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode." call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode."
) )
echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && (
set fixes=%fixes% %mas%in-place_repair_upgrade
call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade"
)
) )
@ -1347,21 +1249,18 @@ echo Checking WPA Registry Count [%wpainfo%]
) )
if not defined notwinact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( if not defined officeact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" (
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || (
set error=1
call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]" call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]"
set fixes=%fixes% %mas%evaluation_editions set fixes=%fixes% %mas%evaluation_editions
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions"
) )
) )
set osedition=0 set osedition=0
if %_wmic% EQU 1 set "chkedi=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL) get LicenseFamily /VALUE" %nul6%')" for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul6%') do set "osedition=%%a"
if %_wmic% EQU 0 set "chkedi=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT LicenseFamily FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL').Get()).LicenseFamily ^| %% {echo ('LicenseFamily='+$_)}" %nul6%')"
%chkedi% do if not errorlevel 1 (call set "osedition=%%a")
if %osedition%==0 for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul6%') do set "osedition=%%a"
:: Workaround for an issue in builds between 1607 and 1709 where ProfessionalEducation is shown as Professional :: Workaround for an issue in builds between 1607 and 1709 where ProfessionalEducation is shown as Professional
@ -1370,27 +1269,26 @@ if "%osSKU%"=="164" set osedition=ProfessionalEducation
if "%osSKU%"=="165" set osedition=ProfessionalEducationN if "%osSKU%"=="165" set osedition=ProfessionalEducationN
) )
if not defined notwinact ( if not defined officeact (
if %osedition%==0 ( if %osedition%==0 (
call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" call :dk_color %Red% "Checking Edition Name [Not Found In Registry]"
) else ( ) else (
if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" if not exist "%SysPath%\licensing\skus\Security-Licensing-SLC-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" (
set error=1
set skunotfound=1 set skunotfound=1
call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]" call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]"
) )
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" ( if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" (
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-%osedition%Edition*.mum" ( set error=1
call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]"
) )
) )
) )
)
if %_wmic% EQU 1 wmic path %sps% get Version %nul% %psc% "try { $null=([WMISEARCHER]'SELECT * FROM %sps%').Get().Version; exit 0 } catch { exit $_.Exception.InnerException.HResult }" %nul%
if %_wmic% EQU 0 %psc% "try { $null=([WMISEARCHER]'SELECT * FROM %sps%').Get().Version; exit 0 } catch { exit $_.Exception.InnerException.HResult }" %nul%
set error_code=%errorlevel% set error_code=%errorlevel%
cmd /c exit /b %error_code% cmd /c exit /b %error_code%
if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" if %error_code% NEQ 0 set "error_code=0x%=ExitCode%"
@ -1405,7 +1303,7 @@ if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %nu
if %_wmic% EQU 0 %psc% "Get-WmiObject -Class Win32_ComputerSystem | Select-Object -Property CreationClassName" %nul2% | find /i "computersystem" %nul1% if %_wmic% EQU 0 %psc% "Get-WmiObject -Class Win32_ComputerSystem | Select-Object -Property CreationClassName" %nul2% | find /i "computersystem" %nul1%
if %errorlevel% NEQ 0 set wmifailed=1 if %errorlevel% NEQ 0 set wmifailed=1
echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants echo "%error_code%" | findstr /i "0x800410 0x800440" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants
if defined wmifailed ( if defined wmifailed (
set error=1 set error=1
call :dk_color %Red% "Checking WMI [Not Working]" call :dk_color %Red% "Checking WMI [Not Working]"
@ -1414,7 +1312,7 @@ set showfix=1
) )
if not defined notwinact ( if not defined officeact (
if %winbuild% GEQ 10240 ( if %winbuild% GEQ 10240 (
%nul% set /a "sum=%slcSKU%+%regSKU%+%wmiSKU%" %nul% set /a "sum=%slcSKU%+%regSKU%+%wmiSKU%"
set /a "sum/=3" set /a "sum/=3"
@ -1447,20 +1345,21 @@ call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System
:: This "WLMS" service was included in previous Eval editions (which were activable) to automatically shut down the system every hour after the evaluation period expired and prevent SPPSVC from stopping. :: This "WLMS" service was included in previous Eval editions (which were activable) to automatically shut down the system every hour after the evaluation period expired and prevent SPPSVC from stopping.
if exist "%SysPath%\wlms\wlms.exe" ( if exist "%SysPath%\wlms\wlms.exe" (
sc query wlms | find /i "RUNNING" %nul% && (
echo Checking Eval WLMS Service [Found] echo Checking Eval WLMS Service [Found]
) )
)
reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || (
set error=1 set error=1
set showfix=1
call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]"
set fixes=%fixes% %mas%in-place_repair_upgrade set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %mas%in-place_repair_upgrade" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) )
for %%# in (SppEx%w%tComObj.exe SLsvc.exe sppsvc.exe sppsvc.exe\PerfOptions) do ( for %%# in (SppEx%w%tComObj.exe sppsvc.exe sppsvc.exe\PerfOptions) do (
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#")) reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#"))
) )
if defined _sppint ( if defined _sppint (
@ -1474,39 +1373,39 @@ echo Checking SPP In IFEO [%_sppint%]
) )
if %winbuild% GEQ 7600 for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" %nul6%') do if /i %%b NEQ 0x0 ( for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" %nul6%') do if /i %%b NEQ 0x0 (
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul% reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul%
call :dk_color %Red% "Checking SkipRearm [Default 0 Value Not Found. Changing To 0]" call :dk_color %Red% "Checking SkipRearm [Default 0 Value Not Found. Changing To 0]"
%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 10 | Out-Null"
set error=1
) )
if %winbuild% GEQ 7600 reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Plugins\Objects\msft:rm/algorithm/hwid/4.0" /f ba02fed39662 /d %nul% || ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Plugins\Objects\msft:rm/algorithm/hwid/4.0" /f ba02fed39662 /d %nul% || (
call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]" call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]"
set fixes=%fixes% %mas%issues_due_to_gaming_spoofers set fixes=%fixes% %mas%issues_due_to_gaming_spoofers
call :dk_color2 %Blue% "Most likely caused by gaming spoofers. Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" call :dk_color2 %Blue% "Most likely caused by HWID spoofers. Help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers"
set error=1 set error=1
set showfix=1 set showfix=1
) )
set tokenstore= set tokenstore=
if %winbuild% GEQ 7600 (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b"
if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform" if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform"
if %winbuild% GEQ 9200 if /i not "!tokenstore!"=="%SysPath%\spp\store" if /i not "!tokenstore!"=="%SysPath%\spp\store\2.0" if /i not "!tokenstore!"=="%SysPath%\spp\store_test\2.0" ( if %winbuild% GEQ 9200 if /i not "%tokenstore%"=="%SysPath%\spp\store" if /i not "%tokenstore%"=="%SysPath%\spp\store\2.0" if /i not "%tokenstore%"=="%SysPath%\spp\store_test\2.0" (
set toerr=1 set toerr=1
set error=1 set error=1
set showfix=1 set showfix=1
call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [%tokenstore%]"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
)
) )
:: This code creates token folder only if it's missing and sets default permission for it :: This code creates token folder only if it's missing and sets default permission for it
if %winbuild% GEQ 7600 if not defined toerr if not exist "%tokenstore%\" ( if not defined toerr if not exist "%tokenstore%\" (
mkdir "%tokenstore%" %nul% mkdir "%tokenstore%" %nul%
if %winbuild% LSS 9200 set "d=$sddl = 'O:NSG:NSD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;NS)';" if %winbuild% LSS 9200 set "d=$sddl = 'O:NSG:NSD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;NS)';"
if %winbuild% GEQ 9200 set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';" if %winbuild% GEQ 9200 set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';"
@ -1524,40 +1423,34 @@ set showfix=1
) )
if not defined notwinact (
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
%psc% "if (-not $env:_vis) {Start-Job { Stop-Service %_slser% -force } | Wait-Job -Timeout 20 | Out-Null}; $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% %psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 10 | Out-Null; $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul%
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
set "_notfoundids=Key Not Installed / Act ID Not Found" set "_notfoundids=Key Not Installed / Act ID Not Found"
call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined allapps ( if not defined allapps (
set error=1
set "_notfoundids=Not found" set "_notfoundids=Not found"
) )
set error=1
call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]" call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]"
) )
) )
)
if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" (
set error=1 set error=1
call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]" call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]"
) )
if %winbuild% GEQ 9200 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( if %winbuild% GEQ 9200 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" (
%psc% "Get-WmiObject -Query 'SELECT Description FROM SoftwareLicensingProduct WHERE PartialProductKey IS NOT NULL AND LicenseDependsOn IS NULL' | Select-Object -Property Description" %nul2% | findstr /i "KMS_" %nul1% || (
for /f "delims=" %%a in ('%psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -TaskPath '\Microsoft\Windows\SoftwareProtectionPlatform\').State" %nul6%') do (set taskinfo=%%a) for /f "delims=" %%a in ('%psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -TaskPath '\Microsoft\Windows\SoftwareProtectionPlatform\').State" %nul6%') do (set taskinfo=%%a)
echo !taskinfo! | find /i "Ready" %nul% || ( echo !taskinfo! | find /i "Ready" %nul% || (
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul% reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul%
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTask" %nul% || set taskinfo=Removed reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTask" %nul% || set taskinfo=Removed
if "!taskinfo!"=="" set "taskinfo=Not Found"
call :dk_color %Red% "Checking SvcRestartTask Status [!taskinfo!, System might deactivate later]" call :dk_color %Red% "Checking SvcRestartTask Status [!taskinfo!, System might deactivate later]"
if not defined error call :dk_color %Blue% "Reboot your machine using the restart option."
)
) )
) )
@ -1565,7 +1458,7 @@ if not defined error call :dk_color %Blue% "Reboot your machine using the restar
:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. :: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers.
set permerror= set permerror=
if %winbuild% GEQ 9200 if not defined ps32onArm ( if %winbuild% GEQ 9200 (
for %%# in ( for %%# in (
"%tokenstore%+FullControl" "%tokenstore%+FullControl"
"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" "HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey"
@ -1625,7 +1518,7 @@ exit /b
$wpaKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("SYSTEM\\WPA") $wpaKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("SYSTEM\\WPA")
$count = 0 $count = 0
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { if ($subkeyName -match '.*-.*-.*-.*-.*-') {
$count++ $count++
} }
} }
@ -1634,7 +1527,7 @@ $minBuildNumber = 14393
if ($osVersion.Build -ge $minBuildNumber) { if ($osVersion.Build -ge $minBuildNumber) {
$subkeyHashTable = @{} $subkeyHashTable = @{}
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { if ($subkeyName -match '.*-.*-.*-.*-.*-') {
$keyNumber = $subkeyName -replace '.*-', '' $keyNumber = $subkeyName -replace '.*-', ''
$subkeyHashTable[$keyNumber] = $true $subkeyHashTable[$keyNumber] = $true
} }
@ -1648,7 +1541,7 @@ if ($osVersion.Build -ge $minBuildNumber) {
} }
} }
$wpaKey.GetSubKeyNames() | ForEach-Object { $wpaKey.GetSubKeyNames() | ForEach-Object {
if ($_ -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { if ($_ -match '.*-.*-.*-.*-.*-') {
if ($PSVersionTable.PSVersion.Major -lt 3) { if ($PSVersionTable.PSVersion.Major -lt 3) {
cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1" cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1"
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
@ -1677,10 +1570,8 @@ $wpaKey.Close()
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else if exist %ps% ( ) else (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -1688,10 +1579,8 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else if exist %ps% ( ) else (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b
@ -1703,10 +1592,8 @@ echo:
if %_unattended%==1 timeout /t 2 & exit /b if %_unattended%==1 timeout /t 2 & exit /b
if defined fixes ( if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Troubleshoot Page " %Gray% " Press [0] to Ignore"
call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 exit /b
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#))
) )

View file

@ -1,4 +1,4 @@
@set masver=3.2 @set masver=2.7
@echo off @echo off
@ -47,28 +47,26 @@ set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%Syste
set "ComSpec=%SysPath%\cmd.exe" set "ComSpec=%SysPath%\cmd.exe"
set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules"
set re1=
set re2=
set "_cmdf=%~f0" set "_cmdf=%~f0"
for %%# in (%*) do ( for %%# in (%*) do (
if /i "%%#"=="re1" set re1=1 if /i "%%#"=="r1" set r1=1
if /i "%%#"=="re2" set re2=1 if /i "%%#"=="r2" set r2=1
) )
:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows
:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows
if exist %SystemRoot%\Sysnative\cmd.exe if not defined re1 ( if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* re1" start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1"
exit /b exit /b
) )
:: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows :: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows
if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined re2 ( if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined r2 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* re2" start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* r2"
exit /b exit /b
) )
@ -112,7 +110,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%fix_service echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -127,7 +125,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%troubleshoot echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -148,8 +146,6 @@ set _unattended=0
set _args=%* set _args=%*
if defined _args set _args=%_args:"=% if defined _args set _args=%_args:"=%
if defined _args set _args=%_args:re1=%
if defined _args set _args=%_args:re2=%
if defined _args ( if defined _args (
for %%A in (%_args%) do ( for %%A in (%_args%) do (
if /i "%%A"=="/KMS38" set _act=1 if /i "%%A"=="/KMS38" set _act=1
@ -167,25 +163,15 @@ set _k38=
call :dk_setvar call :dk_setvar
set "specific_kms=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f" set "specific_kms=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f"
if %winbuild% EQU 1 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
if %winbuild% LSS 14393 ( if %winbuild% LSS 14393 (
%eline% %eline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo KMS38 activation is only supported on Windows 10/11/Server, build 14393 and later. echo KMS38 activation is only supported on Windows 10/11/Server, build 14393 and later.
echo: echo:
if %winbuild% LSS 10240 ( if %winbuild% LSS 10240 (
call :dk_color %Blue% "Use TSforge activation option from the main menu." call :dk_color %Blue% "Use Online KMS activation option."
) else ( ) else (
call :dk_color %Blue% "Use HWID activation option from the main menu." call :dk_color %Blue% "Use HWID activation option."
) )
goto dk_done goto dk_done
) )
@ -222,6 +208,32 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PowerShellTest: $ExecutionContext.SessionState.LanguageMode :PowerShellTest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PowerShellTest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
call :dk_color %Blue% "Check if your antivirus is blocking the script."
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -234,58 +246,6 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto dk_done
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto dk_done
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto dk_done
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -296,33 +256,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
set lines=0 %psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal=
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
start conhost.exe "!_batf!" %_args% -qedit set "launchcmd=start conhost.exe %psc%"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% ) else (
exit /b set "launchcmd=%psc%"
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -331,19 +291,9 @@ exit /b
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for %%A in ( for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do (
activ%-%ated.win if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1))
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -359,7 +309,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b)
) )
) )
cls cls
@ -421,13 +371,8 @@ if defined _fmiss (
%eline% %eline%
echo [%_fmiss%] file is missing, aborting... echo [%_fmiss%] file is missing, aborting...
echo: echo:
if not defined results (
call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run DISM Restore and SFC Scan options."
call :dk_color %Blue% "After that, restart system and try activation again."
echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
)
goto dk_done goto dk_done
) )
@ -481,10 +426,9 @@ echo:
call :dk_color %Blue% "Go Back to main menu and use [Change Edition] option." call :dk_color %Blue% "Go Back to main menu and use [Change Edition] option."
) else ( ) else (
echo Evaluation editions cannot be activated outside of their evaluation period. echo Evaluation editions cannot be activated outside of their evaluation period.
call :dk_color %Blue% "Use TSforge activation option from the main menu to reset evaluation period."
echo: echo:
set fixes=%fixes% %mas%evaluation_editions set fixes=%fixes% %mas%evaluation_editions
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions"
) )
goto dk_done goto dk_done
) )
@ -500,7 +444,7 @@ if not exist "!_work!\clipup.exe" (
echo clipup.exe doesn't exist in Server Cor/Acor [No GUI] versions. echo clipup.exe doesn't exist in Server Cor/Acor [No GUI] versions.
echo The file is required for KMS38 activation. echo The file is required for KMS38 activation.
echo Check the below page for instructions on how to activate it. echo Check the below page for instructions on how to activate it.
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%kms38" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%kms38"
goto dk_done goto dk_done
) )
) )
@ -512,7 +456,7 @@ if defined a_cor (
if !errorlevel!==3 ( if !errorlevel!==3 (
%eline% %eline%
echo Valid digital signature not found in clipup.exe file. echo Valid digital signature not found in clipup.exe file.
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
) )
@ -572,28 +516,17 @@ call :dk_color %Red% "Checking Alternate Edition for KMS38 [%altedition% Acti
) )
if not defined key if not defined _gvlk ( if not defined key if not defined _gvlk (
echo: %eline%
echo [%winos% ^| %winbuild% ^| SKU:%osSKU%] echo [%winos% ^| %winbuild% ^| SKU:%osSKU%]
if not defined skunotfound (
if exist "%SysPath%\spp\tokens\skus\%osedition%\*GVLK*.xrm-ms" set sppks=1 echo This product does not support KMS38 activation.
echo Make sure you are using the latest version of the script.
if defined skunotfound (
call :dk_color %Red% "Required license files not found in %SysPath%\spp\tokens\skus\"
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
)
if defined sppks (
call :dk_color %Red% "KMS38 activation is supported but failed to find the key."
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
)
if not defined skunotfound if not defined sppks (
call :dk_color %Red% "This product does not support KMS38 activation."
call :dk_color %Blue% "Use TSforge activation option from the main menu."
set fixes=%fixes% %mas% set fixes=%fixes% %mas%
echo %mas% echo %mas%
) else (
echo Required license files were not found in %SysPath%\spp\tokens\skus\
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) )
echo: echo:
goto dk_done goto dk_done
@ -622,7 +555,6 @@ call echo Checking Installed Product Key [Partial Key - %%_partial%%] [
) )
if defined key ( if defined key (
set generickey=1
call :dk_inskey "[%key%]" call :dk_inskey "[%key%]"
) )
@ -637,7 +569,7 @@ if %_wmic% EQU 0 for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELE
if not defined app ( if not defined app (
call :dk_color %Red% "Checking Installed GVLK Activation ID [Not Found] Aborting..." call :dk_color %Red% "Checking Installed GVLK Activation ID [Not Found] Aborting..."
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto :dk_done goto :dk_done
) )
@ -719,17 +651,23 @@ set "_xmlexist=if exist "%tdir%\GenuineTicket.xml""
:: Stop sppsvc :: Stop sppsvc
%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 10 | Out-Null"
sc query sppsvc | find /i "STOPPED" %nul% && (
echo Stopping sppsvc Service [Successful]
) || (
call :dk_color %Gray% "Stopping sppsvc Service [Failed]"
)
%_xmlexist% ( %_xmlexist% (
%psc% "Start-Job { Restart-Service ClipSVC } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Restart-Service ClipSVC } | Wait-Job -Timeout 10 | Out-Null"
%_xmlexist% timeout /t 2 %nul% %_xmlexist% timeout /t 2 %nul%
%_xmlexist% timeout /t 2 %nul% %_xmlexist% timeout /t 2 %nul%
%_xmlexist% ( %_xmlexist% (
set error=1 set error=1
if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul% if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul%
call :dk_color %Gray% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]" call :dk_color %Red% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]"
) )
) )
@ -799,7 +737,7 @@ goto :k_final
call :dk_color %Red% "Activation Failed" call :dk_color %Red% "Activation Failed"
if not defined error call :dk_color %Blue% "%_fixmsg%" if not defined error call :dk_color %Blue% "%_fixmsg%"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
::======================================================================================================================================== ::========================================================================================================================================
@ -914,29 +852,20 @@ $key.SetAccessControl($acl)
:dk_setvar :dk_setvar
set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
echo "%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%" | find /i "ARM64" %nul1% && (if %winbuild% LSS 21277 set ps32onArm=1)
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "Red="41;97m"" set "Red="41;97m""
set "Gray="100;97m"" set "Gray="100;97m""
set "Green="42;97m"" set "Green="42;97m""
set "Blue="44;97m"" set "Blue="44;97m""
set "White="107;91m""
set "_Red="40;91m"" set "_Red="40;91m""
set "_White="40;37m"" set "_White="40;37m""
set "_Green="40;92m"" set "_Green="40;92m""
@ -946,7 +875,6 @@ set "Red="Red" "white""
set "Gray="Darkgray" "white"" set "Gray="Darkgray" "white""
set "Green="DarkGreen" "white"" set "Green="DarkGreen" "white""
set "Blue="Blue" "white"" set "Blue="Blue" "white""
set "White="White" "Red""
set "_Red="Black" "Red"" set "_Red="Black" "Red""
set "_White="Black" "Gray"" set "_White="Black" "Gray""
set "_Green="Black" "Green"" set "_Green="Black" "Green""
@ -1082,12 +1010,11 @@ set keyerror=%errorlevel%
cmd /c exit /b %keyerror% cmd /c exit /b %keyerror%
if %keyerror% NEQ 0 set "keyerror=[0x%=ExitCode%]" if %keyerror% NEQ 0 set "keyerror=[0x%=ExitCode%]"
if defined generickey (set "keyecho=Installing Generic Product Key ") else (set "keyecho=Installing Product Key ")
if %keyerror% EQU 0 ( if %keyerror% EQU 0 (
if %sps%==SoftwareLicensingService call :dk_refresh if %sps%==SoftwareLicensingService call :dk_refresh
echo %keyecho% %~1 [Successful] echo Installing Generic Product Key %~1 [Successful]
) else ( ) else (
call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" call :dk_color %Red% "Installing Generic Product Key %~1 [Failed] %keyerror%"
if not defined error ( if not defined error (
if defined altapplist call :dk_color %Red% "Activation ID not found for this key." if defined altapplist call :dk_color %Red% "Activation ID not found for this key."
call :dk_color %Blue% "%_fixmsg%" call :dk_color %Blue% "%_fixmsg%"
@ -1096,7 +1023,6 @@ set showfix=1
set error=1 set error=1
) )
set generickey=
exit /b exit /b
:: Get Windows installed key channel :: Get Windows installed key channel
@ -1132,8 +1058,6 @@ exit /b
:dk_reeval :dk_reeval
if %winbuild% LSS 7600 exit /b
:: This key is left by the system in rearm process and sppsvc sometimes fails to delete it, it causes issues in working of the Scheduled Tasks of SPP :: This key is left by the system in rearm process and sppsvc sometimes fails to delete it, it causes issues in working of the Scheduled Tasks of SPP
set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState" set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState"
@ -1143,7 +1067,7 @@ reg delete "%ruleskey%" /v "SuppressRulesEngine" /f %nul%
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('SLpTriggerServiceWorker', 'sppc.dll', 22, 1, [Int32], @([UInt32], [IntPtr], [String], [UInt32]), 1, 3); set r2=%r1% [void]$TB.DefinePInvokeMethod('SLpTriggerServiceWorker', 'sppc.dll', 22, 1, [Int32], @([UInt32], [IntPtr], [String], [UInt32]), 1, 3);
set d1=%r2% [void]$TB.CreateType()::SLpTriggerServiceWorker(0, 0, 'reeval', 0) set d1=%r2% [void]$TB.CreateType()::SLpTriggerServiceWorker(0, 0, 'reeval', 0)
%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null; %d1%" %psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 10 | Out-Null; %d1%"
exit /b exit /b
:: Install License files using Powershell/WMI instead of slmgr.vbs :: Install License files using Powershell/WMI instead of slmgr.vbs
@ -1161,13 +1085,13 @@ function InstallLicenseArr($Str) {
ForEach ($x in $a) {InstallLicenseFile "$x"} ForEach ($x in $a) {InstallLicenseFile "$x"}
} }
function InstallLicenseDir($Loc) { function InstallLicenseDir($Loc) {
Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName} dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"}
} }
function ReinstallLicenses() { function ReinstallLicenses() {
$Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens") $Oem = "$env:SysPath\oem"
foreach ($Path in $Paths) { $Spp = "$env:SysPath\spp\tokens"
if (Test-Path $Path) { InstallLicenseDir "$Path" } InstallLicenseDir "$Spp"
} If (Test-Path $Oem) {InstallLicenseDir "$Oem"}
} }
:xrm: :xrm:
@ -1175,7 +1099,6 @@ function ReinstallLicenses() {
:dk_ckeckwmic :dk_ckeckwmic
if %winbuild% LSS 9200 (set _wmic=1&exit /b)
set _wmic=0 set _wmic=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1 cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1
@ -1186,16 +1109,16 @@ exit /b
:dk_sppissue :dk_sppissue
sc start %_slser% %nul% sc start sppsvc %nul%
set spperror=%errorlevel% set spperror=%errorlevel%
if %spperror% NEQ 1056 if %spperror% NEQ 0 ( if %spperror% NEQ 1056 if %spperror% NEQ 0 (
%eline% %eline%
echo sc start %_slser% [Error Code: %spperror%] echo sc start sppsvc [Error Code: %spperror%]
) )
echo: echo:
%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host '%_slser% is not working correctly. Check this webpage for help - %mas%troubleshoot'}" %psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 20)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}"
exit /b exit /b
:: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used)
@ -1203,7 +1126,7 @@ exit /b
:dk_product :dk_product
set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3); set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') -replace [string][char]0xa9, '' -replace [string][char]0xae, '' -replace [string][char]0x2122, '' set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%')
set winos= set winos=
for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s)
@ -1294,21 +1217,31 @@ exit /b
set w= set w=
set results= set results=
if exist "%ProgramFiles%\KM%w%Spico" set pupfound= KM%w%Spico if exist "%ProgramFiles%\KM%w%Spico" set pupfound1= KM%w%Spico
if not defined pupfound ( if exist "%SysPath%\Tasks\R@1n-KMS" set pupfound2= R@inKMS
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\taskcache\tasks" /f Path /s | find /i "AutoPico" %nul% && set pupfound= KM%w%Spico reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\taskcache\tasks" /f Path /s | find /i "AutoPico" %nul% && set pupfound1= KM%w%Spico
) reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\taskcache\tasks" /f Path /s | find /i "R@1n" %nul% && set pupfound2= R@inKMS
set pupfound=%pupfound1%%pupfound2%
set hcount=0 set hcount=0
for %%# in (avira.com kaspersky.com virustotal.com mcafee.com) do ( for %%# in (avira.com kaspersky.com virustotal.com mcafee.com) do (
find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1) find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1)
if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]" if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]"
sc start %_slser% %nul% set wucount=0
for %%# in (wuauserv) do (
set _corrupt=
for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type) do if not defined _corrupt (
reg query HKLM\SYSTEM\CurrentControlSet\Services\%%# /v %%G %nul% || (set _corrupt=1 & set /a wucount+=1)
)
)
if %wucount% GEQ 1 set "results=%results%[Windows Update registry is corrupt]"
sc start sppsvc %nul%
echo "%errorlevel%" | findstr "577 225" %nul% && ( echo "%errorlevel%" | findstr "577 225" %nul% && (
set "results=%results%[Likely File Infector]" set "results=%results%[Likely File Infector]"
) || ( ) || (
if not exist %SysPath%\%_slexe% if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]") if not exist %SysPath%\sppsvc.exe if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]")
) )
if not "%results%%pupfound%"=="" ( if not "%results%%pupfound%"=="" (
@ -1316,16 +1249,9 @@ if defined pupfound call :dk_color %Gray% "Checking PUP Activators
if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..." if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..."
if defined results call :dk_color %Red% "%results%" if defined results call :dk_color %Red% "%results%"
set fixes=%fixes% %mas%remove_mal%w%ware set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware"
echo: echo:
) )
:: Remove the scheduled task of R@1n-KMS (old version) that runs the activation command every minute, as it leads to high CPU usage.
if exist %SysPath%\Tasks\R@1n-KMS (
for /f %%A in ('dir /b /a:-d %SysPath%\Tasks\R@1n-KMS %nul6%') do (schtasks /delete /tn \R@1n-KMS\%%A /f %nul%)
)
exit /b exit /b
::======================================================================================================================================== ::========================================================================================================================================
@ -1388,7 +1314,6 @@ for %%# in (%serv_ste%) do (
if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%) if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%)
if /i %%#==wlidsvc sc config %%# start= demand %nul% if /i %%#==wlidsvc sc config %%# start= demand %nul%
if /i %%#==sppsvc (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "2" /f %nul% & sc config %%# start= delayed-auto %nul%) if /i %%#==sppsvc (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "2" /f %nul% & sc config %%# start= delayed-auto %nul%)
if /i %%#==SLsvc sc config %%# start= auto %nul%
if /i %%#==KeyIso sc config %%# start= demand %nul% if /i %%#==KeyIso sc config %%# start= demand %nul%
if /i %%#==LicenseManager sc config %%# start= demand %nul% if /i %%#==LicenseManager sc config %%# start= demand %nul%
if /i %%#==Winmgmt sc config %%# start= auto %nul% if /i %%#==Winmgmt sc config %%# start= auto %nul%
@ -1418,7 +1343,7 @@ set errorcode=
set checkerror= set checkerror=
sc query %%# | find /i "RUNNING" %nul% || ( sc query %%# | find /i "RUNNING" %nul% || (
%psc% "Start-Job { Start-Service %%# } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Start-Service %%# } | Wait-Job -Timeout 10 | Out-Null"
set errorcode=!errorlevel! set errorcode=!errorlevel!
sc query %%# | find /i "RUNNING" %nul% || set checkerror=1 sc query %%# | find /i "RUNNING" %nul% || set checkerror=1
) )
@ -1435,11 +1360,6 @@ echo %serv_e% | findstr /i "ClipSVC-1058 sppsvc-1058" %nul% && (
call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." call :dk_color %Blue% "Reboot your machine using the restart option to fix this error."
set showfix=1 set showfix=1
) )
echo %serv_e% | findstr /i "sppsvc-1060" %nul% && (
set fixes=%fixes% %mas%fix_service
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_service"
set showfix=1
)
) )
::======================================================================================================================================== ::========================================================================================================================================
@ -1453,21 +1373,14 @@ call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option
) )
:: https://learn.microsoft.com/windows-hardware/manufacture/desktop/windows-setup-states
for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B) for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B)
if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" ( if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" (
call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]"
echo "%imagestate%" | find /i "RESEAL" %nul% && (
set error=1 set error=1
call :dk_color %Red% "Checking Windows Setup State [%imagestate%]"
echo "%imagestate%" | find /i "RESEAL" %nul% && (
set showfix=1 set showfix=1
call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode." call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode."
) )
echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && (
set fixes=%fixes% %mas%in-place_repair_upgrade
call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade"
)
) )
@ -1490,21 +1403,18 @@ echo Checking WPA Registry Count [%wpainfo%]
) )
if not defined notwinact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( if not defined officeact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" (
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || (
set error=1
call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]" call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]"
set fixes=%fixes% %mas%evaluation_editions set fixes=%fixes% %mas%evaluation_editions
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions"
) )
) )
set osedition=0 set osedition=0
if %_wmic% EQU 1 set "chkedi=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL) get LicenseFamily /VALUE" %nul6%')" for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul6%') do set "osedition=%%a"
if %_wmic% EQU 0 set "chkedi=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT LicenseFamily FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL').Get()).LicenseFamily ^| %% {echo ('LicenseFamily='+$_)}" %nul6%')"
%chkedi% do if not errorlevel 1 (call set "osedition=%%a")
if %osedition%==0 for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul6%') do set "osedition=%%a"
:: Workaround for an issue in builds between 1607 and 1709 where ProfessionalEducation is shown as Professional :: Workaround for an issue in builds between 1607 and 1709 where ProfessionalEducation is shown as Professional
@ -1513,27 +1423,26 @@ if "%osSKU%"=="164" set osedition=ProfessionalEducation
if "%osSKU%"=="165" set osedition=ProfessionalEducationN if "%osSKU%"=="165" set osedition=ProfessionalEducationN
) )
if not defined notwinact ( if not defined officeact (
if %osedition%==0 ( if %osedition%==0 (
call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" call :dk_color %Red% "Checking Edition Name [Not Found In Registry]"
) else ( ) else (
if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" if not exist "%SysPath%\licensing\skus\Security-Licensing-SLC-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" (
set error=1
set skunotfound=1 set skunotfound=1
call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]" call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]"
) )
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" ( if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" (
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-%osedition%Edition*.mum" ( set error=1
call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]"
) )
) )
) )
)
if %_wmic% EQU 1 wmic path %sps% get Version %nul% %psc% "try { $null=([WMISEARCHER]'SELECT * FROM %sps%').Get().Version; exit 0 } catch { exit $_.Exception.InnerException.HResult }" %nul%
if %_wmic% EQU 0 %psc% "try { $null=([WMISEARCHER]'SELECT * FROM %sps%').Get().Version; exit 0 } catch { exit $_.Exception.InnerException.HResult }" %nul%
set error_code=%errorlevel% set error_code=%errorlevel%
cmd /c exit /b %error_code% cmd /c exit /b %error_code%
if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" if %error_code% NEQ 0 set "error_code=0x%=ExitCode%"
@ -1548,7 +1457,7 @@ if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %nu
if %_wmic% EQU 0 %psc% "Get-WmiObject -Class Win32_ComputerSystem | Select-Object -Property CreationClassName" %nul2% | find /i "computersystem" %nul1% if %_wmic% EQU 0 %psc% "Get-WmiObject -Class Win32_ComputerSystem | Select-Object -Property CreationClassName" %nul2% | find /i "computersystem" %nul1%
if %errorlevel% NEQ 0 set wmifailed=1 if %errorlevel% NEQ 0 set wmifailed=1
echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants echo "%error_code%" | findstr /i "0x800410 0x800440" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants
if defined wmifailed ( if defined wmifailed (
set error=1 set error=1
call :dk_color %Red% "Checking WMI [Not Working]" call :dk_color %Red% "Checking WMI [Not Working]"
@ -1557,7 +1466,7 @@ set showfix=1
) )
if not defined notwinact ( if not defined officeact (
if %winbuild% GEQ 10240 ( if %winbuild% GEQ 10240 (
%nul% set /a "sum=%slcSKU%+%regSKU%+%wmiSKU%" %nul% set /a "sum=%slcSKU%+%regSKU%+%wmiSKU%"
set /a "sum/=3" set /a "sum/=3"
@ -1590,20 +1499,21 @@ call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System
:: This "WLMS" service was included in previous Eval editions (which were activable) to automatically shut down the system every hour after the evaluation period expired and prevent SPPSVC from stopping. :: This "WLMS" service was included in previous Eval editions (which were activable) to automatically shut down the system every hour after the evaluation period expired and prevent SPPSVC from stopping.
if exist "%SysPath%\wlms\wlms.exe" ( if exist "%SysPath%\wlms\wlms.exe" (
sc query wlms | find /i "RUNNING" %nul% && (
echo Checking Eval WLMS Service [Found] echo Checking Eval WLMS Service [Found]
) )
)
reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || (
set error=1 set error=1
set showfix=1
call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]"
set fixes=%fixes% %mas%in-place_repair_upgrade set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %mas%in-place_repair_upgrade" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) )
for %%# in (SppEx%w%tComObj.exe SLsvc.exe sppsvc.exe sppsvc.exe\PerfOptions) do ( for %%# in (SppEx%w%tComObj.exe sppsvc.exe sppsvc.exe\PerfOptions) do (
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#")) reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#"))
) )
if defined _sppint ( if defined _sppint (
@ -1617,39 +1527,39 @@ echo Checking SPP In IFEO [%_sppint%]
) )
if %winbuild% GEQ 7600 for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" %nul6%') do if /i %%b NEQ 0x0 ( for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" %nul6%') do if /i %%b NEQ 0x0 (
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul% reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul%
call :dk_color %Red% "Checking SkipRearm [Default 0 Value Not Found. Changing To 0]" call :dk_color %Red% "Checking SkipRearm [Default 0 Value Not Found. Changing To 0]"
%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 10 | Out-Null"
set error=1
) )
if %winbuild% GEQ 7600 reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Plugins\Objects\msft:rm/algorithm/hwid/4.0" /f ba02fed39662 /d %nul% || ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Plugins\Objects\msft:rm/algorithm/hwid/4.0" /f ba02fed39662 /d %nul% || (
call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]" call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]"
set fixes=%fixes% %mas%issues_due_to_gaming_spoofers set fixes=%fixes% %mas%issues_due_to_gaming_spoofers
call :dk_color2 %Blue% "Most likely caused by gaming spoofers. Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" call :dk_color2 %Blue% "Most likely caused by HWID spoofers. Help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers"
set error=1 set error=1
set showfix=1 set showfix=1
) )
set tokenstore= set tokenstore=
if %winbuild% GEQ 7600 (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b"
if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform" if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform"
if %winbuild% GEQ 9200 if /i not "!tokenstore!"=="%SysPath%\spp\store" if /i not "!tokenstore!"=="%SysPath%\spp\store\2.0" if /i not "!tokenstore!"=="%SysPath%\spp\store_test\2.0" ( if %winbuild% GEQ 9200 if /i not "%tokenstore%"=="%SysPath%\spp\store" if /i not "%tokenstore%"=="%SysPath%\spp\store\2.0" if /i not "%tokenstore%"=="%SysPath%\spp\store_test\2.0" (
set toerr=1 set toerr=1
set error=1 set error=1
set showfix=1 set showfix=1
call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [%tokenstore%]"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
)
) )
:: This code creates token folder only if it's missing and sets default permission for it :: This code creates token folder only if it's missing and sets default permission for it
if %winbuild% GEQ 7600 if not defined toerr if not exist "%tokenstore%\" ( if not defined toerr if not exist "%tokenstore%\" (
mkdir "%tokenstore%" %nul% mkdir "%tokenstore%" %nul%
if %winbuild% LSS 9200 set "d=$sddl = 'O:NSG:NSD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;NS)';" if %winbuild% LSS 9200 set "d=$sddl = 'O:NSG:NSD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;NS)';"
if %winbuild% GEQ 9200 set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';" if %winbuild% GEQ 9200 set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';"
@ -1667,40 +1577,34 @@ set showfix=1
) )
if not defined notwinact (
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
%psc% "if (-not $env:_vis) {Start-Job { Stop-Service %_slser% -force } | Wait-Job -Timeout 20 | Out-Null}; $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% %psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 10 | Out-Null; $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul%
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
set "_notfoundids=Key Not Installed / Act ID Not Found" set "_notfoundids=Key Not Installed / Act ID Not Found"
call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined allapps ( if not defined allapps (
set error=1
set "_notfoundids=Not found" set "_notfoundids=Not found"
) )
set error=1
call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]" call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]"
) )
) )
)
if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" (
set error=1 set error=1
call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]" call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]"
) )
if %winbuild% GEQ 9200 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( if %winbuild% GEQ 9200 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" (
%psc% "Get-WmiObject -Query 'SELECT Description FROM SoftwareLicensingProduct WHERE PartialProductKey IS NOT NULL AND LicenseDependsOn IS NULL' | Select-Object -Property Description" %nul2% | findstr /i "KMS_" %nul1% || (
for /f "delims=" %%a in ('%psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -TaskPath '\Microsoft\Windows\SoftwareProtectionPlatform\').State" %nul6%') do (set taskinfo=%%a) for /f "delims=" %%a in ('%psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -TaskPath '\Microsoft\Windows\SoftwareProtectionPlatform\').State" %nul6%') do (set taskinfo=%%a)
echo !taskinfo! | find /i "Ready" %nul% || ( echo !taskinfo! | find /i "Ready" %nul% || (
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul% reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul%
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTask" %nul% || set taskinfo=Removed reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTask" %nul% || set taskinfo=Removed
if "!taskinfo!"=="" set "taskinfo=Not Found"
call :dk_color %Red% "Checking SvcRestartTask Status [!taskinfo!, System might deactivate later]" call :dk_color %Red% "Checking SvcRestartTask Status [!taskinfo!, System might deactivate later]"
if not defined error call :dk_color %Blue% "Reboot your machine using the restart option."
)
) )
) )
@ -1708,7 +1612,7 @@ if not defined error call :dk_color %Blue% "Reboot your machine using the restar
:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. :: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers.
set permerror= set permerror=
if %winbuild% GEQ 9200 if not defined ps32onArm ( if %winbuild% GEQ 9200 (
for %%# in ( for %%# in (
"%tokenstore%+FullControl" "%tokenstore%+FullControl"
"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" "HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey"
@ -1768,7 +1672,7 @@ exit /b
$wpaKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("SYSTEM\\WPA") $wpaKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("SYSTEM\\WPA")
$count = 0 $count = 0
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { if ($subkeyName -match '.*-.*-.*-.*-.*-') {
$count++ $count++
} }
} }
@ -1777,7 +1681,7 @@ $minBuildNumber = 14393
if ($osVersion.Build -ge $minBuildNumber) { if ($osVersion.Build -ge $minBuildNumber) {
$subkeyHashTable = @{} $subkeyHashTable = @{}
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { if ($subkeyName -match '.*-.*-.*-.*-.*-') {
$keyNumber = $subkeyName -replace '.*-', '' $keyNumber = $subkeyName -replace '.*-', ''
$subkeyHashTable[$keyNumber] = $true $subkeyHashTable[$keyNumber] = $true
} }
@ -1791,7 +1695,7 @@ if ($osVersion.Build -ge $minBuildNumber) {
} }
} }
$wpaKey.GetSubKeyNames() | ForEach-Object { $wpaKey.GetSubKeyNames() | ForEach-Object {
if ($_ -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { if ($_ -match '.*-.*-.*-.*-.*-') {
if ($PSVersionTable.PSVersion.Major -lt 3) { if ($PSVersionTable.PSVersion.Major -lt 3) {
cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1" cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1"
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
@ -1820,10 +1724,8 @@ $wpaKey.Close()
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else if exist %ps% ( ) else (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -1831,10 +1733,8 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else if exist %ps% ( ) else (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b
@ -1846,10 +1746,8 @@ echo:
if %_unattended%==1 timeout /t 2 & exit /b if %_unattended%==1 timeout /t 2 & exit /b
if defined fixes ( if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Troubleshoot Page " %Gray% " Press [0] to Ignore"
call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 exit /b
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#))
) )

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
--------------------------------------------------------------------------------------
Activation Type Supported Product Activation Period
--------------------------------------------------------------------------------------
HWID - Windows 10-11 - Permanent
Ohook - Office - Permanent
KMS38 - Windows 10-11-Server - Till the Year 2038
Online KMS - Windows / Office - 180 Days. Lifetime With Renewal Task
--------------------------------------------------------------------------------------
For more details, use the respective docs section here https://massgrave.dev/

File diff suppressed because it is too large Load diff

View file

@ -1,14 +0,0 @@
--------------------------------------------------------------------------------------
Activation Type Supported Product Activation Period
--------------------------------------------------------------------------------------
HWID - Windows 10-11 - Permanent
Ohook - Office - Permanent
TSforge - Windows / ESU / Office - Permanent
KMS38 - Windows 10-11-Server - Till the Year 2038
Online KMS - Windows / Office - 180 Days. Lifetime With Renewal Task
--------------------------------------------------------------------------------------
Check the below link for more details:
https://massgrave.dev/chart

View file

@ -1,4 +1,4 @@
@set masver=3.2 @set masver=2.7
@echo off @echo off
@ -31,28 +31,26 @@ set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%Syste
set "ComSpec=%SysPath%\cmd.exe" set "ComSpec=%SysPath%\cmd.exe"
set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules"
set re1=
set re2=
set "_cmdf=%~f0" set "_cmdf=%~f0"
for %%# in (%*) do ( for %%# in (%*) do (
if /i "%%#"=="re1" set re1=1 if /i "%%#"=="r1" set r1=1
if /i "%%#"=="re2" set re2=1 if /i "%%#"=="r2" set r2=1
) )
:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows
:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows
if exist %SystemRoot%\Sysnative\cmd.exe if not defined re1 ( if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* re1" start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1"
exit /b exit /b
) )
:: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows :: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows
if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined re2 ( if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined r2 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* re2" start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* r2"
exit /b exit /b
) )
@ -69,7 +67,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%fix_service echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -84,7 +82,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%troubleshoot echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -105,8 +103,6 @@ set _unattended=0
set _args=%* set _args=%*
if defined _args set _args=%_args:"=% if defined _args set _args=%_args:"=%
if defined _args set _args=%_args:re1=%
if defined _args set _args=%_args:re2=%
if defined _args ( if defined _args (
for %%A in (%_args%) do ( for %%A in (%_args%) do (
if /i "%%A"=="-el" set _elev=1 if /i "%%A"=="-el" set _elev=1
@ -123,20 +119,10 @@ set "line=echo _________________________________________________________________
::======================================================================================================================================== ::========================================================================================================================================
if %winbuild% EQU 1 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
if %winbuild% LSS 7600 ( if %winbuild% LSS 7600 (
%eline% %nceline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo This option is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents.
goto dk_done goto dk_done
) )
@ -172,6 +158,32 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PowerShellTest: $ExecutionContext.SessionState.LanguageMode :PowerShellTest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PowerShellTest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
call :dk_color %Blue% "Check if your antivirus is blocking the script."
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -184,58 +196,6 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto dk_done
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto dk_done
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto dk_done
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -246,33 +206,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
set lines=0 %psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal=
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
start conhost.exe "!_batf!" %_args% -qedit set "launchcmd=start conhost.exe %psc%"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% ) else (
exit /b set "launchcmd=%psc%"
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -281,19 +241,9 @@ exit /b
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for %%A in ( for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do (
activ%-%ated.win if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1))
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -309,7 +259,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b)
) )
) )
@ -328,7 +278,7 @@ if not exist %SysPath%\sppsvc.exe (
echo [%SysPath%\sppsvc.exe] file is missing. Aborting... echo [%SysPath%\sppsvc.exe] file is missing. Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -366,7 +316,7 @@ if %osedition%==0 (
echo Failed to detect OS Edition. Aborting... echo Failed to detect OS Edition. Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -439,7 +389,7 @@ echo which is not officially supported on your Windows build version %winbuild%.
echo Aborting... echo Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -453,7 +403,7 @@ echo Unsupported Office %verchk% is installed on your Windows build version %win
echo Aborting... echo Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -471,23 +421,20 @@ echo:
echo: echo:
echo ____________________________________________________________ echo ____________________________________________________________
echo: echo:
echo [1] Change all editions echo [1] Change - Office Edition
echo [2] Add edition echo [2] Add - Office Edition
echo [3] Remove edition echo [3] Remove - Office Edition
echo:
echo [4] Add/Remove apps
echo ____________________________________________ echo ____________________________________________
echo: echo:
echo [5] Change Office Update Channel echo [4] Change Office Update Channel
echo [0] %_exitmsg% echo [0] %_exitmsg%
echo ____________________________________________________________ echo ____________________________________________________________
echo: echo:
call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard [1,2,3,4,5,0]" call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard [1,2,3,4,0]"
choice /C:123450 /N choice /C:12340 /N
set _el=!errorlevel! set _el=!errorlevel!
if !_el!==6 exit /b if !_el!==5 exit /b
if !_el!==5 goto :oe_changeupdchnl if !_el!==4 goto :oe_changeupdchnl
if !_el!==4 goto :oe_editedition
if !_el!==3 goto :oe_removeedition if !_el!==3 goto :oe_removeedition
if !_el!==2 set change=0& goto :oe_edition if !_el!==2 set change=0& goto :oe_edition
if !_el!==1 set change=1& goto :oe_edition if !_el!==1 set change=1& goto :oe_edition
@ -505,12 +452,7 @@ goto :oe_goback
cls cls
if not defined terminal mode 76, 25 if not defined terminal mode 76, 25
if %change%==1 ( title Change Office Edition %masver%
title Change all editions %masver%
) else (
title Add edition %masver%
)
echo: echo:
echo: echo:
echo: echo:
@ -559,30 +501,20 @@ if not exist %SystemRoot%\Temp\%list%.txt (
echo Failed to generate available editions list. echo Failed to generate available editions list.
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto :oe_goback goto :oe_goback
) )
set inpt= set inpt=
set counter=0 set counter=0
set verified=0 set verified=0
set _notfound=
set targetedition= set targetedition=
%line% %line%
echo: echo:
call :dk_color %Gray% "Installed Office editions: %_oIds%" call :dk_color %Gray% "Installed Office editions: %_oIds%"
call :dk_color %Gray% "You can select one of the following Office Editions." call :dk_color %Gray% "You can select one of the following Office Editions."
if %winbuild% LSS 10240 ( if %winbuild% LSS 10240 echo Unsupported products such as 2019/2021/2024 are excluded from this list.
echo Unsupported products such as 2019/2021/2024 are excluded from this list.
) else (
for %%# in (2019 2021 2024) do (
find /i "%%#" "%SystemRoot%\Temp\%list%.txt" %nul1% || (
if defined _notfound (set _notfound=%%#, !_notfound!) else (set _notfound=%%#)
)
)
if defined _notfound call :dk_color %Gray% "Office !_notfound! is not in this list because old version [%_version%] of Office is installed."
)
%line% %line%
echo: echo:
@ -612,8 +544,6 @@ if %verified%==0 goto :oe_editionchange
:: Set app exclusions :: Set app exclusions
:oe_excludeappspre
cls cls
set suites= set suites=
echo %list% | find /i "Suites" %nul1% && ( echo %list% | find /i "Suites" %nul1% && (
@ -624,7 +554,7 @@ if not exist %SystemRoot%\Temp\getAppIds.txt (
echo Failed to generate available apps list. echo Failed to generate available apps list.
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto :oe_goback goto :oe_goback
) )
) )
@ -685,7 +615,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard:" call :dk_color %_Green% "Choose a menu option using your keyboard:"
choice /C:AENOPJRVWLDT10 /N choice /C:AENOPJRVWLDT10 /N
set _el=!errorlevel! set _el=!errorlevel!
if !_el!==14 goto :oemenu if !_el!==14 goto :oe_editionchangepre
if !_el!==13 call :excludelist & goto :oe_editionchangefinal if !_el!==13 call :excludelist & goto :oe_editionchangefinal
if !_el!==12 if defined Teams_st (if "%Teams_st%"=="Off" (set Teams_st=ON) else (set Teams_st=Off)) if !_el!==12 if defined Teams_st (if "%Teams_st%"=="Off" (set Teams_st=ON) else (set Teams_st=Off))
if !_el!==11 if defined OneDrive_st (if "%OneDrive_st%"=="Off" (set OneDrive_st=ON) else (set OneDrive_st=Off)) if !_el!==11 if defined OneDrive_st (if "%OneDrive_st%"=="Off" (set OneDrive_st=ON) else (set OneDrive_st=Off))
@ -705,18 +635,18 @@ goto :oe_excludeapps
set excludelist= set excludelist=
for %%# in ( for %%# in (
access Access
excel Excel
onenote OneNote
outlook Outlook
powerpoint PowerPoint
project Project
publisher Publisher
visio Visio
word Word
lync Lync
onedrive OneDrive
teams Teams
) do ( ) do (
if /i "!%%#_st!"=="Off" if defined excludelist (set excludelist=!excludelist!,%%#) else (set excludelist=,%%#) if /i "!%%#_st!"=="Off" if defined excludelist (set excludelist=!excludelist!,%%#) else (set excludelist=,%%#)
) )
@ -787,7 +717,7 @@ goto :oe_goback
:: OfficeClickToRun.exe with productstoadd method is used here to add editions :: OfficeClickToRun.exe with productstoadd method is used here to add editions
:: It uses delta updates, meaning that since it's using same installed build, it will consume very less Internet :: It uses delta updates, meaning that since it's using same installed build, it will consume very less Internet
set "c2rcommand="%_c2rExe%" platform=%_oArch% culture=%_lang% productstoadd=%targetedition%.16_%_lang%_x-none cdnbaseurl.16=http://officecdn.microsoft.com/pr/%_updch% baseurl.16=http://officecdn.microsoft.com/pr/%_updch% version.16=%_version% mediatype.16=CDN sourcetype.16=CDN deliverymechanism=%_updch% %targetedition%.excludedapps.16=groove%excludelist% flt.useteamsaddon=disabled flt.usebingaddononinstall=disabled flt.usebingaddononupdate=disabled" set "c2rcommand="%_c2rExe%" platform=%_oArch% culture=%_lang% productstoadd=%targetedition%.16_%_lang%_x-none cdnbaseurl.16=http://officecdn.microsoft.com/pr/%_updch% baseurl.16=http://officecdn.microsoft.com/pr/%_updch% version.16=%_version% mediatype.16=CDN sourcetype.16=CDN deliverymechanism=%_updch% %targetedition%.excludedapps.16=Groove%excludelist% flt.useteamsaddon=disabled flt.usebingaddononinstall=disabled flt.usebingaddononupdate=disabled"
if %change%==1 ( if %change%==1 (
set "c2rcommand=!c2rcommand! productstoremove=AllProducts" set "c2rcommand=!c2rcommand! productstoremove=AllProducts"
@ -806,7 +736,7 @@ if %errorcode% EQU 0 (
call :dk_color %Gray% "Now run the Office activation option from the main menu." call :dk_color %Gray% "Now run the Office activation option from the main menu."
) else ( ) else (
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) )
call :oe_tempcleanup call :oe_tempcleanup
@ -814,71 +744,10 @@ goto :oe_goback
::======================================================================================================================================== ::========================================================================================================================================
:: Edit Office edition
:oe_editedition
cls
title Add/Remove Apps %masver%
call :oe_chkinternet
if not defined _int (
goto :oe_goback
)
set change=0
call :ch_getinfo
cls
if not defined terminal (
mode 98, 35
)
set inpt=
set counter=0
set verified=0
set targetedition=
%line%
echo:
call :dk_color %Gray% "You can edit [add/remove apps] one of the following Office editions."
%line%
echo:
for %%A in (%_oIds%) do (
set /a counter+=1
echo [!counter!] %%A
set targetedition!counter!=%%A
)
%line%
echo:
echo [0] Go Back
echo:
call :dk_color %_Green% "Enter an option number using your keyboard and press Enter to confirm:"
set /p inpt=
if "%inpt%"=="" goto :oe_editedition
if "%inpt%"=="0" goto :oemenu
for /l %%i in (1,1,%counter%) do (if "%inpt%"=="%%i" set verified=1)
set targetedition=!targetedition%inpt%!
if %verified%==0 goto :oe_editedition
::===============
cls
if not defined terminal mode 98, 32
echo %targetedition% | findstr /i "Access Excel OneNote Outlook PowerPoint Project Publisher Skype Visio Word" %nul% && (set list=SingleApps) || (set list=Suites)
goto :oe_excludeappspre
::========================================================================================================================================
:: Remove Office editions :: Remove Office editions
:oe_removeedition :oe_removeedition
title Remove Office editions %masver%
call :ch_getinfo call :ch_getinfo
cls cls
@ -949,7 +818,7 @@ echo %c2rcommand%
if %errorlevel% NEQ 0 ( if %errorlevel% NEQ 0 (
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) )
goto :oe_goback goto :oe_goback
@ -960,7 +829,6 @@ goto :oe_goback
:oe_changeupdchnl :oe_changeupdchnl
title Change Office update channel %masver%
call :ch_getinfo call :ch_getinfo
cls cls
@ -1016,12 +884,10 @@ for %%# in (
for /f "tokens=1-2 delims=_" %%A in ("%%~#") do ( for /f "tokens=1-2 delims=_" %%A in ("%%~#") do (
set supported= set supported=
if %winbuild% LSS 10240 (echo %%B | findstr /i "LTSC DevMain" %nul% || set supported=1) else (set supported=1) if %winbuild% LSS 10240 (echo %%B | findstr /i "LTSC DevMain" %nul% || set supported=1) else (set supported=1)
if %winbuild% GEQ 10240 ( if %winbuild% GEQ 10240 (if defined ltsc19 echo %%B | findstr /i "LTSC\>" %nul% || set supported=)
if defined ltsc19 echo %%B | find /i "2019 VL" %nul% || set supported= if %winbuild% GEQ 10240 (if defined ltsc21 echo %%B | findstr /i "LTSC2021\>" %nul% || set supported=)
if defined ltsc21 echo %%B | find /i "2021 VL" %nul% || set supported= if %winbuild% GEQ 10240 (if defined ltsc24 echo %%B | findstr /i "LTSC2024\>" %nul% || set supported=)
if defined ltsc24 echo %%B | find /i "2024 VL" %nul% || set supported= if %winbuild% GEQ 10240 (if not defined ltscfound echo %%B | findstr /i "LTSC" %nul% && set supported=)
if not defined ltscfound echo %%B | find /i "LTSC" %nul% && set supported=
)
if defined supported ( if defined supported (
set /a counter+=1 set /a counter+=1
if !counter! LSS 10 ( if !counter! LSS 10 (
@ -1097,7 +963,7 @@ echo:
echo %updcommand% echo %updcommand%
%updcommand% %updcommand%
echo: echo:
echo Check this webpage for help - %mas%troubleshoot echo Help - %mas%troubleshoot
goto :oe_goback goto :oe_goback
::======================================================================================================================================== ::========================================================================================================================================
@ -1108,10 +974,8 @@ call :oe_tempcleanup
echo: echo:
if defined fixes ( if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] To Open Troubleshoot Page " %Gray% " Press [0] To Ignore"
call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 goto :oemenu
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#))
) )
@ -1193,15 +1057,13 @@ if exist "%_cfolder%\OfficeC2RClient.exe" (
set "_c2rCexe=%_cfolder%\OfficeC2RClient.exe" set "_c2rCexe=%_cfolder%\OfficeC2RClient.exe"
) )
set "audidata4=%_AudienceData:~-4%" echo %_AudienceData% | findstr /i "LTSC\>" %nul% && set ltsc19=LTSC
if /i "%audidata4%"=="LTSC" set ltsc19=LTSC
echo %_clversion% %_version% | findstr "16.0.103 16.0.104 16.0.105" %nul% && set ltsc19=LTSC echo %_clversion% %_version% | findstr "16.0.103 16.0.104 16.0.105" %nul% && set ltsc19=LTSC
if /i "%audidata4%"=="2021" set ltsc21=LTSC2021 echo %_AudienceData% | findstr /i "LTSC2021\>" %nul% && set ltsc21=LTSC2021
echo %_clversion% %_version% | findstr "16.0.14332" %nul% && set ltsc21=LTSC2021 echo %_clversion% %_version% | findstr "16.0.14332" %nul% && set ltsc21=LTSC2021
if /i "%audidata4%"=="2024" set ltsc24=LTSC2024 echo %_AudienceData% | findstr /i "LTSC2024\>" %nul% && set ltsc24=LTSC2024
:: LTSC 2024 build is not fixed yet :: LTSC 2024 build is not fixed yet
if not "%ltsc19%%ltsc21%%ltsc24%"=="" set ltscfound=1 if not "%ltsc19%%ltsc21%%ltsc24%"=="" set ltscfound=1
@ -1353,29 +1215,20 @@ if ($appIdsList.Count -gt 0) {
:dk_setvar :dk_setvar
set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
echo "%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%" | find /i "ARM64" %nul1% && (if %winbuild% LSS 21277 set ps32onArm=1)
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "Red="41;97m"" set "Red="41;97m""
set "Gray="100;97m"" set "Gray="100;97m""
set "Green="42;97m"" set "Green="42;97m""
set "Blue="44;97m"" set "Blue="44;97m""
set "White="107;91m""
set "_Red="40;91m"" set "_Red="40;91m""
set "_White="40;37m"" set "_White="40;37m""
set "_Green="40;92m"" set "_Green="40;92m""
@ -1385,7 +1238,6 @@ set "Red="Red" "white""
set "Gray="Darkgray" "white"" set "Gray="Darkgray" "white""
set "Green="DarkGreen" "white"" set "Green="DarkGreen" "white""
set "Blue="Blue" "white"" set "Blue="Blue" "white""
set "White="White" "Red""
set "_Red="Black" "Red"" set "_Red="Black" "Red""
set "_White="Black" "Gray"" set "_White="Black" "Gray""
set "_Green="Black" "Green"" set "_Green="Black" "Green""
@ -1409,7 +1261,6 @@ exit /b
:dk_ckeckwmic :dk_ckeckwmic
if %winbuild% LSS 9200 (set _wmic=1&exit /b)
set _wmic=0 set _wmic=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1 cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1
@ -1420,16 +1271,16 @@ exit /b
:dk_sppissue :dk_sppissue
sc start %_slser% %nul% sc start sppsvc %nul%
set spperror=%errorlevel% set spperror=%errorlevel%
if %spperror% NEQ 1056 if %spperror% NEQ 0 ( if %spperror% NEQ 1056 if %spperror% NEQ 0 (
%eline% %eline%
echo sc start %_slser% [Error Code: %spperror%] echo sc start sppsvc [Error Code: %spperror%]
) )
echo: echo:
%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host '%_slser% is not working correctly. Check this webpage for help - %mas%troubleshoot'}" %psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 20)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}"
exit /b exit /b
:: Common lines used in PowerShell reflection code :: Common lines used in PowerShell reflection code
@ -1447,10 +1298,8 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else if exist %ps% ( ) else (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -1458,10 +1307,8 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else if exist %ps% ( ) else (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b
@ -1473,10 +1320,8 @@ echo:
if %_unattended%==1 timeout /t 2 & exit /b if %_unattended%==1 timeout /t 2 & exit /b
if defined fixes ( if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] To Open Troubleshoot Page " %Gray% " Press [0] To Ignore"
call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 exit /b
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#))
) )

View file

@ -1,4 +1,4 @@
@set masver=3.2 @set masver=2.7
@echo off @echo off
@ -36,28 +36,26 @@ set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%Syste
set "ComSpec=%SysPath%\cmd.exe" set "ComSpec=%SysPath%\cmd.exe"
set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules"
set re1=
set re2=
set "_cmdf=%~f0" set "_cmdf=%~f0"
for %%# in (%*) do ( for %%# in (%*) do (
if /i "%%#"=="re1" set re1=1 if /i "%%#"=="r1" set r1=1
if /i "%%#"=="re2" set re2=1 if /i "%%#"=="r2" set r2=1
) )
:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows
:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows
if exist %SystemRoot%\Sysnative\cmd.exe if not defined re1 ( if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* re1" start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1"
exit /b exit /b
) )
:: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows :: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows
if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined re2 ( if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined r2 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* re2" start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* r2"
exit /b exit /b
) )
@ -74,7 +72,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%fix_service echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -89,7 +87,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%troubleshoot echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -110,8 +108,6 @@ set _unattended=0
set _args=%* set _args=%*
if defined _args set _args=%_args:"=% if defined _args set _args=%_args:"=%
if defined _args set _args=%_args:re1=%
if defined _args set _args=%_args:re2=%
if defined _args ( if defined _args (
for %%A in (%_args%) do ( for %%A in (%_args%) do (
if /i "%%A"=="-el" set _elev=1 if /i "%%A"=="-el" set _elev=1
@ -128,20 +124,10 @@ set "line=echo _________________________________________________________________
::======================================================================================================================================== ::========================================================================================================================================
if %winbuild% EQU 1 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
if %winbuild% LSS 7600 ( if %winbuild% LSS 7600 (
%eline% %nceline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo This option is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents.
goto dk_done goto dk_done
) )
@ -177,6 +163,32 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PowerShellTest: $ExecutionContext.SessionState.LanguageMode :PowerShellTest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PowerShellTest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
call :dk_color %Blue% "Check if your antivirus is blocking the script."
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -189,58 +201,6 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto dk_done
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto dk_done
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto dk_done
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -251,33 +211,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
set lines=0 %psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal=
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
start conhost.exe "!_batf!" %_args% -qedit set "launchcmd=start conhost.exe %psc%"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% ) else (
exit /b set "launchcmd=%psc%"
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -286,19 +246,9 @@ exit /b
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for %%A in ( for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do (
activ%-%ated.win if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1))
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -314,7 +264,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b)
) )
) )
@ -354,11 +304,8 @@ if not exist %SysPath%\%%# (
%eline% %eline%
echo [%SysPath%\%%#] file is missing, aborting... echo [%SysPath%\%%#] file is missing, aborting...
echo: echo:
call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run DISM Restore and SFC Scan options."
call :dk_color %Blue% "After that, restart system and try activation again."
echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
) )
@ -383,15 +330,15 @@ if defined UBR (set "fullbuild=%%G.!UBR!") else (set "fullbuild=%%G.%%H")
::======================================================================================================================================== ::========================================================================================================================================
:: Check Activation IDs :: Check Activation ID
call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined allapps ( if not defined apps (
%eline% %eline%
echo Failed to find activation IDs. Aborting... echo Either key is not insalled or script failed to get installed key's activation ID. Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -399,30 +346,31 @@ goto dk_done
:: Check Windows Edition and branch :: Check Windows Edition and branch
set osedition= set osedition=0
set dismedition=
set dismnotworking= set dismnotworking=
for /f "tokens=3 delims=: " %%a in ('DISM /English /Online /Get-CurrentEdition %nul6% ^| find /i "Current Edition :"') do set "osedition=%%a"
if not defined osedition set dismnotworking=1
if %_wmic% EQU 1 set "chkedi=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL) get LicenseFamily /VALUE" %nul6%')" if %_wmic% EQU 1 set "chkedi=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL) get LicenseFamily /VALUE" %nul6%')"
if %_wmic% EQU 0 set "chkedi=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT LicenseFamily FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL').Get()).LicenseFamily ^| %% {echo ('LicenseFamily='+$_)}" %nul6%')" if %_wmic% EQU 0 set "chkedi=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT LicenseFamily FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND LicenseDependsOn is NULL AND PartialProductKey IS NOT NULL').Get()).LicenseFamily ^| %% {echo ('LicenseFamily='+$_)}" %nul6%')"
if not defined osedition %chkedi% do if not errorlevel 1 (call set "osedition=%%a") %chkedi% do if not errorlevel 1 (call set "osedition=%%a")
if not defined osedition ( if %osedition%==0 (
%eline% %eline%
echo Failed to detect OS edition, aborting... echo Failed to detect OS edition, aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul6%') do set "regedition=%%a" for /f "skip=2 tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul6%') do set "regedition=%%a"
if /i not "%osedition%"=="%regedition%" ( if /i not "%osedition%"=="%regedition%" (
set "showeditionerror=call :dk_color %_Yellow% "[%osedition%] [Reg-%regedition%]."" set "showeditionerror=call :dk_color %_Yellow% "Mismatch found [WMI-%osedition%] [Reg-%regedition%].""
) )
for /f "tokens=3 delims=: " %%a in ('DISM /English /Online /Get-CurrentEdition %nul6% ^| find /i "Current Edition :"') do set "dismedition=%%a"
if not defined dismedition set dismnotworking=1
set branch= set branch=
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildBranch %nul6%') do set "branch=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildBranch %nul6%') do set "branch=%%b"
@ -440,7 +388,7 @@ if %winbuild% GEQ 10240 for /f "tokens=4" %%a in ('dism /online /english /Get-Ta
if %winbuild% LSS 10240 for /f "tokens=4" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -GetTargetEditions;" ^| findstr /i /c:"Target Edition : "') do (if defined _ptarget (set "_ptarget= !_ptarget! %%a ") else (set "_ptarget= %%a ")) if %winbuild% LSS 10240 for /f "tokens=4" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -GetTargetEditions;" ^| findstr /i /c:"Target Edition : "') do (if defined _ptarget (set "_ptarget= !_ptarget! %%a ") else (set "_ptarget= %%a "))
if %winbuild% GEQ 10240 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( if %winbuild% GEQ 10240 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
if %winbuild% GEQ 17063 call :ced_edilist call :ced_edilist
if /i "%osedition:~0,4%"=="Core" set _pro=Professional if /i "%osedition:~0,4%"=="Core" set _pro=Professional
if /i "%osedition%"=="CoreN" set _pro=ProfessionalN if /i "%osedition%"=="CoreN" set _pro=ProfessionalN
set "_dtarget= %_dtarget% !_wtarget! !_pro! " set "_dtarget= %_dtarget% !_wtarget! !_pro! "
@ -553,7 +501,7 @@ set _dismapi=0
:: Check if DISM API or slmgr.vbs is required for edition upgrade :: Check if DISM API or slmgr.vbs is required for edition upgrade
if not exist "%SysPath%\spp\tokens\skus\%targetedition%\%targetedition%*.xrm-ms" ( if not exist "%SysPath%\spp\tokens\skus\%targetedition%\" (
echo %_wtarget% | find /i " %targetedition% " || ( echo %_wtarget% | find /i " %targetedition% " || (
set _dismapi=1 set _dismapi=1
) )
@ -576,7 +524,7 @@ echo [%targetedition% ^| %winbuild%]
echo Failed to get product key from pkeyhelper.dll. echo Failed to get product key from pkeyhelper.dll.
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -631,7 +579,7 @@ call :dk_color %Gray% "Reboot is required to fully change the edition."
call :dk_color %Red% "[Unsuccessful] [Error Code: !keyerror!]" call :dk_color %Red% "[Unsuccessful] [Error Code: !keyerror!]"
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) )
) )
@ -657,7 +605,7 @@ goto dk_done
cls cls
if not defined terminal ( if not defined terminal (
mode con cols=105 lines=32 mode con cols=105 lines=32
%psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}" %nul% %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}"
) )
call :ced_rebootflag call :ced_rebootflag
@ -694,7 +642,7 @@ goto dk_done
cls cls
if not defined terminal ( if not defined terminal (
mode con cols=105 lines=32 mode con cols=105 lines=32
%psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}" %nul% %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}"
) )
set key= set key=
@ -712,7 +660,7 @@ echo [%targetedition% ^| %winbuild%]
echo Failed to get product key from pkeyhelper.dll. echo Failed to get product key from pkeyhelper.dll.
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -788,7 +736,7 @@ echo:
call :dk_color %Blue% "In case there are errors, you should restart the system before trying again." call :dk_color %Blue% "In case there are errors, you should restart the system before trying again."
echo: echo:
set fixes=%fixes% %mas%change_edition_issues set fixes=%fixes% %mas%change_edition_issues
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%change_edition_issues" call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%change_edition_issues"
exit /b exit /b
:compresslog :compresslog
@ -827,29 +775,20 @@ exit /b
:dk_setvar :dk_setvar
set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
echo "%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%" | find /i "ARM64" %nul1% && (if %winbuild% LSS 21277 set ps32onArm=1)
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "Red="41;97m"" set "Red="41;97m""
set "Gray="100;97m"" set "Gray="100;97m""
set "Green="42;97m"" set "Green="42;97m""
set "Blue="44;97m"" set "Blue="44;97m""
set "White="107;91m""
set "_Red="40;91m"" set "_Red="40;91m""
set "_White="40;37m"" set "_White="40;37m""
set "_Green="40;92m"" set "_Green="40;92m""
@ -859,7 +798,6 @@ set "Red="Red" "white""
set "Gray="Darkgray" "white"" set "Gray="Darkgray" "white""
set "Green="DarkGreen" "white"" set "Green="DarkGreen" "white""
set "Blue="Blue" "white"" set "Blue="Blue" "white""
set "White="White" "Red""
set "_Red="Black" "Red"" set "_Red="Black" "Red""
set "_White="Black" "Gray"" set "_White="Black" "Gray""
set "_Green="Black" "Green"" set "_Green="Black" "Green""
@ -887,14 +825,14 @@ if %_wmic% EQU 1 wmic path %sps% where __CLASS='%sps%' call RefreshLicenseStatus
if %_wmic% EQU 0 %psc% "$null=(([WMICLASS]'%sps%').GetInstances()).RefreshLicenseStatus()" %nul% if %_wmic% EQU 0 %psc% "$null=(([WMICLASS]'%sps%').GetInstances()).RefreshLicenseStatus()" %nul%
exit /b exit /b
:: Get all products Activation IDs :: Get installed products Activation IDs
:dk_actids :dk_actid
set allapps= set apps=
if %_wmic% EQU 1 set "chkapp=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='%1') get ID /VALUE" %nul6%')" if %_wmic% EQU 1 set "chkapp=for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='%1' and PartialProductKey is not null) get ID /VALUE" %nul6%')"
if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM %spp% WHERE ApplicationID=''%1''').Get()).ID ^| %% {echo ('ID='+$_)}" %nul6%')" if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM %spp% WHERE ApplicationID=''%1'' AND PartialProductKey IS NOT NULL').Get()).ID ^| %% {echo ('ID='+$_)}" %nul6%')"
%chkapp% do (if defined allapps (call set "allapps=!allapps! %%a") else (call set "allapps=%%a")) %chkapp% do (if defined apps (call set "apps=!apps! %%a") else (call set "apps=%%a"))
exit /b exit /b
:: Get Edition list :: Get Edition list
@ -910,7 +848,6 @@ exit /b
:dk_ckeckwmic :dk_ckeckwmic
if %winbuild% LSS 9200 (set _wmic=1&exit /b)
set _wmic=0 set _wmic=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1 cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1
@ -921,16 +858,16 @@ exit /b
:dk_sppissue :dk_sppissue
sc start %_slser% %nul% sc start sppsvc %nul%
set spperror=%errorlevel% set spperror=%errorlevel%
if %spperror% NEQ 1056 if %spperror% NEQ 0 ( if %spperror% NEQ 1056 if %spperror% NEQ 0 (
%eline% %eline%
echo sc start %_slser% [Error Code: %spperror%] echo sc start sppsvc [Error Code: %spperror%]
) )
echo: echo:
%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host '%_slser% is not working correctly. Check this webpage for help - %mas%troubleshoot'}" %psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 20)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}"
exit /b exit /b
:: Common lines used in PowerShell reflection code :: Common lines used in PowerShell reflection code
@ -1028,10 +965,8 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else if exist %ps% ( ) else (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -1039,10 +974,8 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else if exist %ps% ( ) else (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b
@ -1054,10 +987,8 @@ echo:
if %_unattended%==1 timeout /t 2 & exit /b if %_unattended%==1 timeout /t 2 & exit /b
if defined fixes ( if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Troubleshoot Page " %Gray% " Press [0] to Ignore"
call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 exit /b
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#))
) )
@ -1336,15 +1267,11 @@ if (!$Dism::_DismSetEdition($Session, "$TargetEdition", "$Key", 0, 0, 0)) {
:: Separator = _ :: Separator = _
:: For Windows 10/11 editions, HWID key is listed where ever possible, in Server versions, KMS key is listed where ever possible. :: For Windows 10/11 editions, HWID key is listed where ever possible, in Server versions, KMS key is listed where ever possible.
:: For Windows, generic keys are mentioned till 22000 and for Server, generic keys are mentioned till 17763, later ones are extracted from the pkeyhelper.dll :: Only RS3 and older version Generic keys are stored here, later ones are extracted from the pkeyhelper.dll itself
:changeeditiondata :changeeditiondata
if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
if %winbuild% GTR 17763 exit /b if %winbuild% GTR 17763 exit /b
) else (
if %winbuild% GEQ 22000 exit /b
)
if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*.mum" (set Cor=Cor) else (set Cor=) if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*.mum" (set Cor=Cor) else (set Cor=)
set h= set h=
@ -1362,12 +1289,8 @@ YTMG3-N6DKC-DKB77-7M9GH-8HV%h%X7______Retail_Core
XKCNC-J26Q9-KFHD2-FKTHY-KD7%h%2Y__OEM:NONSLP_PPIPro XKCNC-J26Q9-KFHD2-FKTHY-KD7%h%2Y__OEM:NONSLP_PPIPro
YNMGQ-8RYV3-4PGQ3-C8XTP-7CF%h%BY______Retail_Education YNMGQ-8RYV3-4PGQ3-C8XTP-7CF%h%BY______Retail_Education
84NGF-MHBT6-FXBX8-QWJK7-DRR%h%8H______Retail_EducationN 84NGF-MHBT6-FXBX8-QWJK7-DRR%h%8H______Retail_EducationN
KCNVH-YKWX8-GJJB9-H9FDT-6F7%h%W2__Volume:MAK_EnterpriseS_VB
43TBQ-NH92J-XKTM7-KT3KK-P39%h%PB__OEM:NONSLP_EnterpriseS_RS5
NK96Y-D9CD8-W44CQ-R8YTK-DYJ%h%WX__OEM:NONSLP_EnterpriseS_RS1 NK96Y-D9CD8-W44CQ-R8YTK-DYJ%h%WX__OEM:NONSLP_EnterpriseS_RS1
FWN7H-PF93Q-4GGP8-M8RF3-MDW%h%WW__OEM:NONSLP_EnterpriseS_TH FWN7H-PF93Q-4GGP8-M8RF3-MDW%h%WW__OEM:NONSLP_EnterpriseS_TH
RQFNW-9TPM3-JQ73T-QV4VQ-DV9%h%PT__Volume:MAK_EnterpriseSN_VB
M33WV-NHY3C-R7FPM-BQGPT-239%h%PG__Volume:MAK_EnterpriseSN_RS5
2DBW3-N2PJG-MVHW3-G7TDK-9HK%h%R4__Volume:MAK_EnterpriseSN_RS1 2DBW3-N2PJG-MVHW3-G7TDK-9HK%h%R4__Volume:MAK_EnterpriseSN_RS1
NTX6B-BRYC2-K6786-F6MVQ-M7V%h%2X__Volume:MAK_EnterpriseSN_TH NTX6B-BRYC2-K6786-F6MVQ-M7V%h%2X__Volume:MAK_EnterpriseSN_TH
G3KNM-CHG6T-R36X3-9QDG6-8M8%h%K9______Retail_ProfessionalSingleLanguage G3KNM-CHG6T-R36X3-9QDG6-8M8%h%K9______Retail_ProfessionalSingleLanguage
@ -1379,10 +1302,6 @@ GJTYN-HDMQY-FRR76-HVGC7-QPF%h%8P______Retail_ProfessionalEducationN
C4NTJ-CX6Q2-VXDMR-XVKGM-F9D%h%JC__Volume:MAK_EnterpriseG C4NTJ-CX6Q2-VXDMR-XVKGM-F9D%h%JC__Volume:MAK_EnterpriseG
46PN6-R9BK9-CVHKB-HWQ9V-MBJ%h%Y8__Volume:MAK_EnterpriseGN 46PN6-R9BK9-CVHKB-HWQ9V-MBJ%h%Y8__Volume:MAK_EnterpriseGN
NJCF7-PW8QT-3324D-688JX-2YV%h%66______Retail_ServerRdsh NJCF7-PW8QT-3324D-688JX-2YV%h%66______Retail_ServerRdsh
XQQYW-NFFMW-XJPBH-K8732-CKF%h%FD______OEM:DM_IoTEnterprise
QPM6N-7J2WJ-P88HH-P3YRH-YY7%h%4H__OEM:NONSLP_IoTEnterpriseS
K9VKN-3BGWV-Y624W-MCRMQ-BHD%h%CD______Retail_CloudEditionN
KY7PN-VR6RX-83W6Y-6DDYQ-T6R%h%4W______Retail_CloudEdition
V3WVW-N2PV2-CGWC3-34QGF-VMJ%h%2C______Retail_Cloud V3WVW-N2PV2-CGWC3-34QGF-VMJ%h%2C______Retail_Cloud
NH9J3-68WK7-6FB93-4K3DF-DJ4%h%F6______Retail_CloudN NH9J3-68WK7-6FB93-4K3DF-DJ4%h%F6______Retail_CloudN
2HN6V-HGTM8-6C97C-RK67V-JQP%h%FD______Retail_CloudE 2HN6V-HGTM8-6C97C-RK67V-JQP%h%FD______Retail_CloudE

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
@set masver=3.2 @set masver=2.7
@echo off @echo off
@ -31,28 +31,26 @@ set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%Syste
set "ComSpec=%SysPath%\cmd.exe" set "ComSpec=%SysPath%\cmd.exe"
set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules"
set re1=
set re2=
set "_cmdf=%~f0" set "_cmdf=%~f0"
for %%# in (%*) do ( for %%# in (%*) do (
if /i "%%#"=="re1" set re1=1 if /i "%%#"=="r1" set r1=1
if /i "%%#"=="re2" set re2=1 if /i "%%#"=="r2" set r2=1
) )
:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows
:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows
if exist %SystemRoot%\Sysnative\cmd.exe if not defined re1 ( if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* re1" start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1"
exit /b exit /b
) )
:: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows :: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows
if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined re2 ( if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined r2 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* re2" start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* r2"
exit /b exit /b
) )
@ -69,7 +67,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%fix_service echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -84,7 +82,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%troubleshoot echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -105,8 +103,6 @@ set _unattended=0
set _args=%* set _args=%*
if defined _args set _args=%_args:"=% if defined _args set _args=%_args:"=%
if defined _args set _args=%_args:re1=%
if defined _args set _args=%_args:re2=%
if defined _args ( if defined _args (
for %%A in (%_args%) do ( for %%A in (%_args%) do (
if /i "%%A"=="-el" set _elev=1 if /i "%%A"=="-el" set _elev=1
@ -122,37 +118,10 @@ call :dk_setvar
::======================================================================================================================================== ::========================================================================================================================================
if %winbuild% EQU 1 ( if %winbuild% LSS 7600 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto done2
)
if %winbuild% LSS 6001 (
%nceline% %nceline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo MAS only supports Windows Vista/7/8/8.1/10/11 and their Server equivalents. echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents.
if %winbuild% EQU 6000 (
echo:
echo Windows Vista RTM is not supported because Powershell cannot be installed.
echo Upgrade to Windows Vista SP1 or SP2.
)
goto done2
)
if %winbuild% LSS 7600 if not exist "%SysPath%\WindowsPowerShell\v1.0\Modules" (
%nceline%
if not exist %ps% (
echo PowerShell is not installed in your system.
)
echo Install PowerShell 2.0 using the following URL.
echo:
echo https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930
if %_unattended%==0 start https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930
goto done2 goto done2
) )
@ -188,6 +157,32 @@ goto done2
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PowerShellTest: $ExecutionContext.SessionState.LanguageMode :PowerShellTest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PowerShellTest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
call :dk_color %Blue% "Check if your antivirus is blocking the script."
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto done2
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -200,58 +195,6 @@ goto done2
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto done2
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto done2
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto done2
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto done2
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -262,33 +205,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
set lines=0 %psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal=
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
start conhost.exe "!_batf!" %_args% -qedit set "launchcmd=start conhost.exe %psc%"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% ) else (
exit /b set "launchcmd=%psc%"
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -297,19 +240,9 @@ exit /b
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for %%A in ( for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do (
activ%-%ated.win if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1))
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -325,7 +258,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b)
) )
) )
@ -366,7 +299,6 @@ set HWID_Activation.cmd=Activators\HWID_Activation.cmd
set KMS38_Activation.cmd=Activators\KMS38_Activation.cmd set KMS38_Activation.cmd=Activators\KMS38_Activation.cmd
set Online_KMS_Activation.cmd=Activators\Online_KMS_Activation.cmd set Online_KMS_Activation.cmd=Activators\Online_KMS_Activation.cmd
set Ohook_Activation_AIO.cmd=Activators\Ohook_Activation_AIO.cmd set Ohook_Activation_AIO.cmd=Activators\Ohook_Activation_AIO.cmd
set TSforge_Activation.cmd=Activators\TSforge_Activation.cmd
pushd "!_work!" pushd "!_work!"
set _nofile= set _nofile=
@ -375,7 +307,6 @@ for %%# in (
%KMS38_Activation.cmd% %KMS38_Activation.cmd%
%Online_KMS_Activation.cmd% %Online_KMS_Activation.cmd%
%Ohook_Activation_AIO.cmd% %Ohook_Activation_AIO.cmd%
%TSforge_Activation.cmd%
) do ( ) do (
if not exist "%%#" set _nofile=1 if not exist "%%#" set _nofile=1
) )
@ -401,34 +332,36 @@ echo:
echo: echo:
echo: echo:
echo: Extract $OEM$ folder on the desktop echo: Extract $OEM$ folder on the desktop
echo: ____________________________________________________________ echo: ________________________________________________________
echo: echo:
echo: [1] HWID [Windows] echo: [1] HWID
echo: [2] Ohook [Office] echo: [2] Ohook
echo: [3] TSforge [Windows / ESU / Office] echo: [3] KMS38
echo: [4] KMS38 [Windows] echo: [4] Online KMS
echo: [5] Online KMS [Windows / Office]
echo: echo:
echo: [6] HWID [Windows] ^+ Ohook [Office] echo: [5] HWID ^(Windows^) ^+ Ohook ^(Office^)
echo: [7] HWID [Windows] ^+ Ohook [Office] ^+ TSforge [ESU] echo: [6] HWID ^(Windows^) ^+ Online KMS ^(Office^)
echo: [8] TSforge [Windows] ^+ Online KMS [Office] echo: [7] KMS38 ^(Windows^) ^+ Ohook ^(Office^)
echo: [8] KMS38 ^(Windows^) ^+ Online KMS ^(Office^)
echo: [9] Online KMS ^(Windows^) ^+ Ohook ^(Office^)
echo: echo:
call :dk_color2 %_White% " [R] " %_Green% "ReadMe" call :dk_color2 %_White% " [R] " %_Green% "ReadMe"
echo: [0] Exit echo: [0] Exit
echo: ____________________________________________________________ echo: ________________________________________________________
echo: echo:
call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard :" call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard :"
choice /C:12345678R0 /N choice /C:123456789R0 /N
set _erl=%errorlevel% set _erl=%errorlevel%
if %_erl%==10 exit /b if %_erl%==11 exit /b
if %_erl%==9 start %mas%oem-folder &goto :Menu if %_erl%==10 start %mas%oem-folder &goto :Menu
if %_erl%==8 goto:tsforge_kms if %_erl%==9 goto:kms_ohook
if %_erl%==7 goto:hwid_ohook_tsforge if %_erl%==8 goto:kms38_kms
if %_erl%==6 goto:hwid_ohook if %_erl%==7 goto:kms38_ohook
if %_erl%==5 goto:kms if %_erl%==6 goto:hwid_kms
if %_erl%==4 goto:kms38 if %_erl%==5 goto:hwid_ohook
if %_erl%==3 goto:tsforge if %_erl%==4 goto:kms
if %_erl%==3 goto:kms38
if %_erl%==2 goto:ohook if %_erl%==2 goto:ohook
if %_erl%==1 goto:hwid if %_erl%==1 goto:hwid
goto :Menu goto :Menu
@ -495,36 +428,6 @@ cd \
::======================================================================================================================================== ::========================================================================================================================================
:tsforge
cls
md "!desktop!\$OEM$\$$\Setup\Scripts"
pushd "!_work!"
copy /y /b "%TSforge_Activation.cmd%" "!_dir!\TSforge_Activation.cmd" %nul%
popd
call :export tsforge_setup
set _error=
if not exist "!_dir!\TSforge_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound
set oem=TSforge
goto done
:tsforge_setup:
@echo off
fltmc >nul || exit /b
call "%~dp0TSforge_Activation.cmd" /Z-WindowsESUOffice
cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
:tsforge_setup:
::========================================================================================================================================
:kms38 :kms38
cls cls
@ -623,28 +526,26 @@ cd \
::======================================================================================================================================== ::========================================================================================================================================
:hwid_ohook_tsforge :hwid_kms
cls cls
md "!desktop!\$OEM$\$$\Setup\Scripts" md "!desktop!\$OEM$\$$\Setup\Scripts"
pushd "!_work!" pushd "!_work!"
copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul% copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul%
copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul% copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul%
copy /y /b "%TSforge_Activation.cmd%" "!_dir!\TSforge_Activation.cmd" %nul%
popd popd
call :export hwid_ohook_tsforge_setup call :export hwid_kms_setup
set _error= set _error=
if not exist "!_dir!\HWID_Activation.cmd" set _error=1 if not exist "!_dir!\HWID_Activation.cmd" set _error=1
if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1 if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1
if not exist "!_dir!\TSforge_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1 if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound if defined _error goto errorfound
set oem=HWID [Windows] + Ohook [Office] + TSforge [ESU] set oem=HWID [Windows] + Online KMS [Office]
goto done goto done
:hwid_ohook_tsforge_setup: :hwid_kms_setup:
@echo off @echo off
fltmc >nul || exit /b fltmc >nul || exit /b
@ -654,45 +555,79 @@ call "%~dp0HWID_Activation.cmd" /HWID
endlocal endlocal
setlocal setlocal
call "%~dp0Ohook_Activation_AIO.cmd" /Ohook call "%~dp0Online_KMS_Activation.cmd" /K-Office
endlocal
setlocal
call "%~dp0TSforge_Activation.cmd" /Z-ESU
endlocal endlocal
cd \ cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
:hwid_ohook_tsforge_setup: :hwid_kms_setup:
::======================================================================================================================================== ::========================================================================================================================================
:tsforge_kms :kms38_ohook
cls cls
md "!desktop!\$OEM$\$$\Setup\Scripts" md "!desktop!\$OEM$\$$\Setup\Scripts"
pushd "!_work!" pushd "!_work!"
copy /y /b "%TSforge_Activation.cmd%" "!_dir!\TSforge_Activation.cmd" %nul% copy /y /b "%KMS38_Activation.cmd%" "!_dir!\KMS38_Activation.cmd" %nul%
copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul% copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul%
popd popd
call :export tsforge_kms_setup call :export kms38_ohook_setup
set _error= set _error=
if not exist "!_dir!\TSforge_Activation.cmd" set _error=1 if not exist "!_dir!\KMS38_Activation.cmd" set _error=1
if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1 if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1 if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound if defined _error goto errorfound
set oem=TSforge [Windows] + Online KMS [Office] set oem=KMS38 [Windows] + Ohook [Office]
goto done goto done
:tsforge_kms_setup: :kms38_ohook_setup:
@echo off @echo off
fltmc >nul || exit /b fltmc >nul || exit /b
setlocal setlocal
call "%~dp0TSforge_Activation.cmd" /Z-Windows call "%~dp0KMS38_Activation.cmd" /KMS38
endlocal
setlocal
call "%~dp0Ohook_Activation_AIO.cmd" /Ohook
endlocal
cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
:kms38_ohook_setup:
::========================================================================================================================================
:kms38_kms
cls
md "!desktop!\$OEM$\$$\Setup\Scripts"
pushd "!_work!"
copy /y /b "%KMS38_Activation.cmd%" "!_dir!\KMS38_Activation.cmd" %nul%
copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul%
popd
call :export kms38_kms_setup
set _error=
if not exist "!_dir!\KMS38_Activation.cmd" set _error=1
if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound
set oem=KMS38 [Windows] + Online KMS [Office]
goto done
:kms38_kms_setup:
@echo off
fltmc >nul || exit /b
setlocal
call "%~dp0KMS38_Activation.cmd" /KMS38
endlocal endlocal
setlocal setlocal
@ -701,7 +636,45 @@ endlocal
cd \ cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
:tsforge_kms_setup: :kms38_kms_setup:
::========================================================================================================================================
:kms_ohook
cls
md "!desktop!\$OEM$\$$\Setup\Scripts"
pushd "!_work!"
copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul%
copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul%
popd
call :export kms_ohook_setup
set _error=
if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1
if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound
set oem=Online KMS [Windows] + Ohook [Office]
goto done
:kms_ohook_setup:
@echo off
fltmc >nul || exit /b
setlocal
call "%~dp0Online_KMS_Activation.cmd" /K-Windows
endlocal
setlocal
call "%~dp0Ohook_Activation_AIO.cmd" /Ohook
endlocal
cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
:kms_ohook_setup:
::======================================================================================================================================== ::========================================================================================================================================
@ -719,7 +692,7 @@ call :dk_color %Blue% "%oem%"
call :dk_color %Green% "$OEM$ folder was successfully created on your Desktop." call :dk_color %Green% "$OEM$ folder was successfully created on your Desktop."
echo "%oem%" | find /i "38" %nul% && ( echo "%oem%" | find /i "38" %nul% && (
echo: echo:
echo To KMS38 activate Server Cor/Acor editions [No GUI Versions], echo To KMS38 activate Server Cor/Acor editions ^(No GUI Versions^),
echo Check this page %mas%oem-folder echo Check this page %mas%oem-folder
) )
echo ______________________________________________________________ echo ______________________________________________________________
@ -728,10 +701,8 @@ echo ______________________________________________________________
echo: echo:
if defined fixes ( if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Troubleshoot Page " %Gray% " Press [0] to Ignore"
call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 exit /b
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#))
) )
@ -750,29 +721,20 @@ exit /b
:dk_setvar :dk_setvar
set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
echo "%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%" | find /i "ARM64" %nul1% && (if %winbuild% LSS 21277 set ps32onArm=1)
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "Red="41;97m"" set "Red="41;97m""
set "Gray="100;97m"" set "Gray="100;97m""
set "Green="42;97m"" set "Green="42;97m""
set "Blue="44;97m"" set "Blue="44;97m""
set "White="107;91m""
set "_Red="40;91m"" set "_Red="40;91m""
set "_White="40;37m"" set "_White="40;37m""
set "_Green="40;92m"" set "_Green="40;92m""
@ -782,7 +744,6 @@ set "Red="Red" "white""
set "Gray="Darkgray" "white"" set "Gray="Darkgray" "white""
set "Green="DarkGreen" "white"" set "Green="DarkGreen" "white""
set "Blue="Blue" "white"" set "Blue="Blue" "white""
set "White="White" "Red""
set "_Red="Black" "Red"" set "_Red="Black" "Red""
set "_White="Black" "Gray"" set "_White="Black" "Gray""
set "_Green="Black" "Green"" set "_Green="Black" "Green""
@ -815,10 +776,8 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else if exist %ps% ( ) else (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -826,10 +785,8 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else if exist %ps% ( ) else (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b

View file

@ -1,4 +1,4 @@
@set masver=3.2 @set masver=2.7
@echo off @echo off
@ -31,28 +31,26 @@ set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%Syste
set "ComSpec=%SysPath%\cmd.exe" set "ComSpec=%SysPath%\cmd.exe"
set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules"
set re1=
set re2=
set "_cmdf=%~f0" set "_cmdf=%~f0"
for %%# in (%*) do ( for %%# in (%*) do (
if /i "%%#"=="re1" set re1=1 if /i "%%#"=="r1" set r1=1
if /i "%%#"=="re2" set re2=1 if /i "%%#"=="r2" set r2=1
) )
:: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows
:: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows :: or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows
if exist %SystemRoot%\Sysnative\cmd.exe if not defined re1 ( if exist %SystemRoot%\Sysnative\cmd.exe if not defined r1 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* re1" start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* r1"
exit /b exit /b
) )
:: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows :: Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows
if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined re2 ( if exist %SystemRoot%\SysArm32\cmd.exe if %PROCESSOR_ARCHITECTURE%==AMD64 if not defined r2 (
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* re2" start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* r2"
exit /b exit /b
) )
@ -69,7 +67,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%fix_service echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -84,7 +82,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Check this webpage for help - %mas%troubleshoot echo Help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -105,8 +103,6 @@ set _unattended=0
set _args=%* set _args=%*
if defined _args set _args=%_args:"=% if defined _args set _args=%_args:"=%
if defined _args set _args=%_args:re1=%
if defined _args set _args=%_args:re2=%
if defined _args ( if defined _args (
for %%A in (%_args%) do ( for %%A in (%_args%) do (
if /i "%%A"=="-el" set _elev=1 if /i "%%A"=="-el" set _elev=1
@ -123,37 +119,10 @@ set "line=______________________________________________________________________
::======================================================================================================================================== ::========================================================================================================================================
if %winbuild% EQU 1 ( if %winbuild% LSS 7600 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
if %winbuild% LSS 6001 (
%nceline% %nceline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo MAS only supports Windows Vista/7/8/8.1/10/11 and their Server equivalents. echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents.
if %winbuild% EQU 6000 (
echo:
echo Windows Vista RTM is not supported because Powershell cannot be installed.
echo Upgrade to Windows Vista SP1 or SP2.
)
goto dk_done
)
if %winbuild% LSS 7600 if not exist "%SysPath%\WindowsPowerShell\v1.0\Modules" (
%nceline%
if not exist %ps% (
echo PowerShell is not installed in your system.
)
echo Install PowerShell 2.0 using the following URL.
echo:
echo https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930
if %_unattended%==0 start https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930
goto dk_done goto dk_done
) )
@ -189,6 +158,32 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PowerShellTest: $ExecutionContext.SessionState.LanguageMode :PowerShellTest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PowerShellTest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
call :dk_color %Blue% "Check if your antivirus is blocking the script."
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -201,58 +196,6 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto dk_done
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto dk_done
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto dk_done
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -263,33 +206,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
set lines=0 %psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal=
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
start conhost.exe "!_batf!" %_args% -qedit set "launchcmd=start conhost.exe %psc%"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% ) else (
exit /b set "launchcmd=%psc%"
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -298,19 +241,9 @@ exit /b
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for %%A in ( for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do (
activ%-%ated.win if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1))
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -326,7 +259,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b)
) )
) )
@ -528,17 +461,10 @@ goto :at_back
cls cls
if not defined terminal ( if not defined terminal (
mode 125, 32 mode 125, 32
%psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}" %nul% %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}"
) )
title Fix Licensing ^(ClipSVC ^+ SPP ^+ OSPP^) title Fix Licensing ^(ClipSVC ^+ SPP ^+ OSPP^)
if %winbuild% EQU 6001 (
%eline%
echo This option is not supported on Windows Vista SP1.
echo Upgrade to Windows Vista SP2.
goto :at_back
)
echo: echo:
echo %line% echo %line%
echo: echo:
@ -555,7 +481,7 @@ echo - Clear ClipSVC, SPP and OSPP licenses.
echo - Fix permissions of SPP tokens folder and registries. echo - Fix permissions of SPP tokens folder and registries.
echo - Trigger the repair option for Office. echo - Trigger the repair option for Office.
echo: echo:
call :dk_color2 %_White% " - " %Blue% "Apply this option only when it is necessary." call :dk_color2 %_White% " - " %Red% "Apply this option only when it is necessary."
echo: echo:
echo %line% echo %line%
echo: echo:
@ -667,7 +593,7 @@ echo [Successful]
echo: echo:
echo Restarting wlidsvc ^& LicenseManager services... echo Restarting wlidsvc ^& LicenseManager services...
for %%# in (wlidsvc LicenseManager) do (%psc% "Start-Job { Restart-Service %%# } | Wait-Job -Timeout 20 | Out-Null") for %%# in (wlidsvc LicenseManager) do (%psc% "Start-Job { Restart-Service %%# } | Wait-Job -Timeout 10 | Out-Null")
::======================================================================================================================================== ::========================================================================================================================================
@ -719,19 +645,19 @@ echo [No Error Found]
) )
echo: echo:
echo Stopping %_slser% service... echo Stopping sppsvc service...
%psc% Stop-Service %_slser% -force %nul% %psc% Stop-Service sppsvc -force %nul%
set w= set w=
set _sppint= set _sppint=
for %%# in (SppEx%w%tComObj.exe %_slexe%) do (reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (set _sppint=1)) for %%# in (SppEx%w%tComObj.exe sppsvc.exe) do (reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (set _sppint=1))
if defined _sppint ( if defined _sppint (
echo: echo:
echo Removing SPP IFEO registry keys... echo Removing SPP IFEO registry keys...
for %%# in (SppE%w%xtComObj.exe %_slexe%) do (reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul%) for %%# in (SppE%w%xtComObj.exe sppsvc.exe) do (reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul%)
) )
if %winbuild% LSS 9200 if not defined _vis ( if %winbuild% LSS 9200 (
REM Fix issues caused by Update KB971033 in Windows 7 REM Fix issues caused by Update KB971033 in Windows 7
REM https://support.microsoft.com/help/4487266 REM https://support.microsoft.com/help/4487266
echo: echo:
@ -750,7 +676,6 @@ del /f /q %SysPath%\7B296FB0-376B-497e-B012-9C450E1B7327-*.C7483456-A289-439d-81
:: Delete registry keys that are not deleted by activation scripts :: Delete registry keys that are not deleted by activation scripts
if not defined _vis (
echo: echo:
echo Cleaning some licensing-related registry keys... echo Cleaning some licensing-related registry keys...
%nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "ServiceSessionId" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "ServiceSessionId" /f
@ -758,7 +683,6 @@ echo Cleaning some licensing-related registry keys...
%nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "PolicyValuesArray" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "PolicyValuesArray" /f
%nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f
%nul% reg delete "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform\data" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform\data" /f
)
echo: echo:
call :scandat delete call :scandat delete
@ -770,13 +694,9 @@ call :dk_color %Red% "Failed to delete .dat files."
echo: echo:
) )
if defined _vis (
%psc% Start-Service %_slser% %nul%
)
echo: echo:
echo Reinstalling system licenses... echo Reinstalling system licenses...
%psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% %psc% "Stop-Service sppsvc -force; $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul%
if %errorlevel% NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% if %errorlevel% NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul%
if %errorlevel% EQU 0 ( if %errorlevel% EQU 0 (
echo [Successful] echo [Successful]
@ -793,7 +713,7 @@ call :dk_color %Red% "Failed to rebuild tokens.dat file."
echo tokens.dat file was rebuilt successfully. echo tokens.dat file was rebuilt successfully.
) )
if %winbuild% LSS 9200 if not defined _vis ( if %winbuild% LSS 9200 (
sc config sppuinotify start= demand sc config sppuinotify start= demand
) )
@ -864,6 +784,14 @@ echo:
call :dk_color %Blue% "Repairing Office licenses..." call :dk_color %Blue% "Repairing Office licenses..."
echo: echo:
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE') do set arch=%%b
if /i "%arch%"=="x86" (
set arch=X86
) else (
set arch=X64
)
for %%# in (68 86) do ( for %%# in (68 86) do (
for %%A in (msi14 msi15 msi16 c2r14 c2r15 c2r16) do (set %%A_%%#=&set %%Arepair%%#=) for %%A in (msi14 msi15 msi16 c2r14 c2r15 c2r16) do (set %%A_%%#=&set %%Arepair%%#=)
) )
@ -874,17 +802,17 @@ set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office
reg query %_68%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_68=Office 14.0 C2R x86/x64" & set "c2r14repair68=") reg query %_68%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_68=Office 14.0 C2R x86/x64" & set "c2r14repair68=")
reg query %_86%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_86=Office 14.0 C2R x86" & set "c2r14repair86=") reg query %_86%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_86=Office 14.0 C2R x86" & set "c2r14repair86=")
for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi14_86=Office 14.0 MSI x86" & call :getrepairsetup msi14repair86 14) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_86=Office 14.0 MSI x86" & call :getrepairsetup msi14repair86 14)
for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi14_68=Office 14.0 MSI x86/x64" & call :getrepairsetup msi14repair68 14) for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_68=Office 14.0 MSI x86/x64" & call :getrepairsetup msi14repair68 14)
for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi15_86=Office 15.0 MSI x86" & call :getrepairsetup msi15repair86 15) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi15_86=Office 15.0 MSI x86" & call :getrepairsetup msi15repair86 15)
for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi15_68=Office 15.0 MSI x86/x64" & call :getrepairsetup msi15repair68 15) for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi15_68=Office 15.0 MSI x86/x64" & call :getrepairsetup msi15repair68 15)
for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi16_86=Office 16.0 MSI x86" & call :getrepairsetup msi16repair86 16) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi16_86=Office 16.0 MSI x86" & call :getrepairsetup msi16repair86 16)
for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi16_68=Office 16.0 MSI x86/x64" & call :getrepairsetup msi16repair68 16) for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi16_68=Office 16.0 MSI x86/x64" & call :getrepairsetup msi16repair68 16)
for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (set "c2r15_86=Office 15.0 C2R x86" & call :getc2rrepair c2r15repair86 integratedoffice.exe) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (set "c2r15_86=Office 15.0 C2R x86" & set "c2r15repair86=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\integratedoffice.exe")
for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (set "c2r15_68=Office 15.0 C2R x86/x64" & call :getc2rrepair c2r15repair68 integratedoffice.exe) for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (set "c2r15_68=Office 15.0 C2R x86/x64" & set "c2r15repair68=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\integratedoffice.exe")
for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (set "c2r16_86=Office 16.0 C2R x86" & call :getc2rrepair c2r16repair86 OfficeClickToRun.exe) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (set "c2r16_86=Office 16.0 C2R x86" & set "c2r16repair86=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\OfficeClickToRun.exe")
for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (set "c2r16_68=Office 16.0 C2R x86/x64" & call :getc2rrepair c2r16repair68 OfficeClickToRun.exe) for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (set "c2r16_68=Office 16.0 C2R x86/x64" & set "c2r16repair68=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\OfficeClickToRun.exe")
set uwp16= set uwp16=
if %winbuild% GEQ 10240 ( if %winbuild% GEQ 10240 (
@ -945,8 +873,11 @@ pause %nul1%
if defined uwp16 ( if defined uwp16 (
echo: echo:
echo Skipping repair for Office 16.0 UWP... echo Note: Skipping repair for Office 16.0 UWP...
echo You need to use the Reset option in Windows Settings instead.
echo ________________________________________________________________
echo: echo:
start ms-settings:appsfeatures
) )
set c2r14= set c2r14=
@ -955,8 +886,11 @@ if defined c2r14_86 set c2r14=1
if defined c2r14 ( if defined c2r14 (
echo: echo:
echo Skipping repair for Office 14.0 C2R... echo Note: Skipping repair for Office 14.0 C2R...
echo You need to use the Repair option in Windows Settings for it.
echo ________________________________________________________________
echo: echo:
start appwiz.cpl
) )
if defined msi14_68 if exist "%msi14repair68%" echo Running - "%msi14repair68%" & "%msi14repair68%" if defined msi14_68 if exist "%msi14repair68%" echo Running - "%msi14repair68%" & "%msi14repair68%"
@ -979,15 +913,6 @@ echo:
call :dk_color %Green% "Finished" call :dk_color %Green% "Finished"
goto :at_back goto :at_back
:getc2rrepair
for %%# in (X86 X64) do (
if exist "%systemdrive%\Program Files\Microsoft Office 15\Client%%#\%2" (
set "%1=%systemdrive%\Program Files\Microsoft Office 15\Client%%#\%2"
)
)
exit /b
:getrepairsetup :getrepairsetup
set "_common86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE%2\Office Setup Controller\setup.exe" set "_common86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE%2\Office Setup Controller\setup.exe"
@ -1152,7 +1077,7 @@ if %errorlevel% NEQ 0 (set error=1& exit /b)
%psc% "try { $null=([WMISEARCHER]'SELECT * FROM SoftwareLicensingService').Get().Version; exit 0 } catch { exit $_.Exception.InnerException.HResult }" %nul% %psc% "try { $null=([WMISEARCHER]'SELECT * FROM SoftwareLicensingService').Get().Version; exit 0 } catch { exit $_.Exception.InnerException.HResult }" %nul%
cmd /c exit /b %errorlevel% cmd /c exit /b %errorlevel%
echo "0x%=ExitCode%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% echo "0x%=ExitCode%" | findstr /i "0x800410 0x800440" %nul1%
if %errorlevel% EQU 0 set error=1 if %errorlevel% EQU 0 set error=1
exit /b exit /b
@ -1213,8 +1138,6 @@ exit /b
set permerror= set permerror=
if not exist "%tokenstore%\" set "permerror=Error Found In Token Folder" if not exist "%tokenstore%\" set "permerror=Error Found In Token Folder"
if defined ps32onArm exit /b
for %%# in ( for %%# in (
"%tokenstore%+FullControl" "%tokenstore%+FullControl"
"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" "HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey"
@ -1359,13 +1282,13 @@ function InstallLicenseArr($Str) {
ForEach ($x in $a) {InstallLicenseFile "$x"} ForEach ($x in $a) {InstallLicenseFile "$x"}
} }
function InstallLicenseDir($Loc) { function InstallLicenseDir($Loc) {
Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName} dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"}
} }
function ReinstallLicenses() { function ReinstallLicenses() {
$Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens") $Oem = "$env:SysPath\oem"
foreach ($Path in $Paths) { $Spp = "$env:SysPath\spp\tokens"
if (Test-Path $Path) { InstallLicenseDir "$Path" } InstallLicenseDir "$Spp"
} If (Test-Path $Oem) {InstallLicenseDir "$Oem"}
} }
:xrm: :xrm:
@ -1379,7 +1302,6 @@ for %%# in (
%SysPath%\spp\store\ %SysPath%\spp\store\
%SysPath%\spp\store\2.0\ %SysPath%\spp\store\2.0\
%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\ %Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\
%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareLicensing\
) do ( ) do (
if %1==check ( if %1==check (
@ -1455,40 +1377,12 @@ $key.SetAccessControl($acl)
::======================================================================================================================================== ::========================================================================================================================================
:dk_color
if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m
) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
)
exit /b
:dk_color2
if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
)
exit /b
::========================================================================================================================================
:dk_done :dk_done
echo: echo:
if %_unattended%==1 timeout /t 2 & exit /b
if defined fixes ( if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to open Troubleshoot page " %Gray% " Press [0] to ignore"
call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 exit /b
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#))
) )
@ -1499,7 +1393,26 @@ choice /c 0 /n
call :dk_color %_Yellow% "Press any key to %_exitmsg%..." call :dk_color %_Yellow% "Press any key to %_exitmsg%..."
pause %nul1% pause %nul1%
) )
exit /b
::========================================================================================================================================
:dk_color
if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m
) else (
%psc% write-host -back '%1' -fore '%2' '%3'
)
exit /b
:dk_color2
if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
)
exit /b exit /b
::======================================================================================================================================== ::========================================================================================================================================
@ -1508,29 +1421,20 @@ exit /b
:dk_setvar :dk_setvar
set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
echo "%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%" | find /i "ARM64" %nul1% && (if %winbuild% LSS 21277 set ps32onArm=1)
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a"
set "Red="41;97m"" set "Red="41;97m""
set "Gray="100;97m"" set "Gray="100;97m""
set "Green="42;97m"" set "Green="42;97m""
set "Blue="44;97m"" set "Blue="44;97m""
set "White="107;91m""
set "_Red="40;91m"" set "_Red="40;91m""
set "_White="40;37m"" set "_White="40;37m""
set "_Green="40;92m"" set "_Green="40;92m""
@ -1540,7 +1444,6 @@ set "Red="Red" "white""
set "Gray="Darkgray" "white"" set "Gray="Darkgray" "white""
set "Green="DarkGreen" "white"" set "Green="DarkGreen" "white""
set "Blue="Blue" "white"" set "Blue="Blue" "white""
set "White="White" "Red""
set "_Red="Black" "Red"" set "_Red="Black" "Red""
set "_White="Black" "Gray"" set "_White="Black" "Gray""
set "_Green="Black" "Green"" set "_Green="Black" "Green""

110
README.md
View file

@ -2,117 +2,61 @@
<h1 align="center">Microsoft Activation Scripts (MAS)</h1> <h1 align="center">Microsoft Activation Scripts (MAS)</h1>
<p align="center">Open-source Windows and Office activator featuring HWID, Ohook, TSforge, KMS38, and Online KMS activation methods, along with advanced troubleshooting.</p> <p align="center">A Windows and Office activator using HWID / Ohook / KMS38 / Online KMS activation methods, with a focus on open-source code and fewer antivirus detections.</p>
<p align="center">
<a href="https://discord.gg/tVFN4N84PP"><img src="https://img.shields.io/badge/Chat%20with%20us%20on%20Discord--blue?style=social&logo=discord" alt="Chat with us without signup" title="Chat with us without signup"></a>
<a href="https://www.reddit.com/r/MAS_Activator"><img src="https://img.shields.io/badge/MAS%20on%20Reddit--orange?style=social&logo=reddit" alt="MAS on Reddit" title="MAS on Reddit"></a>
<a href="https://twitter.com/massgravel"><img src="https://img.shields.io/twitter/follow/massgravel" alt="Follow us on X" title="Follow us on X"></a>
</p>
<hr> <hr>
## How to Activate Windows / Office? ## Download / How to use it?
### Method 1 - PowerShell (Windows 8 and later) ❤️ ### Method 1 - PowerShell (Windows 8 and later) ❤️
1. **Open PowerShell** 1. Open PowerShell (Not CMD). To do that, right-click on the Windows start menu and select PowerShell or Terminal.
To do that, press the Windows key + X, then select PowerShell or Terminal. 2. Copy and paste the code below and press enter
2. **Copy and paste the code below, then press enter.**
``` ```
irm https://get.activated.win | iex irm https://get.activated.win | iex
``` ```
Alternatively, you can use the following (this will be deprecated in the future): or (deprecated, will be retired on Dec 31 2024, use above instead)
``` ```
irm https://massgrave.dev/get | iex irm https://massgrave.dev/get | iex
``` ```
3. You will see the activation options. Choose [1] HWID for Windows activation. Choose [2] Ohook for Office activation.
3. You will see the activation options. 4. That's all.
Press 1 HWID for Windows activation.
Press 2 Ohook for Office activation.
4. That's all
--- ---
### Method 2 - Traditional (Windows Vista and later) - On older Windows builds you may need to run the below command before,
`[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12`
- The Powershell method does not work on Windows 7. Use the Method 2 - Traditional instead.
- The URL get.activated.win may be blocked by some DNS services because it is a new domain.
<details> ### Method 2 - Traditional (Windows 7 and later)
<summary>Click here to view</summary>
1. Download the file using one of the links below: 1. Download the file under the code button from [GitHub](https://github.com/massgravel/Microsoft-Activation-Scripts) or [Bitbucket](https://bitbucket.org/WindowsAddict/microsoft-activation-scripts) or [Codeberg](https://codeberg.org/massgravel/Microsoft-Activation-Scripts)
`https://github.com/massgravel/Microsoft-Activation-Scripts/archive/refs/heads/master.zip` 2. Right-click on the downloaded zip file and extract
or 3. In the extracted folder, find the folder named `All-In-One-Version`
`https://git.activated.win/massgrave/Microsoft-Activation-Scripts/archive/master.zip` 4. Run the file named `MAS_AIO.cmd`
2. Right-click on the downloaded zip file and extract it. 5. You will see the activation options, follow the on-screen instructions.
3. In the extracted folder, find the folder named `All-In-One-Version`.
4. Run the file named `MAS_AIO.cmd`.
5. You will see the activation options. Follow the on-screen instructions.
6. That's all. 6. That's all.
</details> To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches)
--- </br>
- **[Office for macOS](https://massgrave.dev/office_for_mac)**
- To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches).
---
### Not working ❓
- If you are **unable to launch MAS** using the PowerShell method, please refer to **Method 2** listed above.
- If MAS is launched and the script shows any errors, check for any troubleshooting steps mentioned in blue color and try to follow those.
- If you have any issues, please feel free to reach out to us [here](https://massgrave.dev/troubleshoot).
---
> [!NOTE]
>
> - The IRM command in PowerShell downloads a script from a specified URL, and the IEX command executes it.
> - Always double-check the URL before executing the command and verify the source if manually downloading files.
> - Be cautious, as some spread malware disguised as MAS by using different URLs in the IRM command.
---
``` ```
Latest Version: 3.2 Latest Version: 2.7
Release date: 6-May-2025 Release date: 6-Sep-2024
``` ```
### [Troubleshooting / Help](https://massgrave.dev/troubleshoot) ### [Troubleshooting / Help](https://massgrave.dev/troubleshoot)
### [Download Original Windows & Office](https://massgrave.dev/genuine-installation-media) ### [Download Original Windows & Office](https://massgrave.dev/genuine-installation-media)
### Homepage - [https://massgrave.dev/](https://massgrave.dev/) ### Homepage - [https://massgrave.dev/](https://massgrave.dev/)
<div align="center">
[![1.1]][1]
[![1.2]][2]
[![1.3]][3]
</div>
<div align="center">
[![1.4]][4]
[![1.5]][5]
[![1.6]][6]
[![1.7]][7]
</div>
[1.1]: https://massgrave.dev/img/logo_github.png (GitHub)
[1.2]: https://massgrave.dev/img/logo_azuredevops.png (AzureDevOps)
[1.3]: https://massgrave.dev/img/logo_gitea.png (Self-hosted Git)
[1.4]: https://massgrave.dev/img/logo_discord.png (Chat with us without signup)
[1.5]: https://massgrave.dev/img/logo_reddit.png (Reddit)
[1.6]: https://massgrave.dev/img/logo_bluesky.png (Bluesky)
[1.7]: https://massgrave.dev/img/logo_x.png (Twitter)
[1]: https://github.com/massgravel/Microsoft-Activation-Scripts
[2]: https://dev.azure.com/massgrave/_git/Microsoft-Activation-Scripts
[3]: https://git.activated.win/massgrave/Microsoft-Activation-Scripts
[4]: https://discord.gg/j2yFsV5ZVC
[5]: https://www.reddit.com/r/MAS_Activator
[6]: https://bsky.app/profile/massgrave.dev
[7]: https://twitter.com/massgravel
--- ---
<p align="center">Made with Love ❤️</p> <p align="center">Made with Love ❤️</p>