diff --git a/.gitattributes b/.gitattributes index 4d21483..de5bd3d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -# MAS export-ignore -# LICENSE export-ignore -# README.md export-ignore -# .gitattributes export-ignore +MAS export-ignore +LICENSE export-ignore +README.md export-ignore +.gitattributes export-ignore diff --git a/MAS/All-In-One-Version-KL/MAS_AIO.cmd b/MAS/All-In-One-Version-KL/MAS_AIO.cmd index fdadbf4..be4714c 100644 --- a/MAS/All-In-One-Version-KL/MAS_AIO.cmd +++ b/MAS/All-In-One-Version-KL/MAS_AIO.cmd @@ -1,18 +1,19 @@ -@::sfh437frandom -@set masver=3.9 +@::7f8jhe-random +@set masver=3.2 @setlocal DisableDelayedExpansion @echo off -:: For command line switches, check mass{}grave{dot}dev/command_line_switches -:: If you want to better understand script, read from separate files version. +:: For command line switches, check mass<>grave<.>dev/command_line_switches +:: If you want to better understand script, read from MAS separate files version. ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass<>grave<.>dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -43,7 +44,6 @@ set "_cmdf=%~f0" for %%# in (%*) do ( if /i "%%#"=="re1" set re1=1 if /i "%%#"=="re2" set re2=1 -if /i "%%#"=="-qedit" (set re1=1&set re2=1) ) :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows @@ -67,8 +67,6 @@ exit /b set "blank=" set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" -set "github=ht%blank%tps%blank%://github.com/massgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" -set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/massg%blank%rave/Micr%blank%osoft-Act%blank%ivation-Scripts" :: Check if Null service is working, it's important for the batch script @@ -143,16 +141,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto dk_done ) -if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( -sc query gcs | find /i "RUNNING" %nul% && ( -%eline% -echo Windows Sandbox detected; activation is not supported. -echo The script cannot run due to missing licensing components. Aborting... -echo: -goto dk_done -) -) - if %winbuild% LSS 6001 ( %nceline% echo Unsupported OS version detected [%winbuild%]. @@ -225,18 +213,16 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) +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% -for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) -echo Test 1 - %tstresult% -echo Test 2 - !tstresult2! -echo: +echo: %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" REM check LanguageMode -echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +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: @@ -249,9 +235,6 @@ 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... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" goto dk_done ) @@ -266,33 +249,10 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_ goto dk_done ) -REM check if .NET is working properly - -if /i "!tstresult2!"=="FullLanguage" ( -cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% -if !errorlevel!==3 ( -echo Windows Powershell failed to load .NET command. Aborting... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -goto dk_done -) -) - REM check antivirus and other errors echo PowerShell is not working properly. Aborting... - -if /i "!tstresult2!"=="FullLanguage" ( -echo: -echo Your antivirus software might be blocking the script. -echo: -sc query sense | find /i "RUNNING" %nul% && ( -echo Installed Antivirus - Microsoft Defender for Endpoint -) -cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" -) - +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" @@ -313,9 +273,7 @@ set terminal= if defined terminal ( set lines=0 -for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( -for %%B in (%%A) do set lines=%%B -) +for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A if !lines! GEQ 100 set terminal= ) @@ -376,7 +334,7 @@ echo: call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" choice /C:10 /N if !errorlevel!==2 rem -if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) +if !errorlevel!==1 (start %mas% & exit /b) ) ) @@ -390,6 +348,7 @@ set _elev= if defined _args echo "%_args%" | find /i "/S" %nul% && (set "_silent=%nul%") || (set _silent=) if defined _args echo "%_args%" | find /i "/" %nul% && ( echo "%_args%" | find /i "/HWID" %nul% && (setlocal & cls & (call :HWIDActivation %_args% %_silent%) & endlocal) +echo "%_args%" | find /i "/KMS38" %nul% && (setlocal & cls & (call :KMS38Activation %_args% %_silent%) & endlocal) echo "%_args%" | find /i "/Z-" %nul% && (setlocal & cls & (call :TSforgeActivation %_args% %_silent%) & endlocal) echo "%_args%" | find /i "/K-" %nul% && (setlocal & cls & (call :KMSActivation %_args% %_silent%) & endlocal) echo "%_args%" | find /i "/Ohook" %nul% && (setlocal & cls & (call :OhookActivation %_args% %_silent%) & endlocal) @@ -424,34 +383,14 @@ color 07 title Microsoft %blank%Activation %blank%Scripts %masver% if not defined terminal mode 76, 34 -if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" set _serexist=1 -if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" set _evalexist=1 -if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-EnterpriseS*dition~*.mum" set _ltscexist=1 -if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-EnterpriseSN*dition~*.mum" set _ltscnexist=1 - -if %winbuild% GEQ 10240 if not defined _serexist if not defined _evalexist set _hwidgo=1 -if %winbuild% GTR 14393 if defined _ltscnexist set _hwidgo= +if %winbuild% GEQ 10240 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" set _hwidgo=1 +if %winbuild% GTR 14393 if exist "%SysPath%\spp\tokens\skus\EnterpriseSN\" set _hwidgo= if not defined _hwidgo set _tsforgego=1 - set _ohookgo=1 -if %winbuild% GEQ 9200 ( -if %winbuild% LSS 10240 set _ohookgo= -if %winbuild% GEQ 19041 if %winbuild% LEQ 19045 set _ohookgo= -if defined _serexist set _ohookgo= -if defined _evalexist set _ohookgo= -if defined _ltscexist set _ohookgo= -reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %nul2% | find /i "O365" %nul% && set _ohookgo=1 -reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\ClickToRun\Configuration /v ProductReleaseIds %nul2% | find /i "O365" %nul% && set _ohookgo=1 -) -if not defined _ohookgo set _tsforgego=1 echo: echo: echo: -if %winbuild% GEQ 10240 if %winbuild% LEQ 19045 if not defined _serexist if not defined _evalexist if not defined _ltscexist ( -call :dk_color2 %_Green% " Tip:" %_White% " To activate ESU updates after W10 EOL, use TSforge option." -) -echo: echo: echo: ______________________________________________________________ echo: @@ -472,32 +411,34 @@ call :dk_color3 %_White% " [3] " %_Green% "TSforge" %_White% " ) else ( echo: [3] TSforge - Windows / Office / ESU ) -echo: [4] Online KMS - Windows / Office +echo: [4] KMS38 - Windows +echo: [5] Online KMS - Windows / Office echo: __________________________________________________ echo: -echo: [5] Check Activation Status -echo: [6] Change Windows Edition -echo: [7] Change Office Edition +echo: [6] Check Activation Status +echo: [7] Change Windows Edition +echo: [8] Change Office Edition echo: __________________________________________________ echo: -echo: [8] Troubleshoot +echo: [9] Troubleshoot echo: [E] Extras echo: [H] Help echo: [0] Exit echo: ______________________________________________________________ echo: call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard [1,2,3...E,H,0] :" -choice /C:12345678EH0 /N +choice /C:123456789EH0 /N set _erl=%errorlevel% -if %_erl%==11 exit /b -if %_erl%==10 (start %selfgit% & start %github% & start %mas%troubleshoot & goto :MainMenu) -if %_erl%==9 goto :Extras -if %_erl%==8 setlocal & call :troubleshoot & cls & endlocal & goto :MainMenu -if %_erl%==7 setlocal & call :change_offedition & cls & endlocal & goto :MainMenu -if %_erl%==6 setlocal & call :change_winedition & cls & endlocal & goto :MainMenu -if %_erl%==5 setlocal & call :check_actstatus & cls & endlocal & goto :MainMenu -if %_erl%==4 setlocal & call :KMSActivation & cls & endlocal & goto :MainMenu +if %_erl%==12 exit /b +if %_erl%==11 start %mas%troubleshoot & goto :MainMenu +if %_erl%==10 goto :Extras +if %_erl%==9 setlocal & call :troubleshoot & cls & endlocal & goto :MainMenu +if %_erl%==8 setlocal & call :change_offedition & cls & endlocal & goto :MainMenu +if %_erl%==7 setlocal & call :change_winedition & cls & endlocal & goto :MainMenu +if %_erl%==6 setlocal & call :check_actstatus & cls & endlocal & goto :MainMenu +if %_erl%==5 setlocal & call :KMSActivation & cls & endlocal & goto :MainMenu +if %_erl%==4 setlocal & call :KMS38Activation & cls & endlocal & goto :MainMenu if %_erl%==3 setlocal & call :TSforgeActivation & cls & endlocal & goto :MainMenu if %_erl%==2 setlocal & call :OhookActivation & cls & endlocal & goto :MainMenu if %_erl%==1 setlocal & call :HWIDActivation & cls & endlocal & goto :MainMenu @@ -573,29 +514,31 @@ echo: echo: Extract $OEM$ folder on the desktop echo: ____________________________________________________________ echo: -echo: [1] HWID [Windows] -echo: [2] Ohook [Office] -echo: [3] TSforge [Windows / ESU / Office] -echo: [4] Online KMS [Windows / Office] +echo: [1] HWID [Windows] +echo: [2] Ohook [Office] +echo: [3] TSforge [Windows / ESU / Office] +echo: [4] KMS38 [Windows] +echo: [5] Online KMS [Windows / Office] echo: -echo: [5] HWID [Windows] ^+ Ohook [Office] -echo: [6] HWID [Windows] ^+ Ohook [Office] ^+ TSforge [ESU] -echo: [7] TSforge [Windows / ESU] ^+ Ohook [Office] +echo: [6] HWID [Windows] ^+ Ohook [Office] +echo: [7] HWID [Windows] ^+ Ohook [Office] ^+ TSforge [ESU] +echo: [8] TSforge [Windows] ^+ Online KMS [Office] echo: call :dk_color2 %_White% " [R] " %_Green% "ReadMe" echo: [0] Go Back echo: ____________________________________________________________ echo: call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard :" -choice /C:1234567R0 /N +choice /C:12345678R0 /N set _erl=%errorlevel% -if %_erl%==9 goto:Extras -if %_erl%==8 start %mas%oem-folder &goto:Extract$OEM$2 -if %_erl%==7 (set "_oem=TSforge [Windows / ESU] + Ohook [Office]" & set "para=/Z-Windows /Z-ESU /Ohook" &goto:Extract$OEM$3) -if %_erl%==6 (set "_oem=HWID [Windows] + Ohook [Office] + TSforge [ESU]" & set "para=/HWID /Ohook /Z-ESU" &goto:Extract$OEM$3) -if %_erl%==5 (set "_oem=HWID [Windows] + Ohook [Office]" & set "para=/HWID /Ohook" &goto:Extract$OEM$3) -if %_erl%==4 (set "_oem=Online KMS" & set "para=/K-WindowsOffice" &goto:Extract$OEM$3) +if %_erl%==10 goto:Extras +if %_erl%==9 start %mas%oem-folder &goto:Extract$OEM$2 +if %_erl%==8 (set "_oem=TSforge [Windows] + Online KMS [Office]" & set "para=/Z-Windows /K-Office" &goto:Extract$OEM$3) +if %_erl%==7 (set "_oem=HWID [Windows] + Ohook [Office] + TSforge [ESU]" & set "para=/HWID /Ohook /Z-ESU" &goto:Extract$OEM$3) +if %_erl%==6 (set "_oem=HWID [Windows] + Ohook [Office]" & set "para=/HWID /Ohook" &goto:Extract$OEM$3) +if %_erl%==5 (set "_oem=Online KMS" & set "para=/K-WindowsOffice" &goto:Extract$OEM$3) +if %_erl%==4 (set "_oem=KMS38" & set "para=/KMS38" &goto:Extract$OEM$3) if %_erl%==3 (set "_oem=TSforge" & set "para=/Z-WindowsESUOffice" &goto:Extract$OEM$3) if %_erl%==2 (set "_oem=Ohook" & set "para=/Ohook" &goto:Extract$OEM$3) if %_erl%==1 (set "_oem=HWID" & set "para=/HWID" &goto:Extract$OEM$3) @@ -610,7 +553,7 @@ set "_dir=!desktop!\$OEM$\$$\Setup\Scripts" md "!_dir!\" :: Add random data on top to create unique file which helps in avoiding AV's detections -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!'); [io.file]::WriteAllText('!_pdesk!\$OEM$\$$\Setup\Scripts\MAS_AIO.cmd', '@::RANDOM-' + [Guid]::NewGuid().Guid + [Environment]::NewLine + $f, [System.Text.Encoding]::ASCII)" +%psc% "$f=[io.file]::ReadAllText('!_batp!'); [io.file]::WriteAllText('!_pdesk!\$OEM$\$$\Setup\Scripts\MAS_AIO.cmd', '@::RANDOM-' + [Guid]::NewGuid().Guid + [Environment]::NewLine + $f, [System.Text.Encoding]::ASCII)" ( echo @echo off @@ -633,6 +576,11 @@ echo: call :dk_color %Blue% "%_oem%" call :dk_color %Green% "$OEM$ folder was successfully created on your Desktop." ) +echo "%_oem%" | find /i "KMS38" 1>nul && ( +echo: +echo To KMS38 activate Server Cor/Acor editions ^(No GUI Versions^), +echo Check this page %mas%oem-folder +) echo ___________________________________________________________________ echo: call :dk_color %_Yellow% "Press [0] key to %_exitmsg%..." @@ -718,8 +666,8 @@ 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%in-place_repair_upgrade -call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) goto dk_done ) @@ -828,7 +776,7 @@ set notworking= call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f if defined allapps call :hwiddata key if not defined key ( -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getactivationid\:.*';. ([scriptblock]::Create($f[1]))"') do (set altapplist=%%a) +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getactivationid\:.*';iex ($f[1])"') do (set altapplist=%%a) if defined altapplist call :hwiddata key ) @@ -886,15 +834,12 @@ call :dk_inskey "[%key%]" for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Control Panel\International\Geo" /v Name %nul6%') do set "name=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Control Panel\International\Geo" /v Nation %nul6%') do set "nation=%%b" -:: Skip changing region in top countries - +set regionchange= +if not "%name%"=="US" ( set regionchange=1 -for %%# in (US CN IN BR DE JP GB FR MX ID IT PK TR KR CA ES AU NG VN PL PH NL EG AR TH CO SA TW MY CL) do if /i "%name%"=="%%#" set regionchange= - -if defined regionchange ( %psc% "Set-WinHomeLocation -GeoId 244" %nul% if !errorlevel! EQU 0 ( -echo Changing Windows Region To USA [Successful] [Script will change it back] +echo Changing Windows Region To USA [Successful] ) else ( call :dk_color %Red% "Changing Windows Region To USA [Failed]" ) @@ -965,9 +910,7 @@ call :dk_color %Red% "Checking Ticket Migration [Failed]" if not defined altapplist if not defined showfix if defined rebuildinfo ( set showfix=1 -echo: call :dk_color %Blue% "%_fixmsg%" -echo: ) if exist "%tdir%\Genuine*" del /f /q "%tdir%\Genuine*" %nul% @@ -1037,10 +980,8 @@ licensing.mp.microsoft.com findstr /i "%%#" "%SysPath%\drivers\etc\hosts" %nul1% && set "hosfail= [%%# Blocked in Hosts]" ) call :dk_color %Red% "Checking Licensing Servers [Failed to Connect]!hosfail!" -echo: set fixes=%fixes% %mas%licensing-servers-issue call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%licensing-servers-issue" -echo: ) ::========================================================================================================================================== @@ -1053,17 +994,13 @@ reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWin reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DoNotConnectToWindowsUpdateInternetLocations %nul2% | find /i "0x1" %nul% && set wublock=1 if defined wublock ( call :dk_color %Red% "Checking Update Blocker In Registry [Found]" -echo: call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it." -echo: ) reg query "HKLM\SOFTWARE\Policies\Microsoft\WindowsStore" /v DisableStoreApps %nul2% | find /i "0x1" %nul% && ( set storeblock=1 call :dk_color %Red% "Checking Store Blocker In Registry [Found]" -echo: call :dk_color %Blue% "If you have used any tool to block Store, undo it." -echo: ) set wcount=0 @@ -1080,14 +1017,10 @@ set error=1 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." -echo: set fixes=%fixes% %mas%remove_mal%w%ware call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" -echo: ) else ( -echo: call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it." -echo: ) ) else ( %psc% "Start-Job { Start-Service wuauserv } | Wait-Job -Timeout 20 | Out-Null" @@ -1096,9 +1029,7 @@ set error=1 set wuerror=1 sc start wuauserv %nul% call :dk_color %Red% "Starting Windows Update Service [Failed] [!errorlevel!]" -echo: call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it." -echo: ) ) ) @@ -1111,10 +1042,8 @@ 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% && ( call :dk_color %Red% "Checking Internet Issues [Found] %error_code%" -echo: set fixes=%fixes% %mas%licensing-servers-issue call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%licensing-servers-issue" -echo: ) ) ) @@ -1169,7 +1098,7 @@ goto :dk_done set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=%ps% -nop -c set winbuild=1 -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +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) @@ -1258,7 +1187,7 @@ for /f "tokens=3 delims=." %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Con if %_wmic% EQU 1 for /f "tokens=2 delims==" %%a in ('"wmic Path Win32_OperatingSystem Get OperatingSystemSKU /format:LIST" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" if %_wmic% EQU 0 for /f "tokens=1" %%a in ('%psc% "([WMI]'Win32_OperatingSystem=@').OperatingSystemSKU" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" -if %winbuild% GEQ 15063 %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';. ([scriptblock]::Create($f[1]))" %nul2% | find /i "Subscription_is_activated" %nul% && ( +if %winbuild% GEQ 15063 %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';iex ($f[1])" %nul2% | find /i "Subscription_is_activated" %nul% && ( if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" ( set winsub=1 set osSKU=%regSKU% @@ -1321,11 +1250,9 @@ if %sps%==SoftwareLicensingService call :dk_refresh echo %keyecho% %~1 [Successful] ) else ( call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" -if not defined showfix ( +if not defined error ( if defined altapplist call :dk_color %Red% "Activation ID not found for this key." -echo: call :dk_color %Blue% "%_fixmsg%" -echo: set showfix=1 ) set error=1 @@ -1359,9 +1286,9 @@ if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISE if defined allapps if %1==0ff1ce15-a989-479d-af46-f275c6370663 ( set len=0 -echo:!allapps!> "!_ttemp!\chklen" -for %%A in ("!_ttemp!\chklen") do (set len=%%~zA) -del "!_ttemp!\chklen" %nul% +echo:!allapps!> %SystemRoot%\Temp\chklen +for %%A in (%SystemRoot%\Temp\chklen) do (set len=%%~zA) +del %SystemRoot%\Temp\chklen %nul% if !len! GTR 6000 ( %eline% @@ -1464,11 +1391,6 @@ set spperror=%errorlevel% if %spperror% NEQ 1056 if %spperror% NEQ 0 ( %eline% echo sc start %_slser% [Error Code: %spperror%] -if %spperror% EQU 1053 ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and try again." -call :dk_color %Blue% "If it still does not work, go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -) ) echo: @@ -1546,8 +1468,7 @@ if not exist %SysPath%\%_slexe% if not exist %SysPath%\alg.exe (set "results=%re if not "%results%%pupfound%"=="" ( if defined pupfound call :dk_color %Gray% "Checking PUP Activators [Found%pupfound%]" if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..." -if defined results (call :dk_color %Red% "%results%"&set showfix=1) -echo: +if defined results call :dk_color %Red% "%results%" set fixes=%fixes% %mas%remove_mal%w%ware call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" echo: @@ -1568,118 +1489,40 @@ exit /b set showfix= call :dk_chkmal -::============================== - :: Check Sandboxing sc query Null %nul% || ( -call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly]" -if not defined showfix ( -echo: +set error=1 +set showfix=1 +call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly.]" call :dk_color %Blue% "If you are using any third-party antivirus, check if it is blocking the script." echo: ) -set error=1 -set showfix=1 -) -::============================== - -:: Check WinPE mode - -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( - -call :dk_color %Red% "Checking WinPE [Found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "WinPE mode found. Reboot the system and run in normal mode." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check Safe mode - -if defined safeboot_option ( -call :dk_color %Red% "Checking Boot Mode [%safeboot_option%]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Safe mode found. Reboot the system and run in normal mode." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check ImageState -:: https://learn.microsoft.com/en-us/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) - -if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" ( -call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]" -echo "%imagestate%" | find /i "RESEAL" %nul% && ( -if not defined showfix ( -echo: -call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode." -echo: -) -set error=1 -set showfix=1 -) -echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && ( -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -) -) - -::============================== +::======================================================================================================================================== :: Check corrupt services set serv_cor= for %%# in (%_serv%) do ( -set _regcorr= set _corrupt= sc start %%# %nul% if !errorlevel! EQU 1060 set _corrupt=1 sc query %%# %nul% || set _corrupt=1 -for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type) do if not defined _regcorr ( -reg query HKLM\SYSTEM\CurrentControlSet\Services\%%# /v %%G %nul% || (set _corrupt=1&set _regcorr=-RegistryError) +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 ) -if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#!_regcorr!") else (set "serv_cor=%%#!_regcorr!")) +if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#") else (set "serv_cor=%%#")) ) if defined serv_cor ( -call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" - -if not defined showfix ( -echo: -if /i "%serv_cor%"=="sppsvc-RegistryError" ( -set fixes=%fixes% %mas%fix_service -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_service" -) else ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) -echo: -) - set error=1 set showfix=1 +call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" ) -::============================== +::======================================================================================================================================== :: Check disabled services @@ -1714,26 +1557,11 @@ if defined serv_cste (set "serv_cste=!serv_cste! %%#") else (set "serv_cste=%%#" if defined serv_csts call :dk_color %Gray% "Enabling Disabled Services [Successful] [%serv_csts%]" if defined serv_cste ( -call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" - -if not defined showfix ( -echo: -echo %serv_cste% | findstr /i "ClipSVC sppsvc" %nul% && ( -echo A registry fix has been applied to enable the disabled service. -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -) || ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) -echo: -) - set error=1 -set showfix=1 +call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" ) -::============================== +::======================================================================================================================================== :: Check if the services are able to run or not :: Workarounds are added to get correct status and error code because sc query doesn't output correct results in some conditions @@ -1755,322 +1583,75 @@ if defined checkerror if defined serv_e (set "serv_e=!serv_e!, %%#-!errorcode!") ) if defined serv_e ( +set error=1 call :dk_color %Red% "Starting Services [Failed] [%serv_e%]" - -if not defined showfix ( -set listwospp=%_serv:sppsvc=% -echo %serv_e% | findstr /i "!listwospp!" %nul% && ( +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." set showfix=1 -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and run the script again." +) +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 +) +) + +::======================================================================================================================================== + +:: Various error checks + +if defined safeboot_option ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option%] " %Blue% "[Safe mode found. Run in normal mode.]" +) + + +:: 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) + +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 showfix=1 +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 service error is still not fixed, do this - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: +call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade" ) ) -set error=1 -) -::============================== -:: Check WMI - -set wmifailed= -if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 %_wmic% EQU 1 wmic path %sps% get Version %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% -cmd /c exit /b %error_code% -if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" - -echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants - -if defined wmifailed ( -call :dk_color %Red% "Checking WMI [Not Working]" - -if not defined showfix ( -echo: -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." -echo: -) +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( set error=1 set showfix=1 +call :dk_color2 %Red% "Checking WinPE " %Blue% "[WinPE mode found. Run in normal mode.]" ) -::============================== -:: Check SPP Registry Key - -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% || ( -call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found] [Most likely caused by gaming spoofers]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%issues_due_to_gaming_spoofers -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check TokenStore registry key - -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" -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" ( -call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set toerr=1 -set error=1 -set showfix=1 -) -) - -::============================== - -:: 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%\" ( - -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% 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)';" -set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" -set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" -set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" -%psc% "!d!" %nul% - -if exist "%tokenstore%\" ( -call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" -) else ( -call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set error=1 -set showfix=1 -) -) - -::============================== - -:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. - -set permerror= -if %winbuild% GEQ 9200 if not defined toerr if not defined ps32onArm if exist "%tokenstore%\" ( -for %%# in ( -"%tokenstore%+FullControl" -"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" -"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" -) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( -%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% -if !errorlevel!==2 ( -if "%%A"=="%tokenstore%" ( -set "permerror=Error Found In Token Folder" -) else ( -set "permerror=Error Found In SPP Registries" -) -) -) - -REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application - -if not defined permerror ( -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( -set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" -reg query "!pol!" %nul% || reg add "!pol!" %nul% -%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% -if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" -) -) - -if defined permerror ( -call :dk_color %Red% "Checking SPP Permissions [!permerror!]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -) -set error=1 -set showfix=1 -) -) - -::============================== - -:: Check WPA Registry Errors - -set chkalp= -set wpainfo=NotFound -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wpatest\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do (set wpainfo=%%a) -for /f "delims=0123456789" %%i in ("%wpainfo%") do set chkalp=%%i - -if defined chkalp ( -call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" -if not defined showfix ( +set wpainfo= +set wpaerror= +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1])" %nul6%') do (set wpainfo=%%a) echo "%wpainfo%" | find /i "Error Found" %nul% && ( -echo: -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -echo: set error=1 -set showfix=1 -) -) -set wpainfo=a -) - -if not defined chkalp ( -if %wpainfo% GEQ 5000 ( -call :dk_color %Gray% "Checking WPA Registry Count [%wpainfo%]" -echo: -call :dk_color %Blue% "A large number of WPA registries have been found, which may cause high CPU usage." -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -echo: -) else ( +set wpaerror=1 +call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" +) || ( echo Checking WPA Registry Count [%wpainfo%] ) -) -::============================== - -:: Check Rearm - -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( -call :dk_color %Red% "Checking Rearm [System is Rearmed]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -echo: -) -set error=1 -set showfix=1 -) - - -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( -call :dk_color %Red% "Checking ClipSVC PersistedSystemState [Found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check SoftwareLicensingService - -if %error_code% NEQ 0 ( -call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] [%error_code%]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check Activation IDs - -call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f - -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=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if not defined _vis if !errorlevel! NEQ 0 set rlicfailed=1 -call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f -) - -if not defined apps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -if not defined apps if defined allapps if not defined notwinact ( -call :dk_color %Gray% "Checking Activation IDs [Key Not Installed or Act ID Not Found]" -) - -if not defined apps if not defined allapps ( -call :dk_color %Red% "Checking Activation IDs [Not found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) -set error=1 -set showfix=1 -) - -if not defined showfix if defined rlicfailed ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) - -if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( -call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]" -) - -::============================== - -:: Check Eval Windows if not defined notwinact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || ( -call :dk_color %Red% "Checking Eval Packages [License swapping found. Non-Eval licenses are installed in Eval Windows]" -if not defined showfix ( -echo: -call :dk_color %Blue% "License swapping is not the right way to upgrade to the full version. Learn the correct method at the link below." +call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]" set fixes=%fixes% %mas%evaluation_editions call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" -echo: -) -set error=1 -set showfix=1 ) ) -::============================== - -:: Check HKU\S-1-5-20\Software registry, in some systems it's missing and that causes Windows activation problems - -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( -call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check license and package files for the current edition 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%')" @@ -2090,10 +1671,12 @@ if not defined notwinact ( if %osedition%==0 ( call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" ) 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" ( set skunotfound=1 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%Edition*.mum" ( call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" @@ -2102,9 +1685,31 @@ call :dk_color %Red% "Checking Package Files [Not Found] [%osed ) ) -::============================== -:: Check SKU value to find if there is any difference +if %_wmic% EQU 1 wmic path %sps% get Version %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% +cmd /c exit /b %error_code% +if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" +if %error_code% NEQ 0 ( +set error=1 +call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] %error_code%" +) + + +set wmifailed= +if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 +echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants +if defined wmifailed ( +set error=1 +call :dk_color %Red% "Checking WMI [Not Working]" +if not defined showfix call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." +set showfix=1 +) + if not defined notwinact ( if %winbuild% GEQ 10240 ( @@ -2122,19 +1727,35 @@ call :dk_color %Gray% "Checking SLC/WMI SKU [Difference Found ) ) -::============================== +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Rearm " %Blue% "[System Restart Is Required]" +) + + +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System Restart Is Required]" +) + :: 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. -sc query wlms %nul% - -if %errorlevel% NEQ 1060 ( +if exist "%SysPath%\wlms\wlms.exe" ( echo Checking Eval WLMS Service [Found] ) -::============================== -:: Check SPP interference in IFEO +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( +set error=1 +set showfix=1 +call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" +set fixes=%fixes% %mas%in-place_repair_upgrade +call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +) + for %%# in (SppEx%w%tComObj.exe SLsvc.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=%%#")) @@ -2142,56 +1763,156 @@ reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu if defined _sppint ( echo %_sppint% | find /i "PerfOptions" %nul% && ( call :dk_color %Red% "Checking SPP Interference In IFEO [%_sppint% - System might deactivate later]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -) +if not defined showfix call :dk_color %Blue% "%_fixmsg%" set showfix=1 ) || ( echo Checking SPP In IFEO [%_sppint%] ) ) -::============================== - -:: Check and fix SkipRearm registry value 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 ( reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul% -call :dk_color %Gray% "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" ) -::============================== -:: Check SvcRestartTask status, this task helps in making sure system remains activated +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% || ( +call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]" +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" +set error=1 +set showfix=1 +) + + +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" +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" ( +set toerr=1 +set error=1 +set showfix=1 +call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +) +) + +:: 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%\" ( +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% 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)';" +set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" +set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" +set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" +%psc% "!d!" %nul% +if exist "%tokenstore%\" ( +call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" +) else ( +call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" +set error=1 +set showfix=1 +) +) + + +if not defined notwinact ( +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +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% +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined apps ( +set "_notfoundids=Key Not Installed / Act ID Not Found" +call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined allapps ( +set error=1 +set "_notfoundids=Not found" +) +call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]" +) +) +) + + +if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( +set error=1 +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" ( %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% "$s=New-Object -ComObject 'Schedule.Service'; $s.Connect(); $state=$s.GetFolder('\Microsoft\Windows\SoftwareProtectionPlatform').GetTask('SvcRestartTask').State; @{0='Unknown';1='Disabled';2='Queued';3='Ready';4='Running'}[$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% || ( 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 if "!taskinfo!"=="" set "taskinfo=Not Found" +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." +) +) +) -call :dk_color %Gray% "Checking SvcRestartTask Status [!taskinfo!. System might deactivate later.]" + +:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. + +set permerror= +if %winbuild% GEQ 9200 if not defined ps32onArm ( +for %%# in ( +"%tokenstore%+FullControl" +"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" +"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" +) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( +%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% +if !errorlevel!==2 ( +if "%%A"=="%tokenstore%" ( +set "permerror=Error Found In Token Folder" +) else ( +set "permerror=Error Found In SPP Registries" +) +) +) + +REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application + +if not defined permerror ( +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( +set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" +reg query "!pol!" %nul% || reg add "!pol!" %nul% +%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% +if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" +) +) + +if defined permerror ( +set error=1 +call :dk_color %Red% "Checking SPP Permissions [!permerror!]" +if not defined showfix call :dk_color %Blue% "%_fixmsg%" +set showfix=1 +) +) + + +:: If required services are not disabled or corrupted + if there is any error + SoftwareLicensingService errorlevel is not Zero + no fix was shown before + +if not defined serv_cor if not defined serv_cste if defined error if /i not %error_code%==0 if not defined showfix ( +if not defined permerror if defined wpaerror (call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." & set showfix=1) if not defined showfix ( -echo: -echo "!taskinfo!" | findstr /i "Removed Not Found" %nul1% && ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) || ( -call :dk_color %Blue% "Reboot your machine using the restart option and run the script again." -) -echo: -) -) +set showfix=1 +call :dk_color %Blue% "%_fixmsg%" +if not defined permerror call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." ) ) -::============================== +if not defined showfix if defined wpaerror ( +set showfix=1 +call :dk_color %Blue% "If activation fails then go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." +) exit /b @@ -2283,7 +2004,7 @@ call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" choice /C:10 /N if !errorlevel!==2 exit /b -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -2302,10 +2023,11 @@ exit /b :: 2nd column = Generic Retail/OEM/MAK Key :: 3rd column = SKU ID :: 4th column = Key part number -:: 5th column = 1 = activation is not working (at the time of writing this), 0 = activation is working -:: 6th column = Key Type -:: 7th column = WMI Edition ID (For reference only) -:: 8th column = Version name incase same Edition ID is used in different OS versions with different key +:: 5th column = Ticket signature value. It's as it is, it's not encoded. (Check mass grave[.]dev/hwid#manual-activation to see how it's generated) +:: 6th column = 1 = activation is not working (at the time of writing this), 0 = activation is working +:: 7th column = Key Type +:: 8th column = WMI Edition ID (For reference only) +:: 9th column = Version name incase same Edition ID is used in different OS versions with different key :: Separator = _ @@ -2313,40 +2035,39 @@ exit /b set f= for %%# in ( -8b351c9c-f398-4515-9900-09df49427262_XGVPP-NMH47-7TTHJ-W3FW7-8H%f%V2C___4_X19-99683_0_OEM:NONSLP_Enterprise -c83cef07-6b72-4bbc-a28f-a00386872839_3V6Q6-NQXCX-V8YXR-9QCYV-QP%f%FCT__27_X19-98746_0_Volume:MAK_EnterpriseN -4de7cb65-cdf1-4de9-8ae8-e3cce27b9f2c_VK7JG-NPHTM-C97JM-9MPGT-3V%f%66T__48_X19-98841_0_____Retail_Professional -9fbaf5d6-4d83-4422-870d-fdda6e5858aa_2B87N-8KFHP-DKV6R-Y2C8J-PK%f%CKT__49_X19-98859_0_____Retail_ProfessionalN -f742e4ff-909d-4fe9-aacb-3231d24a0c58_4CPRK-NM3K3-X6XXQ-RXX86-WX%f%CHW__98_X19-98877_0_____Retail_CoreN -1d1bac85-7365-4fea-949a-96978ec91ae0_N2434-X9D7W-8PF6X-8DV9T-8T%f%YMD__99_X19-99652_0_____Retail_CoreCountrySpecific -3ae2cc14-ab2d-41f4-972f-5e20142771dc_BT79Q-G7N6G-PGBYW-4YWX6-6F%f%4BT_100_X19-99661_0_____Retail_CoreSingleLanguage -2b1f36bb-c1cd-4306-bf5c-a0367c2d97d8_YTMG3-N6DKC-DKB77-7M9GH-8H%f%VX7_101_X19-98868_0_____Retail_Core -2a6137f3-75c0-4f26-8e3e-d83d802865a4_XKCNC-J26Q9-KFHD2-FKTHY-KD%f%72Y_119_X19-99606_0_OEM:NONSLP_PPIPro -e558417a-5123-4f6f-91e7-385c1c7ca9d4_YNMGQ-8RYV3-4PGQ3-C8XTP-7C%f%FBY_121_X19-98886_0_____Retail_Education -c5198a66-e435-4432-89cf-ec777c9d0352_84NGF-MHBT6-FXBX8-QWJK7-DR%f%R8H_122_X19-98892_0_____Retail_EducationN -f6e29426-a256-4316-88bf-cc5b0f95ec0c_PJB47-8PN2T-MCGDY-JTY3D-CB%f%CPV_125_X23-50331_1_Volume:MAK_EnterpriseS_Ge -cce9d2de-98ee-4ce2-8113-222620c64a27_KCNVH-YKWX8-GJJB9-H9FDT-6F%f%7W2_125_X22-66075_1_Volume:MAK_EnterpriseS_VB -d06934ee-5448-4fd1-964a-cd077618aa06_43TBQ-NH92J-XKTM7-KT3KK-P3%f%9PB_125_X21-83233_0_OEM:NONSLP_EnterpriseS_RS5 -706e0cfd-23f4-43bb-a9af-1a492b9f1302_NK96Y-D9CD8-W44CQ-R8YTK-DY%f%JWX_125_X21-05035_0_OEM:NONSLP_EnterpriseS_RS1 -faa57748-75c8-40a2-b851-71ce92aa8b45_FWN7H-PF93Q-4GGP8-M8RF3-MD%f%WWW_125_X19-99617_0_OEM:NONSLP_EnterpriseS_TH -3d1022d8-969f-4222-b54b-327f5a5af4c9_2DBW3-N2PJG-MVHW3-G7TDK-9H%f%KR4_126_X21-04921_0_Volume:MAK_EnterpriseSN_RS1 -60c243e1-f90b-4a1b-ba89-387294948fb6_NTX6B-BRYC2-K6786-F6MVQ-M7%f%V2X_126_X19-98770_0_Volume:MAK_EnterpriseSN_TH -01eb852c-424d-4060-94b8-c10d799d7364_3XP6D-CRND4-DRYM2-GM84D-4G%f%G8Y_139_X23-37869_1_____Retail_ProfessionalCountrySpecific_Zn -eb6d346f-1c60-4643-b960-40ec31596c45_DXG7C-N36C4-C4HTG-X4T3X-2Y%f%V77_161_X21-43626_0_____Retail_ProfessionalWorkstation -89e87510-ba92-45f6-8329-3afa905e3e83_WYPNQ-8C467-V2W6J-TX4WX-WT%f%2RQ_162_X21-43644_0_____Retail_ProfessionalWorkstationN -62f0c100-9c53-4e02-b886-a3528ddfe7f6_8PTT6-RNW4C-6V7J2-C2D3X-MH%f%BPB_164_X21-04955_0_____Retail_ProfessionalEducation -13a38698-4a49-4b9e-8e83-98fe51110953_GJTYN-HDMQY-FRR76-HVGC7-QP%f%F8P_165_X21-04956_0_____Retail_ProfessionalEducationN -df96023b-dcd9-4be2-afa0-c6c871159ebe_NJCF7-PW8QT-3324D-688JX-2Y%f%V66_175_X21-41295_0_____Retail_ServerRdsh -d4ef7282-3d2c-4cf0-9976-8854e64a8d1e_V3WVW-N2PV2-CGWC3-34QGF-VM%f%J2C_178_X21-32983_0_____Retail_Cloud -af5c9381-9240-417d-8d35-eb40cd03e484_NH9J3-68WK7-6FB93-4K3DF-DJ%f%4F6_179_X21-32987_0_____Retail_CloudN -8ab9bdd1-1f67-4997-82d9-8878520837d9_XQQYW-NFFMW-XJPBH-K8732-CK%f%FFD_188_X21-99378_0_____OEM:DM_IoTEnterprise -ed655016-a9e8-4434-95d9-4345352c2552_QPM6N-7J2WJ-P88HH-P3YRH-YY%f%74H_191_X21-99682_0_OEM:NONSLP_IoTEnterpriseS_VB -6c4de1b8-24bb-4c17-9a77-7b939414c298_CGK42-GYN6Y-VD22B-BX98W-J8%f%JXD_191_X23-12617_0_OEM:NONSLP_IoTEnterpriseS_Ge -d4bdc678-0a4b-4a32-a5b3-aaa24c3b0f24_K9VKN-3BGWV-Y624W-MCRMQ-BH%f%DCD_202_X22-53884_0_____Retail_CloudEditionN -92fb8726-92a8-4ffc-94ce-f82e07444653_KY7PN-VR6RX-83W6Y-6DDYQ-T6%f%R4W_203_X22-53847_0_____Retail_CloudEdition -5a85300a-bfce-474f-ac07-a30983e3fb90_N979K-XWD77-YW3GB-HBGH6-D3%f%2MH_205_X23-15042_0_____OEM:DM_IoTEnterpriseSK -80083eae-7031-4394-9e88-4901973d56fe_P8Q7T-WNK7X-PMFXY-VXHBG-RR%f%K69_206_X23-62084_0_____OEM:DM_IoTEnterpriseK -1bc2140b-285b-4351-b99c-26a126104b29_TMP2N-KGFHJ-PWM6F-68KCQ-3P%f%JBP_210_X23-60513_0_____Retail_WNC +8b351c9c-f398-4515-9900-09df49427262_XGVPP-NMH47-7TTHJ-W3FW7-8H%f%V2C___4_X19-99683_HGNKjkKcKQHO6n8srMUrDh/MElffBZarLqCMD9rWtgFKf3YzYOLDPEMGhuO/auNMKCeiU7ebFbQALS/MyZ7TvidMQ2dvzXeXXKzPBjfwQx549WJUU7qAQ9Txg9cR9SAT8b12Pry2iBk+nZWD9VtHK3kOnEYkvp5WTCTsrSi6Re4_0_OEM:NONSLP_Enterprise +c83cef07-6b72-4bbc-a28f-a00386872839_3V6Q6-NQXCX-V8YXR-9QCYV-QP%f%FCT__27_X19-98746_NHn2n0N1UfVf00CfaI5LCDMDsKdVAWpD/HAfUrcTAKsw9d2Sks4h5MhyH/WUx+B6dFi8ol7D3AHorR8y9dqVS1Bd2FdZNJl/tTR1PGwYn6KL88NS19aHmFNdX8s4438vaa+Ty8Qk8EDcwm/wscC8lQmi3/RgUKYdyGFvpbGSVlk_0_Volume:MAK_EnterpriseN +4de7cb65-cdf1-4de9-8ae8-e3cce27b9f2c_VK7JG-NPHTM-C97JM-9MPGT-3V%f%66T__48_X19-98841_Yl/jNfxJ1SnaIZCIZ4m6Pf3ySNoQXifNeqfltNaNctx+onwiivOx7qcSn8dFtURzgMzSOFnsRQzb5IrvuqHoxWWl1S3JIQn56FvKsvSx7aFXIX3+2Q98G1amPV/WEQ0uHA5d7Ya6An+g0Z0zRP7evGoomTs4YuweaWiZQjQzSpA_0_____Retail_Professional +9fbaf5d6-4d83-4422-870d-fdda6e5858aa_2B87N-8KFHP-DKV6R-Y2C8J-PK%f%CKT__49_X19-98859_Ge0mRQbW8ALk7T09V+1k1yg66qoS0lhkgPIROOIOgxKmWPAvsiLAYPKDqM4+neFCA/qf1dHFmdh0VUrwFBPYsK251UeWuElj4bZFVISL6gUt1eZwbGfv5eurQ0i+qZiFv+CcQOEFsd5DD4Up6xPLLQS3nAXODL5rSrn2sHRoCVY_0_____Retail_ProfessionalN +f742e4ff-909d-4fe9-aacb-3231d24a0c58_4CPRK-NM3K3-X6XXQ-RXX86-WX%f%CHW__98_X19-98877_vel4ytVtnE8FhvN87Cflz9sbh5QwHD1YGOeej9QP7hF3vlBR4EX2/S/09gRneeXVbQnjDOCd2KFMKRUWHLM7ZhFBk8AtlG+kvUawPZ+CIrwrD3mhi7NMv8UX/xkLK3HnBupMEuEwsMJgCUD8Pn6om1mEiQebHBAqu4cT7GN9Y0g_0_____Retail_CoreN +1d1bac85-7365-4fea-949a-96978ec91ae0_N2434-X9D7W-8PF6X-8DV9T-8T%f%YMD__99_X19-99652_Nv17eUTrr1TmUX6frlI7V69VR6yWb7alppCFJPcdjfI+xX4/Cf2np3zm7jmC+zxFb9nELUs477/ydw2KCCXFfM53bKpBQZKHE5+MdGJGxebOCcOtJ3hrkDJtwlVxTQmUgk5xnlmpk8PHg82M2uM5B7UsGLxGKK4d3hi0voSyKeI_0_____Retail_CoreCountrySpecific +3ae2cc14-ab2d-41f4-972f-5e20142771dc_BT79Q-G7N6G-PGBYW-4YWX6-6F%f%4BT_100_X19-99661_FV2Eao/R5v8sGrfQeOjQ4daokVlNOlqRCDZXuaC45bQd5PsNU3t1b4AwWeYM8TAwbHauzr4tPG0UlsUqUikCZHy0poROx35bBBMBym6Zbm9wDBVyi7nCzBtwS86eOonQ3cU6WfZxhZRze0POdR33G3QTNPrnVIM2gf6nZJYqDOA_0_____Retail_CoreSingleLanguage +2b1f36bb-c1cd-4306-bf5c-a0367c2d97d8_YTMG3-N6DKC-DKB77-7M9GH-8H%f%VX7_101_X19-98868_GH/jwFxIcdQhNxJIlFka8c1H48PF0y7TgJwaryAUzqSKXynONLw7MVciDJFVXTkCjbXSdxLSWpPIC50/xyy1rAf8aC7WuN/9cRNAvtFPC1IVAJaMeq1vf4mCqRrrxJQP6ZEcuAeHFzLe/LLovGWCd8rrs6BbBwJXCvAqXImvycQ_0_____Retail_Core +2a6137f3-75c0-4f26-8e3e-d83d802865a4_XKCNC-J26Q9-KFHD2-FKTHY-KD%f%72Y_119_X19-99606_hci78IRWDLBtdbnAIKLDgV9whYgtHc1uYyp9y6FszE9wZBD5Nc8CUD2pI2s2RRd3M04C4O7M3tisB3Ov/XVjpAbxlX3MWfUR5w4MH0AphbuQX0p5MuHEDYyfqlRgBBRzOKePF06qfYvPQMuEfDpKCKFwNojQxBV8O0Arf5zmrIw_0_OEM:NONSLP_PPIPro +e558417a-5123-4f6f-91e7-385c1c7ca9d4_YNMGQ-8RYV3-4PGQ3-C8XTP-7C%f%FBY_121_X19-98886_x9tPFDZmjZMf29zFeHV5SHbXj8Wd8YAcCn/0hbpLcId4D7OWqkQKXxXHIegRlwcWjtII0sZ6WYB0HQV2KH3LvYRnWKpJ5SxeOgdzBIJ6fhegYGGyiXsBv9sEb3/zidPU6ZK9LugVGAcRZ6HQOiXyOw+Yf5H35iM+2oDZXSpjvJw_0_____Retail_Education +c5198a66-e435-4432-89cf-ec777c9d0352_84NGF-MHBT6-FXBX8-QWJK7-DR%f%R8H_122_X19-98892_jkL4YZkmBCJtvL1fT30ZPBcjmzshBSxjwrE0Q00AZ1hYnhrH+npzo1MPCT6ZRHw19ZLTz7wzyBb0qqcBVbtEjZW0Xs2MYLxgriyoONkhnPE6KSUJBw7C0enFVLHEqnVu/nkaOFfockN3bc+Eouw6W2lmHjklPHc9c6Clo04jul0_0_____Retail_EducationN +f6e29426-a256-4316-88bf-cc5b0f95ec0c_PJB47-8PN2T-MCGDY-JTY3D-CB%f%CPV_125_X23-50331_OPGhsyx+Ctw7w/KLMRNrY+fNBmKPjUG0R9RqkWk4e8ez+ExSJxSLLex5WhO5QSNgXLmEra+cCsN6C638aLjIdH2/L7D+8z/C6EDgRvbHMmidHg1lX3/O8lv0JudHkGtHJYewjorn/xXGY++vOCTQdZNk6qzEgmYSvPehKfdg8js_1_Volume:MAK_EnterpriseS_Ge +cce9d2de-98ee-4ce2-8113-222620c64a27_KCNVH-YKWX8-GJJB9-H9FDT-6F%f%7W2_125_X22-66075_GCqWmJOsTVun9z4QkE9n2XqBvt3ZWSPl9QmIh9Q2mXMG/QVt2IE7S+ES/NWlyTSNjLVySr1D2sGjxgEzy9kLwn7VENQVJ736h1iOdMj/3rdqLMSpTa813+nPSQgKpqJ3uMuvIvRP0FdB7Y4qt8qf9kNKK25A1QknioD/6YubL/4_1_Volume:MAK_EnterpriseS_VB +d06934ee-5448-4fd1-964a-cd077618aa06_43TBQ-NH92J-XKTM7-KT3KK-P3%f%9PB_125_X21-83233_EpB6qOCo8pRgO5kL4vxEHck2J1vxyd9OqvxUenDnYO9AkcGWat/D74ZcFg5SFlIya1U8l5zv+tsvZ4wAvQ1IaFW1PwOKJLOaGgejqZ41TIMdFGGw+G+s1RHsEnrWr3UOakTodby1aIMUMoqf3NdaM5aWFo8fOmqWC5/LnCoighs_0_OEM:NONSLP_EnterpriseS_RS5 +706e0cfd-23f4-43bb-a9af-1a492b9f1302_NK96Y-D9CD8-W44CQ-R8YTK-DY%f%JWX_125_X21-05035_ntcKmazIvLpZOryft28gWBHu1nHSbR+Gp143f/BiVe+BD2UjHBZfSR1q405xmQZsygz6VRK6+zm8FPR++71pkmArgCLhodCQJ5I4m7rAJNw/YX99pILphi1yCRcvHsOTGa825GUVXgf530tHT6hr0HQ1lGeGgG1hPekpqqBbTlg_0_OEM:NONSLP_EnterpriseS_RS1 +faa57748-75c8-40a2-b851-71ce92aa8b45_FWN7H-PF93Q-4GGP8-M8RF3-MD%f%WWW_125_X19-99617_Fe9CDClilrAmwwT7Yhfx67GafWRQEpwyj8R+a4eaTqbpPcAt7d1hv1rx8Sa9AzopEGxIrb7IhiPoDZs0XaT1HN0/olJJ/MnD73CfBP4sdQdLTsSJE3dKMWYTQHpnjqRaS/pNBYRr8l9Mv8yfcP8uS2MjIQ1cRTqRmC7WMpShyCg_0_OEM:NONSLP_EnterpriseS_TH +3d1022d8-969f-4222-b54b-327f5a5af4c9_2DBW3-N2PJG-MVHW3-G7TDK-9H%f%KR4_126_X21-04921_zLPNvcl1iqOefy0VLg+WZgNtRNhuGpn8+BFKjMqjaNOSKiuDcR6GNDS5FF1Aqk6/e6shJ+ohKzuwrnmYq3iNQ3I2MBlYjM5kuNfKs8Vl9dCjSpQr//GBGps6HtF2xrG/2g/yhtYC7FbtGDIE16uOeNKFcVg+XMb0qHE/5Etyfd8_0_Volume:MAK_EnterpriseSN_RS1 +60c243e1-f90b-4a1b-ba89-387294948fb6_NTX6B-BRYC2-K6786-F6MVQ-M7%f%V2X_126_X19-98770_kbXfe0z9Vi1S0yfxMWzI5+UtWsJKzxs7wLGUDLjrckFDn1bDQb4MvvuCK1w+Qrq33lemiGpNDspa+ehXiYEeSPFcCvUBpoMlGBFfzurNCHWiv3o1k3jBoawJr/VoDoVZfxhkps0fVoubf9oy6C6AgrkZ7PjCaS58edMcaUWvYYg_0_Volume:MAK_EnterpriseSN_TH +01eb852c-424d-4060-94b8-c10d799d7364_3XP6D-CRND4-DRYM2-GM84D-4G%f%G8Y_139_X23-37869_PVW0XnRJnsWYjTqxb6StCi2tge/uUwegjdiFaFUiZpwdJ620RK+MIAsSq5S+egXXzIWNntoy2fB6BO8F1wBFmxP/mm/3rn5C33jtF5QrbNqY7X9HMbqSiC7zhs4v4u2Xa4oZQx8JQkwr8Q2c/NgHrOJKKRASsSckhunxZ+WVEuM_1_____Retail_ProfessionalCountrySpecific_Zn +eb6d346f-1c60-4643-b960-40ec31596c45_DXG7C-N36C4-C4HTG-X4T3X-2Y%f%V77_161_X21-43626_MaVqTkRrGnOqYizl15whCOKWzx01+BZTVAalvEuHXM+WV55jnIfhWmd/u1GqCd5OplqXdU959zmipK2Iwgu2nw/g91nW//sQiN/cUcvg1Lxo6pC3gAo1AjTpHmGIIf9XlZMYlD+Vl6gXsi/Auwh3yrSSFh5s7gOczZoDTqQwHXA_0_____Retail_ProfessionalWorkstation +89e87510-ba92-45f6-8329-3afa905e3e83_WYPNQ-8C467-V2W6J-TX4WX-WT%f%2RQ_162_X21-43644_JVGQowLiCcPtGY9ndbBDV+rTu/q5ljmQTwQWZgBIQsrAeQjLD8jLEk/qse7riZ7tMT6PKFVNXeWqF7PhLAmACbE8O3Lvp65XMd/Oml9Daynj5/4n7unsffFHIHH8TGyO5j7xb4dkFNqC5TX3P8/1gQEkTIdZEOTQQXFu0L2SP5c_0_____Retail_ProfessionalWorkstationN +62f0c100-9c53-4e02-b886-a3528ddfe7f6_8PTT6-RNW4C-6V7J2-C2D3X-MH%f%BPB_164_X21-04955_CEDgxI8f/fxMBiwmeXw5Of55DG32sbGALzHihXkdbYTDaE3pY37oAA4zwGHALzAFN/t254QImGPYR6hATgl+Cp804f7serJqiLeXY965Zy67I4CKIMBm49lzHLFJeDnVTjDB0wVyN29pvgO3+HLhZ22KYCpkRHFFMy2OKxS68Yc_0_____Retail_ProfessionalEducation +13a38698-4a49-4b9e-8e83-98fe51110953_GJTYN-HDMQY-FRR76-HVGC7-QP%f%F8P_165_X21-04956_r35zp9OfxKSBcTxKWon3zFtbOiCufAPo6xRGY5DJqCRFKdB0jgZalNQitvjmaZ/Rlez2vjRJnEart4LrvyW4d9rrukAjR3+c3UkeTKwoD3qBl9AdRJbXCa2BdsoXJs1WVS4w4LuVzpB/SZDuggZt0F2DlMB427F5aflook/n1pY_0_____Retail_ProfessionalEducationN +df96023b-dcd9-4be2-afa0-c6c871159ebe_NJCF7-PW8QT-3324D-688JX-2Y%f%V66_175_X21-41295_rVpetYUmiRB48YJfCvJHiaZapJ0bO8gQDRoql+rq5IobiSRu//efV1VXqVpBkwILQRKgKIVONSTUF5y2TSxlDLbDSPKp7UHfbz17g6vRKLwOameYEz0ZcK3NTbApN/cMljHvvF/mBag1+sHjWu+eoFzk8H89k9nw8LMeVOPJRDc_0_____Retail_ServerRdsh +d4ef7282-3d2c-4cf0-9976-8854e64a8d1e_V3WVW-N2PV2-CGWC3-34QGF-VM%f%J2C_178_X21-32983_Xzme9hDZR6H0Yx0deURVdE6LiTOkVqWng5W/OTbkxRc0rq+mSYpo/f/yqhtwYlrkBPWx16Yok5Bvcb34vbKHvEAtxfYp4te20uexLzVOtBcoeEozARv4W/6MhYfl+llZtR5efsktj4N4/G4sVbuGvZ9nzNfQO9TwV6NGgGEj2Ec_0_____Retail_Cloud +af5c9381-9240-417d-8d35-eb40cd03e484_NH9J3-68WK7-6FB93-4K3DF-DJ%f%4F6_179_X21-32987_QGRDZOU/VZhYLOSdp2xDnFs8HInNZctcQlWCIrORVnxTQr55IJwN4vK3PJHjkfRLQ/bgUrcEIhyFbANqZFUq8yD1YNubb2bjNORgI/m8u85O9V7nDGtxzO/viEBSWyEHnrzLKKWYqkRQKbbSW3ungaZR0Ti5O2mAUI4HzAFej50_0_____Retail_CloudN +8ab9bdd1-1f67-4997-82d9-8878520837d9_XQQYW-NFFMW-XJPBH-K8732-CK%f%FFD_188_X21-99378_djy0od0uuKd2rrIl+V1/2+MeRltNgW7FEeTNQsPMkVSL75NBphgoso4uS0JPv2D7Y1iEEvmVq6G842Kyt52QOwXgFWmP/IQ6Sq1dr+fHK/4Et7bEPrrGBEZoCfWqk0kdcZRPBij2KN6qCRWhrk1hX2g+U40smx/EYCLGh9HCi24_0_____OEM:DM_IoTEnterprise +ed655016-a9e8-4434-95d9-4345352c2552_QPM6N-7J2WJ-P88HH-P3YRH-YY%f%74H_191_X21-99682_qHs/PzfhYWdtSys2edzcz4h+Qs8aDqb8BIiQ/mJ/+0uyoJh1fitbRCIgiFh2WAGZXjdgB8hZeheNwHibd8ChXaXg4u+0XlOdFlaDTgTXblji8fjETzDBk9aGkeMCvyVXRuUYhTSdp83IqGHz7XuLwN2p/6AUArx9JZCoLGV8j3w_0_OEM:NONSLP_IoTEnterpriseS_VB +6c4de1b8-24bb-4c17-9a77-7b939414c298_CGK42-GYN6Y-VD22B-BX98W-J8%f%JXD_191_X23-12617_J/fpIRynsVQXbp4qZNKp6RvOgZ/P2klILUKQguMlcwrBZybwNkHg/kM5LNOF/aDzEktbPnLnX40GEvKkYT6/qP4cMhn/SOY0/hYOkIdR34ilzNlVNq5xP7CMjCjaUYJe+6ydHPK6FpOuEoWOYYP5BZENKNGyBy4w4shkMAw19mA_0_OEM:NONSLP_IoTEnterpriseS_Ge +d4bdc678-0a4b-4a32-a5b3-aaa24c3b0f24_K9VKN-3BGWV-Y624W-MCRMQ-BH%f%DCD_202_X22-53884_kyoNx2s93U6OUSklB1xn+GXcwCJO1QTEtACYnChi8aXSoxGQ6H2xHfUdHVCwUA1OR0UeNcRrMmOzZBOEUBtdoGWSYPg9AMjvxlxq9JOzYAH+G6lT0UbCWgMSGGrqdcIfmshyEak3aUmsZK6l+uIAFCCZZ/HbbCRkkHC5rWKstMI_0_____Retail_CloudEditionN +92fb8726-92a8-4ffc-94ce-f82e07444653_KY7PN-VR6RX-83W6Y-6DDYQ-T6%f%R4W_203_X22-53847_gD6HnT4jP4rcNu9u83gvDiQq1xs7QSujcDbo60Di5iSVa9/ihZ7nlhnA0eDEZfnoDXriRiPPqc09T6AhSnFxLYitAkOuPJqL5UMobIrab9dwTKlowqFolxoHhLOO4V92Hsvn/9JLy7rEzoiAWHhX/0cpMr3FCzVYPeUW1OyLT1A_0_____Retail_CloudEdition +5a85300a-bfce-474f-ac07-a30983e3fb90_N979K-XWD77-YW3GB-HBGH6-D3%f%2MH_205_X23-15042_blZopkUuayCTgZKH4bOFiisH9GTAHG5/js6UX/qcMWWc3sWNxKSX1OLp1k3h8Xx1cFuvfG/fNAw/I83ssEtPY+A0Gx1JF4QpRqsGOqJ5ruQ2tGW56CJcCVHkB+i46nJAD759gYmy3pEYMQbmpWbhLx3MJ6kvwxKfU+0VCio8k50_0_____OEM:DM_IoTEnterpriseSK +80083eae-7031-4394-9e88-4901973d56fe_P8Q7T-WNK7X-PMFXY-VXHBG-RR%f%K69_206_X23-62084_habUJ0hhAG0P8iIKaRQ74/wZQHyAdFlwHmrejNjOSRG08JeqilJlTM6V8G9UERLJ92/uMDVHIVOPXfN8Zdh8JuYO8oflPnqymIRmff/pU+Gpb871jV2JDA4Cft5gmn+ictKoN4VoSfEZRR+R5hzF2FsoCExDNNw6gLdjtiX94uA_0_____OEM:DM_IoTEnterpriseK ) do ( for /f "tokens=1-9 delims=_" %%A in ("%%#") do ( @@ -2354,7 +2075,7 @@ REM Detect key if %1==key if %osSKU%==%%C if not defined key ( echo "!allapps! !altapplist!" | find /i "%%A" %nul1% && ( -if %%E==1 set notworking=1 +if %%F==1 set notworking=1 set key=%%B ) ) @@ -2362,8 +2083,11 @@ set key=%%B REM Generate ticket if %1==ticket if "%key%"=="%%B" ( -set "SessionIdStr=OSMajorVersion=5;OSMinorVersion=1;OSPlatformId=2;PP=0;Pfn=Microsoft.Windows.%%C.%%D_8wekyb3d8bbwe;PKeyIID=465145217131314304264339481117862266242033457260311819664735280;" -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':sign\:.*';. ([scriptblock]::Create($f[1]))" +set "string=OSMajorVersion=5;OSMinorVersion=1;OSPlatformId=2;PP=0;Pfn=Microsoft.Windows.%%C.%%D_8wekyb3d8bbwe;PKeyIID=465145217131314304264339481117862266242033457260311819664735280;$([char]0)" +for /f "tokens=* delims=" %%i in ('%psc% [conv%f%ert]::ToBas%f%e64String([Text.En%f%coding]::Uni%f%code.GetBytes("""!string!"""^)^)') do set "encoded=%%i" +echo "!encoded!" | find "AAAA" %nul1% || exit /b + +1.0OA3xOriginalProductId=;OA3xOriginalProductKey=;SessionId=!encoded!;TimeStampClient=2022-10-11T12:00:00Z%%E=" >"%tdir%\GenuineTicket" ) ) @@ -2372,77 +2096,6 @@ exit /b ::======================================================================================================================================== -:sign: -$ErrorActionPreference = "Stop" - -function SignProperties { - param ( - $Properties, - $rsa - ) - - $sha256 = [Security.Cryptography.SHA256]::Create() - $bytes = [Text.Encoding]::UTF8.GetBytes($Properties) - $hash = $sha256.ComputeHash($bytes) - - $signature = $rsa.SignHash($hash, [Security.Cryptography.HashAlgorithmName]::SHA256, [Security.Cryptography.RSASignaturePadding]::Pkcs1) - return [Convert]::ToBase64String($signature) - -} - -[byte[]] $key = 0x07,0x02,0x00,0x00,0x00,0xA4,0x00,0x00,0x52,0x53,0x41,0x32,0x00,0x04,0x00,0x00, - 0x01,0x00,0x01,0x00,0x29,0x87,0xBA,0x3F,0x52,0x90,0x57,0xD8,0x12,0x26,0x6B,0x38, - 0xB2,0x3B,0xF9,0x67,0x08,0x4F,0xDD,0x8B,0xF5,0xE3,0x11,0xB8,0x61,0x3A,0x33,0x42, - 0x51,0x65,0x05,0x86,0x1E,0x00,0x41,0xDE,0xC5,0xDD,0x44,0x60,0x56,0x3D,0x14,0x39, - 0xB7,0x43,0x65,0xE9,0xF7,0x2B,0xA5,0xF0,0xA3,0x65,0x68,0xE9,0xE4,0x8B,0x5C,0x03, - 0x2D,0x36,0xFE,0x28,0x4C,0xD1,0x3C,0x3D,0xC1,0x90,0x75,0xF9,0x6E,0x02,0xE0,0x58, - 0x97,0x6A,0xCA,0x80,0x02,0x42,0x3F,0x6C,0x15,0x85,0x4D,0x83,0x23,0x6A,0x95,0x9E, - 0x38,0x52,0x59,0x38,0x6A,0x99,0xF0,0xB5,0xCD,0x53,0x7E,0x08,0x7C,0xB5,0x51,0xD3, - 0x8F,0xA3,0x0D,0xA0,0xFA,0x8D,0x87,0x3C,0xFC,0x59,0x21,0xD8,0x2E,0xD9,0x97,0x8B, - 0x40,0x60,0xB1,0xD7,0x2B,0x0A,0x6E,0x60,0xB5,0x50,0xCC,0x3C,0xB1,0x57,0xE4,0xB7, - 0xDC,0x5A,0x4D,0xE1,0x5C,0xE0,0x94,0x4C,0x5E,0x28,0xFF,0xFA,0x80,0x6A,0x13,0x53, - 0x52,0xDB,0xF3,0x04,0x92,0x43,0x38,0xB9,0x1B,0xD9,0x85,0x54,0x7B,0x14,0xC7,0x89, - 0x16,0x8A,0x4B,0x82,0xA1,0x08,0x02,0x99,0x23,0x48,0xDD,0x75,0x9C,0xC8,0xC1,0xCE, - 0xB0,0xD7,0x1B,0xD8,0xFB,0x2D,0xA7,0x2E,0x47,0xA7,0x18,0x4B,0xF6,0x29,0x69,0x44, - 0x30,0x33,0xBA,0xA7,0x1F,0xCE,0x96,0x9E,0x40,0xE1,0x43,0xF0,0xE0,0x0D,0x0A,0x32, - 0xB4,0xEE,0xA1,0xC3,0x5E,0x9B,0xC7,0x7F,0xF5,0x9D,0xD8,0xF2,0x0F,0xD9,0x8F,0xAD, - 0x75,0x0A,0x00,0xD5,0x25,0x43,0xF7,0xAE,0x51,0x7F,0xB7,0xDE,0xB7,0xAD,0xFB,0xCE, - 0x83,0xE1,0x81,0xFF,0xDD,0xA2,0x77,0xFE,0xEB,0x27,0x1F,0x10,0xFA,0x82,0x37,0xF4, - 0x7E,0xCC,0xE2,0xA1,0x58,0xC8,0xAF,0x1D,0x1A,0x81,0x31,0x6E,0xF4,0x8B,0x63,0x34, - 0xF3,0x05,0x0F,0xE1,0xCC,0x15,0xDC,0xA4,0x28,0x7A,0x9E,0xEB,0x62,0xD8,0xD8,0x8C, - 0x85,0xD7,0x07,0x87,0x90,0x2F,0xF7,0x1C,0x56,0x85,0x2F,0xEF,0x32,0x37,0x07,0xAB, - 0xB0,0xE6,0xB5,0x02,0x19,0x35,0xAF,0xDB,0xD4,0xA2,0x9C,0x36,0x80,0xC6,0xDC,0x82, - 0x08,0xE0,0xC0,0x5F,0x3C,0x59,0xAA,0x4E,0x26,0x03,0x29,0xB3,0x62,0x58,0x41,0x59, - 0x3A,0x37,0x43,0x35,0xE3,0x9F,0x34,0xE2,0xA1,0x04,0x97,0x12,0x9D,0x8C,0xAD,0xF7, - 0xFB,0x8C,0xA1,0xA2,0xE9,0xE4,0xEF,0xD9,0xC5,0xE5,0xDF,0x0E,0xBF,0x4A,0xE0,0x7A, - 0x1E,0x10,0x50,0x58,0x63,0x51,0xE1,0xD4,0xFE,0x57,0xB0,0x9E,0xD7,0xDA,0x8C,0xED, - 0x7D,0x82,0xAC,0x2F,0x25,0x58,0x0A,0x58,0xE6,0xA4,0xF4,0x57,0x4B,0xA4,0x1B,0x65, - 0xB9,0x4A,0x87,0x46,0xEB,0x8C,0x0F,0x9A,0x48,0x90,0xF9,0x9F,0x76,0x69,0x03,0x72, - 0x77,0xEC,0xC1,0x42,0x4C,0x87,0xDB,0x0B,0x3C,0xD4,0x74,0xEF,0xE5,0x34,0xE0,0x32, - 0x45,0xB0,0xF8,0xAB,0xD5,0x26,0x21,0xD7,0xD2,0x98,0x54,0x8F,0x64,0x88,0x20,0x2B, - 0x14,0xE3,0x82,0xD5,0x2A,0x4B,0x8F,0x4E,0x35,0x20,0x82,0x7E,0x1B,0xFE,0xFA,0x2C, - 0x79,0x6C,0x6E,0x66,0x94,0xBB,0x0A,0xEB,0xBA,0xD9,0x70,0x61,0xE9,0x47,0xB5,0x82, - 0xFC,0x18,0x3C,0x66,0x3A,0x09,0x2E,0x1F,0x61,0x74,0xCA,0xCB,0xF6,0x7A,0x52,0x37, - 0x1D,0xAC,0x8D,0x63,0x69,0x84,0x8E,0xC7,0x70,0x59,0xDD,0x2D,0x91,0x1E,0xF7,0xB1, - 0x56,0xED,0x7A,0x06,0x9D,0x5B,0x33,0x15,0xDD,0x31,0xD0,0xE6,0x16,0x07,0x9B,0xA5, - 0x94,0x06,0x7D,0xC1,0xE9,0xD6,0xC8,0xAF,0xB4,0x1E,0x2D,0x88,0x06,0xA7,0x63,0xB8, - 0xCF,0xC8,0xA2,0x6E,0x84,0xB3,0x8D,0xE5,0x47,0xE6,0x13,0x63,0x8E,0xD1,0x7F,0xD4, - 0x81,0x44,0x38,0xBF - -$rsa = New-Object Security.Cryptography.RSACryptoServiceProvider -$rsa.ImportCspBlob($key) -$SessionId = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($env:SessionIdStr + [char]0)) -$PropertiesStr = "OA3xOriginalProductId=;OA3xOriginalProductKey=;SessionId=$SessionId;TimeStampClient=2022-10-11T12:00:00Z" -$SignatureStr = SignProperties $PropertiesStr $rsa - -$xml = @" -1.0$PropertiesStr$SignatureStr -"@ -[System.IO.File]::WriteAllText("$env:ProgramData\Microsoft\Windows\ClipSVC\GenuineTicket\GenuineTicket", ($xml -join ""), [System.Text.Encoding]::ASCII) -:sign: - -::======================================================================================================================================== - :: Below code is used to get alternate edition name and key if current edition doesn't support HWID activation :: 1st column = Current SKU ID @@ -2576,8 +2229,8 @@ 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%in-place_repair_upgrade -call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) goto dk_done ) @@ -2676,7 +2329,7 @@ call :dk_color %Red% "Checking Installed Office [Not Found]" if defined ohub ( echo: -echo You only have the Office Dashboard app installed. You need to install the full version of Office. +echo You only have the Office dashboard app installed, you need to install the full version of Office. ) echo: call :dk_color %Blue% "Download and install Office from the below URL and then try again." @@ -2751,7 +2404,6 @@ set error=1 goto :starto16c2r ) -call :oh_expiredpreview 2013 call :oh_fixprids call :oh_process if defined isOspp ( @@ -2809,7 +2461,6 @@ set error=1 goto :startmsi ) -call :oh_expiredpreview 2016 2019 2021 2024 call :oh_fixprids call :oh_process if defined isOspp ( @@ -2820,19 +2471,19 @@ call :oh_hookinstall ::======================================================================================================================================== -:: Old version of Office with subscription license key may show a banner to sign in to fix license issue. +:: Old version (16.0.9xxxx and below) of Office with subscription license key may show a banner to sign in to fix license issue. :: Although script applies a Resiliency registry entry to fix that but it doesn't work on old office versions. :: Below code checks that condition and informs the user to update the Office. if defined _sublic ( -if not exist "%_oLPath%\Word2021VL_KMS_Client_AE*.xrm-ms" ( +if not exist "%_oLPath%\Word2019VL_KMS_Client_AE*.xrm-ms" ( call :dk_color %Gray% "Checking Old Office With Sub License [Found. Update Office, otherwise, it may show a licensing issue-related banner.]" ) ) ::======================================================================================================================================== -:: mass{}grave{dot}dev/office-license-is-not-genuine +:: mass grave[.]dev/office-license-is-not-genuine :: Add registry keys for volume products so that 'non-genuine' banner won't appear :: Script already is using MAK instead of GVLK so it won't appear anyway, but registry keys are added incase Office installs default GVLK grace key for volume products @@ -2874,7 +2525,7 @@ if defined ohub call :dk_color %Gray% "Office apps such as Word, Excel are activ echo Help: %mas%troubleshoot ) else ( call :dk_color %Red% "Some errors were detected." -if not defined ierror if not defined showfix call :dk_color %Blue% "%_fixmsg%" +if not defined ierror if not defined showfix if not defined serv_cor if not defined serv_cste call :dk_color %Blue% "%_fixmsg%" echo: set fixes=%fixes% %mas%troubleshoot call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" @@ -3069,28 +2720,6 @@ exit /b ::======================================================================================================================================== -:oh_expiredpreview - -echo %_oIds% | find /i "Volume" %nul% || exit /b - -for %%# in (%*) do ( -if %%#==2013 set _offver= -if %%#==2016 set _offver= -if %%#==2019 set _offver=2019 -if %%#==2021 set _offver=2021 -if %%#==2024 set _offver=2024 -if exist "!_oLPath!\ProPlus!_offver!PreviewVL_*.xrm-ms" if not exist "!_oLPath!\ProPlus!_offver!VL_*.xrm-ms" ( -set error=1 -set showfix=1 -call :dk_color %Red% "Checking Expired Preview Products [Office %%# Preview Found]" -call :dk_color %Blue% "Please run the Office updates first, and then attempt to activate it again." -) -) - -exit /b - -::======================================================================================================================================== - :oh_ppcpath if not defined isOspp ( @@ -3205,7 +2834,7 @@ for %%# in ("!_oLPath!\%_License%*.xrm-ms") do ( if defined _arr (set "_arr=!_arr!;"!_oLPath!\%%~nx#"") else (set "_arr="!_oLPath!\%%~nx#"") ) -%psc% "$sls = Get-WmiObject %sps%; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_oLPath!\pkeyconfig-office.xrm-ms"'" %nul% +%psc% "$sls = Get-WmiObject %sps%; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_oLPath!\pkeyconfig-office.xrm-ms"'" %nul% call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 echo "!allapps!" | find /i "!_actid!" %nul1% || ( @@ -3527,7 +3156,7 @@ exit /b :oh_clearblock :: Find remnants of Office vNext/shared/device license block and remove it because it stops other licenses from appearing -:: https://learn.microsoft.com/en-us/office/troubleshoot/activation/reset-office-365-proplus-activation-state +:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state set _sidlist= for /f "tokens=* delims=" %%a in ('%psc% "$p = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'; Get-ChildItem $p | ForEach-Object { $pi = (Get-ItemProperty """"$p\$($_.PSChildName)"""").ProfileImagePath; if ($pi -like '*\Users\*' -and (Test-Path """"$pi\NTUSER.DAT"""") -and -not ($_.PSChildName -match '\.bak$')) { Split-Path $_.PSPath -Leaf } }" %nul6%') do (if defined _sidlist (set _sidlist=!_sidlist! %%a) else (set _sidlist=%%a)) @@ -3579,12 +3208,10 @@ call :dk_color %Gray% "Checking Total User Accounts [%counter%]" :: Clear the vNext/shared/device license blocks which may prevent ohook activation -set vnextexist= rmdir /s /q "%ProgramData%\Microsoft\Office\Licenses\" %nul% for %%x in (15 16) do ( for %%# in (%_sidlist%) do ( -reg query HKU\%%#\Software\Microsoft\Office\%%x.0\Common\Licensing /s %nul2% | findstr /i "CIDToLicenseIdsMapping LicenseIdToEmailMapping @" %nul% && set vnextexist=1 reg delete HKU\%%#\Software\Microsoft\Office\%%x.0\Common\Licensing /f %nul% for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do ( @@ -3607,7 +3234,6 @@ rmdir /s /q "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\L if exist "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\SystemAppData\Helium\User.dat" ( set defname=DEFTEMP-%%# reg load HKU\!defname! "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\SystemAppData\Helium\User.dat" %nul% -reg query HKU\!defname!\Software\Microsoft\Office\16.0\Common\Licensing /s %nul2% | findstr /i "CIDToLicenseIdsMapping LicenseIdToEmailMapping @" %nul% && set vnextexist=1 reg delete HKU\!defname!\Software\Microsoft\Office\16.0\Common\Licensing /f %nul% reg unload HKU\!defname! %nul% ) @@ -3615,15 +3241,6 @@ reg unload HKU\!defname! %nul% ) ) -if defined vnextexist ( -echo: -call :dk_color %Gray% "The logged-in Office account has a subscription license." -call :dk_color %Blue% "If the subscription is active, it overrides other activation methods." -call :dk_color %Blue% "If it is expiring soon, rerun the activation script after it expires." -call :dk_color2 %Blue% "If it has already expired and activation fails, get help here - " %_Yellow% " %mas%troubleshoot" -echo: -) - :: Clear SharedComputerLicensing for office :: https://learn.microsoft.com/en-us/deployoffice/overview-shared-computer-activation @@ -3635,12 +3252,12 @@ reg delete HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration /v Share ) :: Clear device-based-licensing -:: https://learn.microsoft.com/en-us/deployoffice/device-based-licensing +:: https://learn.microsoft.com/deployoffice/device-based-licensing for /f %%# in ('reg query "%o16c2r_reg%\Configuration" /f *.DeviceBasedLicensing %nul6% ^| findstr REG_') do reg delete "%o16c2r_reg%\Configuration" /v %%# /f %nul% :: Remove OEM registry key -:: https://support.microsoft.com/en-us/office/office-repeatedly-prompts-you-to-activate-on-a-new-pc-a9a6b05f-f6ce-4d1f-8d49-eb5007b64ba1 +:: https://support.microsoft.com/office/office-repeatedly-prompts-you-to-activate-on-a-new-pc-a9a6b05f-f6ce-4d1f-8d49-eb5007b64ba1 for %%# in (15 16) do ( reg delete "HKLM\SOFTWARE\Microsoft\Office\%%#.0\Common\OEM" /f %nul% @@ -3718,15 +3335,7 @@ set upk_result=2 if defined ohookact if not %upk_result%==0 echo: if %upk_result%==1 echo Uninstalling Other/Grace Keys [Successful] -if %upk_result%==2 ( -call :dk_color %Red% "Uninstalling Other/Grace Keys [Failed]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -set showfix=1 -) -) +if %upk_result%==2 call :dk_color %Red% "Uninstalling Other/Grace Keys [Failed]" exit /b ::======================================================================================================================================== @@ -3737,8 +3346,8 @@ exit /b :oh_licrefresh if exist "%SysPath%\spp\store_test\2.0\tokens.dat" ( -%psc% "Stop-Service sppsvc -force; $sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if !errorlevel! NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($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% ) exit /b @@ -3790,6 +3399,7 @@ exit /b 14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_Retail________ExcelR_[HSExcelR] 14_7004b7f0-6407-4f45-8eac-966e5f868bde_Retail________GrooveR +14_fbf4ac36-31c8-4340-8666-79873129cf40_Retail________OutlookR 14_133c8359-4e93-4241-8118-30bb18737ea0_Retail________PowerPointR_[HSPowerPointR] 14_db3bbc9c-ce52-41d1-a46f-1a1d68059119_Retail________WordR_[HSWordR] 14_dbe3aee0-5183-4ff7-8142-66050173cb01_Retail________SmallBusBasicsR_[SmallBusBasicsMSDNR] @@ -3818,7 +3428,6 @@ for %%# in ( 14_85e22450-b741-430c-a172-a37962c938af_6GKT2-KMJPK-4RRBF-8VQKB-JB%f%6G6_MAK___________InfoPathVL 14_3f7aa693-9a7e-44fc-9309-bb3d8e604925_2TG3P-9DB76-4YT99-8RXGD-CW%f%XBP_Retail________OneNoteR_[HSOneNoteR] 14_6860b31f-6a67-48b8-84b9-e312b3485c4b_CV64P-F4VRH-BJ33D-PH6MR-X6%f%9RY_MAK___________OneNoteVL -14_fbf4ac36-31c8-4340-8666-79873129cf40_9D8FR-7GYBW-4YG8M-V36JK-VD%f%7CM_Retail________OutlookR 14_a9aeabd8-63b8-4079-a28e-f531807fd6b8_J8C9M-YXMH2-9CX44-2C3YG-V7%f%692_MAK___________OutlookVL 14_acb51361-c0db-4895-9497-1831c41f31a6_GMBWM-WVX26-7WHV4-DB43D-WV%f%DY2_Retail________PersonalR_[PersonalDemoR,PersonalPrepaidR] 14_38252940-718c-4aa6-81a4-135398e53851_HPBQP-RJHDR-Q3472-PT9Q6-PB%f%B72_MAK___________PowerPointVL @@ -4074,7 +3683,7 @@ exit /b :oh_extractdll set b= -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':%_hook%\:.*';$encoded = ($f[1]) -replace '-', 'A' -replace '_', 'a';$bytes = [Con%b%vert]::FromBas%b%e64String($encoded); $PePath='%1'; $offset='%2'; $m=[System.IO.File]::ReadAllText('!_batp!') -split ':hexedit\:.*';. ([scriptblock]::Create($m[1]))" %nul2% | find /i "Error found" %nul1% && set hasherror=1 +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':%_hook%\:.*';$encoded = ($f[1]) -replace '-', 'A' -replace '_', 'a';$bytes = [Con%b%vert]::FromBas%b%e64String($encoded); $PePath='%1'; $offset='%2'; $m=[io.file]::ReadAllText('!_batp!') -split ':hexedit\:.*';iex ($m[1])" %nul2% | find /i "Error found" %nul1% && set hasherror=1 exit /b :hexedit: @@ -4157,13 +3766,13 @@ $MemoryStream.Close() :: :: The files are encoded in base64 to make AIO version. :: -:: mass{}grave{dot}dev/ohook +:: mass grave[.]dev/ohook :: Here you can find the files source code and info on how to rebuild the identical sppc.dll files :: :: stackoverflow.com/a/35335273 :: Here you can check how to extract sppc.dll files from base64 :: -:: For any further question, feel free to contact us on mass{}grave{dot}dev/contactus +:: For any further question, feel free to contact us on mass grave[.]dev/contactus :: ::======================================================================================================================================== :: @@ -4348,11 +3957,6 @@ set tsids= :: To reset rearm counter, evaluation period and clear the tamper state, key lock, run the script with "/Z-Reset" parameter or change 0 to 1 in below line set _resall=0 -:: Choose activation method: -:: In builds 26100 and later, the script will auto select StaticCID (requires internet). If no internet is detected, it will then auto select the KMS4k method. For builds lower than 26100, the script will auto select ZeroCID. -:: To change the activation method, run the script with the parameters "/Z-SCID", "/Z-ZCID", or "/Z-KMS4k", or modify the option from Auto to SCID, ZCID, or KMS4k in the line below. -set _actmethod=Auto - :: Debug Mode: :: To run the script in debug mode, change 0 to any parameter above that you want to run, in below line set "_debug=0" @@ -4387,14 +3991,10 @@ if /i "%%A"=="/Z-OffHost" (set _actoffhost=1) if /i "%%A"=="/Z-APPX" (set _actappx=1) echo "%%A" | find /i "/Z-ID-" >nul && (set _actman=1& set "filtsids=%%A" & call set "filtsids=%%filtsids:~6%%" & if defined filtsids call set tsids=%%filtsids%% %%tsids%%) if /i "%%A"=="/Z-Reset" (set _resall=1) -if /i "%%A"=="/Z-SCID" (set _actmethod=SCID) -if /i "%%A"=="/Z-ZCID" (set _actmethod=ZCID) -if /i "%%A"=="/Z-KMS4k" (set _actmethod=KMS4k) ) if not defined tsids set _actman=0 for %%A in (%_actwin% %_actesu% %_actoff% %_actprojvis% %_actwinesuoff% %_actwinhost% %_actoffhost% %_actappx% %_actman% %_resall%) do (if "%%A"=="1" set _unattended=1) -if /i not %_actmethod%==Auto set _unattended=1 if %winbuild% LSS 7600 ( reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" /v Install %nul2% | find /i "0x1" %nul1% || ( @@ -4402,8 +4002,8 @@ reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" /v Install %nul echo .NET 3.5 Framework is not installed in your system. echo Install it using the following URL. echo: -echo https://www.microsoft.com/en-us/download/details.aspx?id=25150 -if %_unattended%==0 start https://www.microsoft.com/en-us/download/details.aspx?id=25150 +echo https://www.microsoft.com/download/details.aspx?id=25150 +if %_unattended%==0 start https://www.microsoft.com/download/details.aspx?id=25150 goto dk_done ) ) @@ -4440,7 +4040,6 @@ echo [E] Reset - Rearm/Timers ) else ( echo [E] Reset - Rearm/Timers/Tamper/Lock ) -echo [F] Change - Activation Method [%_actmethod%] echo _______________________________________________ echo: echo [6] Remove TSforge Activation @@ -4449,13 +4048,12 @@ echo [0] %_exitmsg% echo ______________________________________________________________ echo: call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard..." -choice /C:12345ABCDEF670 /N +choice /C:12345ABCDE670 /N set _el=!errorlevel! -if !_el!==14 exit /b -if !_el!==13 start %mas%genuine-installation-media & goto :ts_menu -if !_el!==12 call :ts_remove & cls & goto :ts_menu -if !_el!==11 goto :ts_changemethod +if !_el!==13 exit /b +if !_el!==12 start %mas%genuine-installation-media & goto :ts_menu +if !_el!==11 call :ts_remove & cls & goto :ts_menu if !_el!==10 cls & setlocal & set "_resall=1" & call :ts_start & endlocal & cls & goto :ts_menu if !_el!==9 cls & setlocal & set "_actman=1" & call :ts_start & endlocal & cls & goto :ts_menu if !_el!==8 cls & setlocal & set "_actappx=1" & call :ts_start & endlocal & cls & goto :ts_menu @@ -4469,56 +4067,6 @@ if !_el!==1 cls & setlocal & set "_actwin=1" & call :ts_start & endlocal goto :ts_menu ) -goto :ts_start - -::======================================================================================================================================== - -:ts_changemethod - -cls -if not defined terminal mode 76, 36 - -echo: -echo: -echo: -echo ______________________________________________________________ -echo: -call :dk_color2 %_White% " [1] " %_Green% "Auto" -echo Builds ^>= 26100 - StaticCID (KMS4k if offline) -echo Builds ^< 26100 - ZeroCID -echo __________________________________________________ -echo: -echo [2] StaticCID -echo Needs Internet -echo Not for Windows 7 or older -echo __________________________________________________ -echo: -echo [3] ZeroCID -echo Works reliably on builds below 26100 -echo Does not work on builds above 26100.4188 -echo __________________________________________________ -echo: -echo [4] KMS4k -echo Volume licenses only -echo Activates for 4000+ years -echo __________________________________________________ -echo: -echo [5] Learn More -echo [0] %_exitmsg% -echo ______________________________________________________________ -echo: -call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard..." -choice /C:123450 /N -set _el=!errorlevel! - -if !_el!==6 goto :ts_menu -if !_el!==5 cls & start %mas%tsforge &goto :ts_menu -if !_el!==4 cls & set "_actmethod=KMS4k" & goto :ts_menu -if !_el!==3 cls & set "_actmethod=ZCID" & goto :ts_menu -if !_el!==2 cls & set "_actmethod=SCID" & goto :ts_menu -if !_el!==1 cls & set "_actmethod=Auto" & goto :ts_menu -goto :ts_changemethod - ::======================================================================================================================================== :ts_start @@ -4545,8 +4093,8 @@ 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%in-place_repair_upgrade -call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) goto dk_done ) @@ -4601,57 +4149,6 @@ cls echo: call :dk_showosinfo -if /i %_actmethod%==SCID set tsmethod=StaticCID -if /i %_actmethod%==ZCID set tsmethod=ZeroCID -if /i %_actmethod%==KMS4k set tsmethod=KMS4k - -if /i %_actmethod%==Auto ( -if %winbuild% GEQ 26100 ( -set tsmethod=StaticCID -) else ( -set tsmethod=ZeroCID -) -) - -if %winbuild% LSS 9200 if /i %tsmethod%==StaticCID ( -%eline% -echo StaticCID method is supported only on Windows 8 and later. -goto dk_done -) - -::======================================================================================================================================== - -:: Check Internet connection - -if /i %tsmethod%==StaticCID ( -set _int= -for %%a in (l.root-servers.net resolver1.opendns.com download.windowsupdate.com google.com) do if not defined _int ( -for /f "delims=[] tokens=2" %%# in ('ping -n 1 %%a') do (if not "%%#"=="" set _int=1) -) - -if not defined _int ( -%psc% "If([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet){Exit 0}Else{Exit 1}" -if !errorlevel!==0 (set _int=1&set ping_f= But Ping Failed) -) - -if defined _int ( -echo Checking Internet Connection [Connected!ping_f!] -) else ( -if /i %_actmethod%==Auto if not %_actman%==1 set tsmethod=KMS4k -if /i !tsmethod!==KMS4k ( -call :dk_color %Red% "Checking Internet Connection [Not Connected]" -call :dk_color %Blue% "Switching To KMS4k activation because Internet is needed for StaticCID method." -) else ( -set error=1 -call :dk_color %Red% "Checking Internet Connection [Not Connected]" -call :dk_color %Blue% "Internet is required for TSforge StaticCID option." -) -echo: -) -) - -::======================================================================================================================================== - echo Initiating Diagnostic Tests... set "_serv=%_slser% Winmgmt" @@ -4669,11 +4166,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto :dk_done ) -if /i !tsmethod!==KMS4k ( -call :_taskclear-cache -echo Clearing %KS% Cache [Successful] -) - ::======================================================================================================================================== if %_resall%==1 goto :ts_resetall @@ -4695,24 +4187,17 @@ echo %tsedition% | find /i "Eval" %nul1% && ( goto :ts_wineval ) -set /a UBR=0 -if %winbuild% EQU 26100 ( -for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR %nul6%') do if not errorlevel 1 set /a UBR=%%b -if !UBR! LSS 4188 (set dontcheckact=1) -) - -if not defined dontcheckact call :ts_checkwinperm +call :ts_checkwinperm if defined _perm ( call :dk_color %Gray% "Checking OS Activation [Windows is already permanently activated]" goto :ts_esu ) -if %winbuild% LSS 9200 if /i %tsmethod%==KMS4k goto :ts_oldks if defined _vis goto :ts_winvista set tempid= -if /i %tsmethod%==KMS4k (set keytype=ks) else (set keytype=zero) -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wintsid\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do ( +set keytype=zero +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wintsid\:.*';iex ($f[1])" %nul6%') do ( echo "%%a" | findstr /r ".*-.*-.*-.*-.*" %nul1% && (set tsids=!tsids! %%a& set tempid=%%a) ) @@ -4721,13 +4206,6 @@ echo Checking Activation ID [%tempid%] [%tsedition%] ) else ( call :dk_color %Red% "Checking Activation ID [Not Found] [%tsedition%] [%osSKU%]" set error=1 -if /i %tsmethod%==KMS4k ( -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -) goto :ts_esu ) @@ -4735,83 +4213,6 @@ if defined winsub ( call :dk_color %Blue% "Windows Subscription [SKU ID-%slcSKU%] found. Script will activate base edition [SKU ID-%regSKU%]." echo: ) - -goto :ts_esu - -::======================================================================================================================================== - -:ts_oldks - -:: KMS keys for KMS4k method because TSforge cannot install KMS key on Windows Vista and 7 - -:: 1st column = Activation ID -:: 2nd column = Generic key -:: 3rd column = Edition ID -:: Separator = _ - -set f= -set key= -set tempid= -if not defined allapps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -for %%# in ( -:: Windows 7 -ae2ee509-1b34-41c0-acb7-6d4650168915_33PXH-7Y6KF-2VJC9-XBBR8-HV%f%THH_Enterprise -1cb6d605-11b3-4e14-bb30-da91c8e3983a_YDRBP-3D83W-TY26F-D46B2-XC%f%KRJ_EnterpriseN -b92e9980-b9d5-4821-9c94-140f632f6312_FJ82H-XT6CR-J8D7P-XQJJ2-GP%f%DD4_Professional -54a09a0d-d57b-4c10-8b69-a842d6590ad5_MRPKT-YTG23-K7D7T-X2JMM-QY%f%7MG_ProfessionalN -db537896-376f-48ae-a492-53d0547773d0_YBYF6-BHCR3-JPKRB-CDW7B-F9%f%BK4_Embedded_POSReady -aa6dd3aa-c2b4-40e2-a544-a6bbb3f5c395_73KQT-CD9G6-K7TQG-66MRP-CQ%f%22C_Embedded_ThinPC -5a041529-fef8-4d07-b06f-b59b573b32d2_W82YF-2Q76Y-63HXB-FGJG9-GF%f%7QX_ProfessionalE -46bbed08-9c7b-48fc-a614-95250573f4ea_C29WB-22CC8-VJ326-GHFJW-H9%f%DH4_EnterpriseE -:: Windows Server 2008 R2 -68531fb9-5511-4989-97be-d11a0f55633f_YC6KT-GKW9T-YTKYR-T4X34-R7%f%VHC_ServerStandard -7482e61b-c589-4b7f-8ecc-46d455ac3b87_74YFP-3QFB3-KQT8W-PMXWJ-7M%f%648_ServerDatacenter -620e2b3d-09e7-42fd-802a-17a13652fe7a_489J6-VHDMP-X63PK-3K798-CP%f%X3Y_ServerEnterprise -7482e61b-c589-4b7f-8ecc-46d455ac3b87_74YFP-3QFB3-KQT8W-PMXWJ-7M%f%648_ServerDatacenterCore -68531fb9-5511-4989-97be-d11a0f55633f_YC6KT-GKW9T-YTKYR-T4X34-R7%f%VHC_ServerStandardCore -620e2b3d-09e7-42fd-802a-17a13652fe7a_489J6-VHDMP-X63PK-3K798-CP%f%X3Y_ServerEnterpriseCore -8a26851c-1c7e-48d3-a687-fbca9b9ac16b_GT63C-RJFQ3-4GMB6-BRFB9-CB%f%83V_ServerEnterpriseIA64 -a78b8bd9-8017-4df5-b86a-09f756affa7c_6TPJF-RBVHG-WBW2R-86QPH-6R%f%TM4_ServerWeb -cda18cf3-c196-46ad-b289-60c072869994_TT8MH-CG224-D3D7Q-498W2-9Q%f%CTX_ServerHPC -a78b8bd9-8017-4df5-b86a-09f756affa7c_6TPJF-RBVHG-WBW2R-86QPH-6R%f%TM4_ServerWebCore -f772515c-0e87-48d5-a676-e6962c3e1195_736RG-XDKJK-V34PF-BHK87-J6%f%X3K_ServerEmbeddedSolution -:: Windows Vista -cfd8ff08-c0d7-452b-9f60-ef5c70c32094_VKK3X-68KWM-X2YGT-QR4M6-4B%f%WMV_Enterprise -4f3d1606-3fea-4c01-be3c-8d671c401e3b_YFKBB-PQJJV-G996G-VWGXY-2V%f%3X8_Business -2c682dc2-8b68-4f63-a165-ae291d4cf138_HMBQG-8H2RH-C77VX-27R82-VM%f%QBT_BusinessN -d4f54950-26f2-4fb4-ba21-ffab16afcade_VTC42-BM838-43QHV-84HX6-XJ%f%XKV_EnterpriseN -:: Windows Server 2008 -ad2542d4-9154-4c6d-8a44-30f11ee96989_TM24T-X9RMF-VWXK6-X8JC9-BF%f%GM2_ServerStandard -68b6e220-cf09-466b-92d3-45cd964b9509_7M67G-PC374-GR742-YH8V4-TC%f%BY3_ServerDatacenter -c1af4d90-d1bc-44ca-85d4-003ba33db3b9_YQGMW-MPWTJ-34KDK-48M3W-X4%f%Q6V_ServerEnterprise -01ef176b-3e0d-422a-b4f8-4ea880035e8f_4DWFP-JF3DJ-B7DTH-78FJB-PD%f%RHK_ServerEnterpriseIA64 -ddfa9f7c-f09e-40b9-8c1a-be877a9a7f4b_WYR28-R7TFJ-3X2YQ-YCY4H-M2%f%49D_ServerWeb -7afb1156-2c1d-40fc-b260-aab7442b62fe_RCTX3-KWVHP-BR6TB-RB6DM-6X%f%7HP_ServerComputeCluster -2401e3d0-c50a-4b58-87b2-7e794b7d2607_W7VD6-7JFBR-RX26B-YKQ3Y-6F%f%FFJ_ServerStandardV -fd09ef77-5647-4eff-809c-af2b64659a45_22XQ2-VRXRG-P8D42-K34TD-G3%f%QQC_ServerDatacenterV -8198490a-add0-47b2-b3ba-316b12d647b4_39BXF-X8Q23-P2WWT-38T2F-G3%f%FPG_ServerEnterpriseV -) do ( -for /f "tokens=1-3 delims=_" %%A in ("%%#") do if %tsedition%==%%C if not defined key ( -echo "%allapps%" | find /i "%%A" %nul1% && ( -set key=%%B -set tempid=%%A -) -) -) - -if not defined key ( -call :dk_color %Red% "Checking Activation ID [%tsedition% SKU-%osSKU% %KS% key is not available]" -call :dk_color %Blue% "Use ZeroCID activation method from the previous menu." -goto :ts_esu -) - -echo Checking Activation ID [%tempid%] [%tsedition%] - -set oldks=1 -set generickey=1 -call :dk_inskey "[%key%]" -set tsids=%tsids% %tempid% goto :ts_esu ::======================================================================================================================================== @@ -4892,7 +4293,7 @@ echo Checking Activation ID [%tempid%] [%tsedition%] set generickey=1 call :dk_inskey "[%key%]" -set tsids=%tsids% %tempid% +if not defined error set tsids=%tsids% %tempid% goto :ts_esu ::======================================================================================================================================== @@ -5002,7 +4403,7 @@ goto :ts_esu ) set resetstuff=1 -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':tsforge\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':tsforge\:.*';iex ($f[1])" set resetstuff= if !errorlevel!==3 ( set error=1 @@ -5021,15 +4422,6 @@ call :dk_inskey "[%key%]" :ts_esu if not %_actesu%==1 goto :ts_off -if /i %tsmethod%==KMS4k ( -call :dk_color %Red% "Skipping Windows ESU [KMS4k method is not supported with Windows ESU]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -goto :ts_off -) :: Process Windows ESU @@ -5051,19 +4443,6 @@ if exist "%SystemRoot%\Servicing\Packages\WinEmb-Branding-Embedded-Standard-Pack ) if not defined allapps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f -set w10EsuEditions=Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN - -set minbuild=0 -if /i %tsedition%==ServerRdsh set minbuild=5552 -for %%# in (Core CoreN CoreCountrySpecific CoreSingleLanguage IoTEnterprise) do (if /i %tsedition%==%%# set minbuild=6156) -if /i %tsedition%==PPIPro set minbuild=6388 - -set /a UBR=0 -for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR %nul6%') do if not errorlevel 1 set /a UBR=%%b -if %winbuild% EQU 19045 if %minbuild% GTR 0 if %UBR% GEQ %minbuild% ( -set w10EsuEditionsLaterAdded=%tsedition%- -) - if not defined isThinpc if not defined isltsc for %%# in ( REM Windows7 4220f546-f522-46df-8202-4d07afd26454_Client-ESU-Year3[1-3y]_-Enterprise-EnterpriseE-EnterpriseN-Professional-ProfessionalE-ProfessionalN-Ultimate-UltimateE-UltimateN- @@ -5080,10 +4459,14 @@ REM Windows8.1 REM WindowsServer2012/2012R2 55b1dd2d-2209-4ea0-a805-06298bad25b3_Server-ESU-Year3[1-3y]_-ServerDatacenter-ServerDatacenterCore-ServerDatacenterV-ServerDatacenterVCore-ServerStandard-ServerStandardCore-ServerStandardV-ServerStandardVCore- REM Windows10 -f520e45e-7413-4a34-a497-d2765967d094_Client-ESU-Year1_-%w10EsuEditions%-%w10EsuEditionsLaterAdded% -1043add5-23b1-4afb-9a0f-64343c8f3f8d_Client-ESU-Year2_-%w10EsuEditions%-%w10EsuEditionsLaterAdded% -83d49986-add3-41d7-ba33-87c7bfb5c0fb_Client-ESU-Year3_-%w10EsuEditions%-%w10EsuEditionsLaterAdded% -0b533b5e-08b6-44f9-b885-c2de291ba456_Client-ESU-Year6[4-6y]_-%w10EsuEditions%-%w10EsuEditionsLaterAdded% +f520e45e-7413-4a34-a497-d2765967d094_Client-ESU-Year1_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN-ServerRdsh- +1043add5-23b1-4afb-9a0f-64343c8f3f8d_Client-ESU-Year2_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN-ServerRdsh- +83d49986-add3-41d7-ba33-87c7bfb5c0fb_Client-ESU-Year3_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN-ServerRdsh- +0b533b5e-08b6-44f9-b885-c2de291ba456_Client-ESU-Year6[4-6y]_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN-ServerRdsh- +b8527af1-5389-447c-9a88-2d1691ea33d3_Client-IoT-ESU-Year1_-IoTEnterprise- +7b76ee02-0a75-4f08-85d5-bd0feadad0c0_Client-IoT-ESU-Year2_-IoTEnterprise- +4dac5a0c-5709-4595-a32c-14a56a4a6b31_Client-IoT-ESU-Year3_-IoTEnterprise- +f69e2d51-3bbd-4ddf-8da7-a145e9dca597_Client-IoT-ESU-Year6[4-6y]_-IoTEnterprise- ) do ( for /f "tokens=1-3 delims=_" %%A in ("%%#") do ( echo "%allapps%" | find /i "%%A" %nul1% && ( @@ -5125,12 +4508,7 @@ goto :ts_off ) if defined esuexistbutnosup ( -call :dk_color %Red% "Checking Activation ID [Currently installed ESU License is not supported for %tsedition%]" -echo: -if %winbuild% EQU 19045 if not defined w10EsuEditionsLaterAdded ( -call :dk_color %Blue% "To get latest version, go to Windows settings and run Windows Update. After that, try the script again." -goto :ts_off -) +call :dk_color %Red% "Checking Activation ID [Commercial ESU is not supported for %tsedition%]" call :dk_color %Blue% "Go back to Main Menu, select Change Windows Edition option and change to any of the below listed editions." echo [%esueditionlist%] goto :ts_off @@ -5257,7 +4635,7 @@ call :dk_color %Gray% "Checking Installed Office [Not Found]" if defined ohub ( echo: -echo You only have the Office Dashboard app installed. You need to install the full version of Office. +echo You have only Office dashboard app installed, you need to install full Office version. ) call :dk_color %Blue% "Download and install Office from below URL and try again." if %_actwin%==0 set fixes=%fixes% %mas%genuine-installation-media @@ -5361,7 +4739,6 @@ set error=1 goto :ts_starto16c2r ) -call :oh_expiredpreview 2013 if "%_actprojvis%"=="0" call :oh_fixprids call :ts_process @@ -5403,30 +4780,11 @@ set error=1 goto :ts_startmsi ) -call :oh_expiredpreview 2016 2019 2021 2024 if "%_actprojvis%"=="0" call :oh_fixprids call :ts_process ::======================================================================================================================================== -:: mass{}grave{dot}dev/office-license-is-not-genuine -:: Add registry keys for volume products so that 'non-genuine' banner won't appear - -set "kmskey=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\0ff1ce15-a989-479d-af46-f275c6370663" -if /i %tsmethod%==KMS4k ( -if %winbuild% GEQ 9200 ( -if not "%osarch%"=="x86" ( -reg delete "%kmskey%" /f /reg:32 %nul% -reg add "%kmskey%" /f /v KeyManagementServiceName /t REG_SZ /d "10.0.0.10" /reg:32 %nul% -) -reg delete "%kmskey%" /f %nul% -reg add "%kmskey%" /f /v KeyManagementServiceName /t REG_SZ /d "10.0.0.10" %nul% -echo Adding a Registry to Prevent Banner [Successful] -) -) - -::======================================================================================================================================== - :ts_startmsi if defined o15msi call :ts_processmsi 15 %o15msi_reg% @@ -5450,17 +4808,6 @@ goto :ts_act echo: echo Processing Windows %KS% Host... -if /i %tsmethod%==KMS4k ( -echo: -call :dk_color %Red% "Skipping Windows %KS% Host [KMS4k method is not supported with Windows %KS% Host]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -goto :ts_act -) - echo: if %winbuild% GEQ 10586 ( call :dk_color %Gray% "With %KS% Host license, system may randomly change Windows Edition later. It is a Windows issue and can be safely ignored." @@ -5487,10 +4834,10 @@ if %winbuild% GEQ 10586 ( for %%# in ("%SysPath%\spp\tokens\skus\%tsedition%\*CSVLK*.xrm-ms") do ( if defined _arr (set "_arr=!_arr!;"%SysPath%\spp\tokens\skus\%tsedition%\%%~nx#"") else (set "_arr="%SysPath%\spp\tokens\skus\%tsedition%\%%~nx#"") ) -if defined _arr %psc% "$sls = Get-WmiObject %sps%; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); InstallLicenseArr '!_arr!'" %nul% +if defined _arr %psc% "$sls = Get-WmiObject %sps%; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); InstallLicenseArr '!_arr!'" %nul% ) -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wintsid\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do ( +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wintsid\:.*';iex ($f[1])" %nul6%') do ( echo "%%a" | findstr /r ".*-.*-.*-.*-.*" %nul1% && (set tsids=!tsids! %%a& set tempid=%%a) ) @@ -5554,7 +4901,7 @@ goto :ts_act ) call :dk_inskey "[%key%]" -set tsids=%tsids% %tempid% +if not defined error set tsids=%tsids% %tempid% goto :ts_act ::======================================================================================================================================== @@ -5572,17 +4919,6 @@ call :dk_color %Blue% "Windows Vista and Server 2008 do not support the installa goto :ts_act ) -if /i %tsmethod%==KMS4k ( -echo: -call :dk_color %Red% "Skipping Office %KS% Host [KMS4k method is not supported with Office %KS% Host]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -goto :ts_act -) - set ohostexist= call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 set ohostids=%allapps% @@ -5635,17 +4971,6 @@ call :dk_color %Gray% "Checking Activation ID [APPX Sideloading goto :dk_done ) -if /i %tsmethod%==KMS4k ( -echo: -call :dk_color %Red% "Skipping Windows 8/8.1 APPX [KMS4k method is not supported with Windows 8/8.1 APPX]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -goto :dk_done -) - set appxexist= if not defined allapps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f @@ -5684,7 +5009,7 @@ echo Processing Reset of Rearm / Timers / Tamper / Lock... echo: set resetstuff=1 -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':tsforge\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':tsforge\:.*';iex ($f[1])" if %errorlevel%==3 ( call :dk_color %Red% "Reset Failed." @@ -5704,17 +5029,6 @@ echo: echo Processing Manual Activation... echo: -if /i %tsmethod%==KMS4k ( -echo: -call :dk_color %Red% "Skipping Manual Activation [KMS4k method is not supported with it]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -goto :dk_done -) - call :dk_color %Gray% "This option is for advanced users, those who already know what they are doing." call :dk_color %Blue% "Some activation IDs may cause system crash [MUI mismatch], or irreversible changes [CloudEdition etc]." @@ -5732,7 +5046,7 @@ if %errorlevel%==1 exit /b echo: echo Fetching Supported Activation IDs list. Please wait... -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':listactids\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':listactids\:.*';iex ($f[1])" if %errorlevel%==3 ( call :dk_color %Gray% "No supported activation ID found, aborting..." goto :dk_done @@ -5807,14 +5121,14 @@ $filteredResults = $results | Where-Object { $true } else { - $_.Name -like "*ESU*" -or $_.Name -notlike "*CountrySpecific*" + $_.Name -notlike "*CountrySpecific*" } } | Where-Object { if ($env:tsedition -like "*CloudEdition*") { $true } else { - $_.Name -like "*ESU*" -or $_.Name -notlike "*CloudEdition*" + $_.Name -notlike "*CloudEdition*" } } | Where-Object { $_.Name -like "*CountrySpecific*" -or (IsMuiNotLocked $_.ID) @@ -5867,7 +5181,6 @@ call :dk_color %Gray% "To activate, check your internet connection and ensure th ) else ( call :dk_color %Blue% "This Windows version is known to not activate due to MS Windows/Server issues." ) -if not defined showfix call :dk_color %Blue% "%_fixmsg%" set fixes=%fixes% %mas%troubleshoot call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) @@ -5875,39 +5188,26 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble if defined tsids ( echo: -if not defined _vis if not defined oldks echo Installing Forged Product Key Data... -if /i %tsmethod%==KMS4k ( -echo Writing TrustedStore data... -) else ( -if /i %tsmethod%==StaticCID (echo Depositing Static Confirmation ID...) else (echo Depositing Zero Confirmation ID...) -) +if not defined _vis echo Installing Forged Product Key Data... +echo Depositing Zero Confirmation ID... echo: -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':tsforge\:.*';. ([scriptblock]::Create($f[1])) %tsids%" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':tsforge\:.*';& ([ScriptBlock]::Create($f[1])) %tsids%" if !errorlevel!==3 ( -if %_actman%==0 (if not defined showfix call :dk_color %Blue% "%_fixmsg%") +if %_actman%==0 call :dk_color %Blue% "%_fixmsg%" set fixes=%fixes% %mas%troubleshoot call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) else ( -if /i %tsmethod%==KMS4k if %winbuild% GEQ 26100 ( -echo: -call :dk_color %Gray% "In Windows settings, you may see a renewal notification for activation that can be ignored." -if /i %_actmethod%==Auto call :dk_color %Gray% "To avoid this notification, run the script with an internet connection to use the StaticCID method." -) echo "%tsids%" | find /i "7e94be23-b161-4956-a682-146ab291774c" %nul1% && ( -call :dk_color %Gray% "Windows Update gets 1-3 years of ESU; 4-6 are unofficial but let you install Server 2008 R2 updates manually." +call :dk_color %Gray% "Windows Update can receive 1-3 years of ESU. 4-6 years ESU is not officially supported, but you can manually install updates." ) echo "%tsids%" | findstr /i "4afc620f-12a4-48ad-8015-2aebfbd6e47c 11be7019-a309-4763-9a09-091d1722ffe3" %nul1% && ( -call :dk_color %Gray% "ESU is not officially supported on Windows 8.1, but updates can be installed manually until January 2024." +call :dk_color %Gray% "ESU is not officially supported on Windows 8.1, but you can manually install updates until Jan-2024." ) -echo "%tsids%" | findstr /i "83d49986-add3-41d7-ba33-87c7bfb5c0fb 0b533b5e-08b6-44f9-b885-c2de291ba456" %nul1% && ( -call :dk_color %Gray% "Windows Update gets 1-3 years of ESU; 4-6 are unofficial but may let you install LTSC updates manually." -if exist %SysPath%\ClipESUConsumer.exe (%SysPath%\ClipESUConsumer.exe -evaluateEligibility) -if exist %SysPath%\ClipESU.exe (%SysPath%\ClipESU.exe %nul%) +echo "%tsids%" | findstr /i "0b533b5e-08b6-44f9-b885-c2de291ba456 f69e2d51-3bbd-4ddf-8da7-a145e9dca597" %nul1% && ( +call :dk_color %Gray% "Windows Update can receive 1-3 years of ESU. 4-6 years ESU is not officially supported, but it might be useful." ) ) -if defined esuexistsup echo Help: %mas%tsforge#windows-esu - if %_actwin%==1 for %%# in (407) do if %osSKU%==%%# ( call :dk_color %Red% "%winos% does not support activation on non-azure platforms." ) @@ -6009,19 +5309,6 @@ set _preview= set _License=%%# set skipprocess= - -set foundprod= -call :tsksdata chkprod %%# -if defined _oMSI if not defined foundprod if /i %tsmethod%==KMS4k ( -set skipprocess=1 -call :dk_color %Red% "Checking Product In Script [%%# MSI Retail is not supported with KMS4k]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -) - if "%_actprojvis%"=="1" ( echo %%# | findstr /i "Project Visio" %nul% || ( set skipprocess=1 @@ -6029,17 +5316,8 @@ call :dk_color %Gray% "Skipping Because Project/Visio Mode [%%#]" ) ) -if "%_actprojvis%"=="0" if /i %tsmethod%==KMS4k echo %_oIds% | findstr /i "O365" %nul% && ( -echo %%# | findstr /i "Project Visio" %nul% && ( -set skipprocess=1 -echo Skipping Because Mondo Is Available [%%#] -) -) - - if not defined skipprocess ( -if /i not %tsmethod%==KMS4k ( set no365= if "%oVer%"=="15" (echo %%# | findstr /i "O365HomePremRetail" %nul% && set no365=1) if "%oVer%"=="16" (echo %%# | findstr /i "O365" %nul% && set no365=1) @@ -6049,8 +5327,6 @@ set _License=MondoRetail set _altoffid=MondoRetail call :ks_osppready echo Converting Unsupported O365 Office [%%# To MondoRetail] -if "%oVer%"=="15" (call :dk_color %Gray% "Mondo 2013 is equivalent to O365 [15.0 version] in terms of the latest features.") -if "%oVer%"=="16" (call :dk_color %Gray% "Mondo 2016 is equivalent to O365 in terms of the latest features.") ) if not defined _oMSI ( @@ -6061,31 +5337,9 @@ call :ks_osppready echo Converting Unsupported OEM-ARM Office [%%# To MondoRetail] ) ) -) -if not defined _oMSI if /i %tsmethod%==KMS4k if not defined foundprod ( -call :tsksdata getinfo %%# -if defined _altoffid ( -echo Converting Retail To Volume [%%# To !_altoffid!] -) else ( -set _License=MondoVolume -set _altoffid=MondoVolume -echo Converting Retail To Volume [%%# To !_altoffid!] [Using Mondo because %%# is not found in the script] -) -echo %%# | find /i "O365" %nul% && ( -if "%oVer%"=="15" (call :dk_color %Gray% "Mondo 2013 is equivalent to O365 [15.0 version] in terms of the latest features.") -if "%oVer%"=="16" (call :dk_color %Gray% "Mondo 2016 is equivalent to O365 in terms of the latest features.") -) -call :ks_osppready -) - -if /i %tsmethod%==KMS4k ( -echo !_License! | find /i "Retail" %nul% && (set keytype=zero) || (set keytype=ks) -) else ( set keytype=zero -) - -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':offtsid\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do ( +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':offtsid\:.*';iex ($f[1])" %nul6%') do ( echo "%%a" | findstr /r ".*-.*-.*-.*-.*" %nul1% && (set tsids=!tsids! %%a& set _actid=%%a) ) set "_allactid=!tsids!" @@ -6113,7 +5367,7 @@ echo "!allapps!" | find /i "!_actid!" %nul1% || call :oh_installlic :: Add SharedComputerLicensing registry key if Retail Office C2R is installed on Windows Server :: https://learn.microsoft.com/en-us/office/troubleshoot/office-suite-issues/click-to-run-office-on-terminal-server -if /i not %tsmethod%==KMS4k if defined winserver if defined _config if exist "%_oLPath%\Word2019VL_KMS_Client_AE*.xrm-ms" ( +if defined winserver if defined _config if exist "%_oLPath%\Word2019VL_KMS_Client_AE*.xrm-ms" ( echo %_oIds% | find /i "Retail" %nul1% && ( set scaIsNeeded=1 reg add %_config% /v SharedComputerLicensing /t REG_SZ /d "1" /f %nul1% @@ -6179,221 +5433,7 @@ exit /b :tsforge: $src = @' -#if !POWERSHELL2 -namespace ActivationWs -{ - -/* - -This code is adapted from ActivationWs. -Original Repository: https://github.com/dadorner-msft/activationws - -MIT License - -Copyright (c) Daniel Dorner - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ - -using System; -using System.IO; -using System.Linq; -using System.Net; -using System.Security.Cryptography; -using System.Text; -using System.Xml.Linq; - - public static class ActivationHelper { - // Key for HMAC/SHA256 signature. - private static readonly byte[] MacKey = new byte[64] { - 254, 49, 152, 117, 251, 72, 132, 134, - 156, 243, 241, 206, 153, 168, 144, 100, - 171, 87, 31, 202, 71, 4, 80, 88, - 48, 36, 226, 20, 98, 135, 121, 160, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 - }; - - private const string Action = "http://www.microsoft.com/BatchActivationService/BatchActivate"; - - private static readonly Uri Uri = new Uri("https://activation.sls.microsoft.com/BatchActivation/BatchActivation.asmx"); - - private static readonly XNamespace SoapSchemaNs = "http://schemas.xmlsoap.org/soap/envelope/"; - private static readonly XNamespace XmlSchemaInstanceNs = "http://www.w3.org/2001/XMLSchema-instance"; - private static readonly XNamespace XmlSchemaNs = "http://www.w3.org/2001/XMLSchema"; - private static readonly XNamespace BatchActivationServiceNs = "http://www.microsoft.com/BatchActivationService"; - private static readonly XNamespace BatchActivationRequestNs = "http://www.microsoft.com/DRM/SL/BatchActivationRequest/1.0"; - private static readonly XNamespace BatchActivationResponseNs = "http://www.microsoft.com/DRM/SL/BatchActivationResponse/1.0"; - - public static string CallWebService(int requestType, string installationId, string extendedProductId) { - XDocument soapRequest = CreateSoapRequest(requestType, installationId, extendedProductId); - HttpWebRequest webRequest = CreateWebRequest(soapRequest); - XDocument soapResponse = new XDocument(); - - try { - IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null); - asyncResult.AsyncWaitHandle.WaitOne(); - - // Read data from the response stream. - using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult)) - using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream())) { - soapResponse = XDocument.Parse(streamReader.ReadToEnd()); - } - - return ParseSoapResponse(soapResponse); - - } catch { - throw; - } - } - - private static XDocument CreateSoapRequest(int requestType, string installationId, string extendedProductId) { - // Create an activation request. - XElement activationRequest = new XElement(BatchActivationRequestNs + "ActivationRequest", - new XElement(BatchActivationRequestNs + "VersionNumber", "2.0"), - new XElement(BatchActivationRequestNs + "RequestType", requestType), - new XElement(BatchActivationRequestNs + "Requests", - new XElement(BatchActivationRequestNs + "Request", - new XElement(BatchActivationRequestNs + "PID", extendedProductId), - requestType == 1 ? new XElement(BatchActivationRequestNs + "IID", installationId) : null) - ) - ); - - // Get the unicode byte array of activationRequest and convert it to Base64. - byte[] bytes = Encoding.Unicode.GetBytes(activationRequest.ToString()); - string requestXml = Convert.ToBase64String(bytes); - - XDocument soapRequest = new XDocument(); - - using (HMACSHA256 hMACSHA = new HMACSHA256(MacKey)) { - // Convert the HMAC hashed data to Base64. - string digest = Convert.ToBase64String(hMACSHA.ComputeHash(bytes)); - - soapRequest = new XDocument( - new XDeclaration("1.0", "UTF-8", "no"), - new XElement(SoapSchemaNs + "Envelope", - new XAttribute(XNamespace.Xmlns + "soap", SoapSchemaNs), - new XAttribute(XNamespace.Xmlns + "xsi", XmlSchemaInstanceNs), - new XAttribute(XNamespace.Xmlns + "xsd", XmlSchemaNs), - new XElement(SoapSchemaNs + "Body", - new XElement(BatchActivationServiceNs + "BatchActivate", - new XElement(BatchActivationServiceNs + "request", - new XElement(BatchActivationServiceNs + "Digest", digest), - new XElement(BatchActivationServiceNs + "RequestXml", requestXml) - ) - ) - ) - )); - - } - - return soapRequest; - } - - private static HttpWebRequest CreateWebRequest(XDocument soapRequest) { - HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(Uri); - webRequest.Accept = "text/xml"; - webRequest.ContentType = "text/xml; charset=\"utf-8\""; - webRequest.Headers.Add("SOAPAction", Action); - webRequest.Host = "activation.sls.microsoft.com"; - webRequest.Method = "POST"; - - try { - // Insert SOAP envelope - using (Stream stream = webRequest.GetRequestStream()) { - soapRequest.Save(stream); - } - - return webRequest; - - } catch { - throw; - } - } - - private static string ParseSoapResponse(XDocument soapResponse) { - if (soapResponse == null) { - throw new ArgumentNullException("soapResponse", "The remote server returned an unexpected response."); - } - - if (!soapResponse.Descendants(BatchActivationServiceNs + "ResponseXml").Any()) { - throw new Exception("The remote server returned an unexpected response"); - } - - try { - XDocument responseXml = XDocument.Parse(soapResponse.Descendants(BatchActivationServiceNs + "ResponseXml").First().Value); - - if (responseXml.Descendants(BatchActivationResponseNs + "ErrorCode").Any()) { - string errorCode = responseXml.Descendants(BatchActivationResponseNs + "ErrorCode").First().Value; - - switch (errorCode) { - case "0x7F": - throw new Exception("The Multiple Activation Key has exceeded its limit"); - - case "0x67": - throw new Exception("The product key has been blocked"); - - case "0x68": - throw new Exception("Invalid product key"); - - case "0x86": - throw new Exception("Invalid key type"); - - case "0x90": - throw new Exception("Please check the Installation ID and try again"); - - default: - throw new Exception(string.Format("The remote server reported an error ({0})", errorCode)); - } - - } else if (responseXml.Descendants(BatchActivationResponseNs + "ResponseType").Any()) { - string responseType = responseXml.Descendants(BatchActivationResponseNs + "ResponseType").First().Value; - - switch (responseType) { - case "1": - string confirmationId = responseXml.Descendants(BatchActivationResponseNs + "CID").First().Value; - return confirmationId; - - case "2": - string activationsRemaining = responseXml.Descendants(BatchActivationResponseNs + "ActivationRemaining").First().Value; - return activationsRemaining; - - default: - throw new Exception("The remote server returned an unrecognized response"); - } - - } else { - throw new Exception("The remote server returned an unrecognized response"); - } - - } catch { - throw; - } - } - } -} -#endif - -// LibTSforge/Common.cs +// Common.cs namespace LibTSforge { using System; @@ -6635,7 +5675,7 @@ namespace LibTSforge } -// LibTSforge/SPP/PKeyConfig.cs +// SPP/PKeyConfig.cs namespace LibTSforge.SPP { using System; @@ -6661,7 +5701,7 @@ namespace LibTSforge.SPP public bool Contains(int n) { - return Start <= n && n <= End; + return Start <= n && End <= n; } } @@ -6791,19 +5831,10 @@ namespace LibTSforge.SPP string refActIdStr = configNode.SelectSingleNode("./p:ActConfigId", nsmgr).InnerText; Guid refActId = new Guid(refActIdStr); int group = int.Parse(configNode.SelectSingleNode("./p:RefGroupId", nsmgr).InnerText); - List keyRanges; - ranges.TryGetValue(refActIdStr, out keyRanges); - - if (keyRanges == null) - { - continue; - } + List keyRanges = ranges[refActIdStr]; if (keyRanges.Count > 0 && !Products.ContainsKey(refActId)) { - PKeyAlgorithm algorithm; - algorithms.TryGetValue(group, out algorithm); - ProductConfig productConfig = new ProductConfig { GroupId = group, @@ -6811,7 +5842,7 @@ namespace LibTSforge.SPP Description = configNode.SelectSingleNode("./p:ProductDescription", nsmgr).InnerText, Channel = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText, Randomized = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText.ToLower() == "true", - Algorithm = algorithm, + Algorithm = algorithms[group], Ranges = keyRanges, ActivationId = refActId }; @@ -6861,7 +5892,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/ProductKey.cs +// SPP/ProductKey.cs namespace LibTSforge.SPP { using System; @@ -7177,7 +6208,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/SLAPI.cs +// SPP/SLAPI.cs namespace LibTSforge.SPP { using System; @@ -7590,7 +6621,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/SPPUtils.cs +// SPP/SPPUtils.cs namespace LibTSforge.SPP { using Microsoft.Win32; @@ -7927,7 +6958,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/SPSys.cs +// SPP/SPSys.cs namespace LibTSforge.SPP { using Microsoft.Win32.SafeHandles; @@ -7974,7 +7005,7 @@ namespace LibTSforge.SPP } -// LibTSforge/Crypto/CryptoUtils.cs +// Crypto/CryptoUtils.cs namespace LibTSforge.Crypto { using System; @@ -8109,7 +7140,7 @@ namespace LibTSforge.Crypto } -// LibTSforge/Crypto/Keys.cs +// Crypto/Keys.cs namespace LibTSforge.Crypto { public static class Keys @@ -8199,7 +7230,7 @@ namespace LibTSforge.Crypto } -// LibTSforge/Crypto/PhysStoreCrypto.cs +// Crypto/PhysStoreCrypto.cs namespace LibTSforge.Crypto { using System; @@ -8284,7 +7315,7 @@ namespace LibTSforge.Crypto } -// LibTSforge/Modifiers/GenPKeyInstall.cs +// Modifiers/GenPKeyInstall.cs namespace LibTSforge.Modifiers { using System; @@ -8495,7 +7526,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/GracePeriodReset.cs +// Modifiers/GracePeriodReset.cs namespace LibTSforge.Modifiers { using System.Collections.Generic; @@ -8528,7 +7559,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/KeyChangeLockDelete.cs +// Modifiers/KeyChangeLockDelete.cs namespace LibTSforge.Modifiers { using System.Collections.Generic; @@ -8568,7 +7599,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/KMSHostCharge.cs +// Modifiers/KMSHostCharge.cs namespace LibTSforge.Modifiers { using System; @@ -8729,7 +7760,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/RearmReset.cs +// Modifiers/RearmReset.cs namespace LibTSforge.Modifiers { using System.Collections.Generic; @@ -8785,7 +7816,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/SetIIDParams.cs +// Modifiers/SetIIDParams.cs namespace LibTSforge.Modifiers { using PhysicalStore; @@ -8854,7 +7885,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/TamperedFlagsDelete.cs +// Modifiers/TamperedFlagsDelete.cs namespace LibTSforge.Modifiers { using System.Linq; @@ -8904,7 +7935,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/UniqueIdDelete.cs +// Modifiers/UniqueIdDelete.cs namespace LibTSforge.Modifiers { using System; @@ -8963,23 +7994,27 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Activators/KMS4K.cs +// Activators/AVMA4K.cs namespace LibTSforge.Activators { using System; - using System.IO; using PhysicalStore; using SPP; - public class KMS4k + public static class AVMA4k { public static void Activate(PSVersion version, bool production, Guid actId) { + if (version != PSVersion.WinModern && version != PSVersion.WinBlue) + { + throw new NotSupportedException("AVMA licenses are not available for this product."); + } + Guid appId; if (actId == Guid.Empty) { appId = SLApi.WINDOWS_APP_ID; - actId = SLApi.GetDefaultActivationID(appId, true); + actId = SLApi.GetDefaultActivationID(appId, false); if (actId == Guid.Empty) { @@ -8991,9 +8026,9 @@ namespace LibTSforge.Activators appId = SLApi.GetAppId(actId); } - if (SLApi.GetPKeyChannel(SLApi.GetInstalledPkeyID(actId)) != "Volume:GVLK") + if (SLApi.GetPKeyChannel(SLApi.GetInstalledPkeyID(actId)) != "VT:IA") { - throw new NotSupportedException("Non-Volume:GVLK product key installed."); + throw new NotSupportedException("Non-VT:IA product key installed."); } SPPUtils.KillSPP(version); @@ -9004,177 +8039,86 @@ namespace LibTSforge.Activators { string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId); - ulong unknown = 0; - ulong time1; - ulong time2 = (ulong)DateTime.UtcNow.ToFileTime(); - ulong expiry = Constants.TimerMax; + long creationTime = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-CREATION-TIME$$").Data, 0); + long tickCount = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-TICKCOUNT-UPTIME$$").Data, 0); + long deltaTime = BitConverter.ToInt64(store.GetBlock(key, "__##USERSEP-RESERVED##__$$UP-TIME-DELTA$$").Data, 0); - if (version == PSVersion.Vista || version == PSVersion.Win7) + const ulong unknown = 0; + ulong time1 = (ulong)(creationTime + tickCount + deltaTime); + ulong crcBindTime = (ulong)DateTime.UtcNow.ToFileTime(); + ulong timerTime = crcBindTime / 10000; + ulong expiry = Constants.TimerMax / 10000; + + VariableBag avmaBinding = new VariableBag(version); + + avmaBinding.Blocks.AddRange(new[] { - unknown = 0x800000000; - time1 = 0; - } - else - { - long creationTime = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-CREATION-TIME$$").Data, 0); - long tickCount = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-TICKCOUNT-UPTIME$$").Data, 0); - long deltaTime = BitConverter.ToInt64(store.GetBlock(key, "__##USERSEP-RESERVED##__$$UP-TIME-DELTA$$").Data, 0); - - time1 = (ulong)(creationTime + tickCount + deltaTime); - time2 /= 10000; - expiry /= 10000; - } - - if (version == PSVersion.Vista) - { - VistaTimer vistaTimer = new VistaTimer - { - Time = time2, - Expiry = Constants.TimerMax - }; - - string vistaTimerName = string.Format("msft:sl/timer/VLExpiration/VOLUME/{0}/{1}", appId, actId); - - store.DeleteBlock(key, vistaTimerName); - store.DeleteBlock(key, actId.ToString()); - - BinaryWriter writer = new BinaryWriter(new MemoryStream()); - writer.Write(Constants.KMSv4Response.Length); - writer.Write(Constants.KMSv4Response); - writer.Write(Constants.UniversalHWIDBlock); - byte[] kmsData = writer.GetBytes(); - - store.AddBlocks(new[] - { - new PSBlock - { - Type = BlockType.TIMER, - Flags = 0, - KeyAsStr = key, - ValueAsStr = vistaTimerName, - Data = vistaTimer.CastToArray() - }, - new PSBlock - { - Type = BlockType.NAMED, - Flags = 0, - KeyAsStr = key, - ValueAsStr = actId.ToString(), - Data = kmsData - } - }); - } - else - { - byte[] hwidBlock = Constants.UniversalHWIDBlock; - byte[] kmsResp; - - switch (version) - { - case PSVersion.Win7: - kmsResp = Constants.KMSv4Response; - break; - case PSVersion.Win8: - kmsResp = Constants.KMSv5Response; - break; - case PSVersion.WinBlue: - case PSVersion.WinModern: - kmsResp = Constants.KMSv6Response; - break; - default: - throw new NotSupportedException("Unsupported PSVersion."); - } - - VariableBag kmsBinding = new VariableBag(version); - - kmsBinding.Blocks.AddRange(new[] - { new CRCBlockModern { DataType = CRCBlockType.BINARY, Key = new byte[] { }, - Value = kmsResp + Value = BitConverter.GetBytes(crcBindTime), }, new CRCBlockModern { DataType = CRCBlockType.STRING, Key = new byte[] { }, - ValueAsStr = "msft:rm/algorithm/hwid/4.0" + ValueAsStr = "AVMA4K", }, new CRCBlockModern { - DataType = CRCBlockType.BINARY, - KeyAsStr = "SppBindingLicenseData", - Value = hwidBlock + DataType = CRCBlockType.STRING, + Key = new byte[] { }, + ValueAsStr = "00491-50000-00001-AA666", } - }); + }); - if (version == PSVersion.WinModern) - { - kmsBinding.Blocks.AddRange(new[] - { - new CRCBlockModern - { - DataType = CRCBlockType.STRING, - Key = new byte[] { }, - ValueAsStr = "massgrave.dev" - }, - new CRCBlockModern - { - DataType = CRCBlockType.STRING, - Key = new byte[] { }, - ValueAsStr = "6969" - } - }); - } + byte[] avmaBindingData = avmaBinding.Serialize(); - byte[] kmsBindingData = kmsBinding.Serialize(); + Timer avmaTimer = new Timer + { + Unknown = unknown, + Time1 = time1, + Time2 = timerTime, + Expiry = expiry + }; - Timer kmsTimer = new Timer - { - Unknown = unknown, - Time1 = time1, - Time2 = time2, - Expiry = expiry - }; + string storeVal = string.Format("msft:spp/ia/bind/1.0/store/{0}/{1}", appId, actId); + string timerVal = string.Format("msft:spp/ia/bind/1.0/timer/{0}/{1}", appId, actId); - string storeVal = string.Format("msft:spp/kms/bind/2.0/store/{0}/{1}", appId, actId); - string timerVal = string.Format("msft:spp/kms/bind/2.0/timer/{0}/{1}", appId, actId); + store.DeleteBlock(key, storeVal); + store.DeleteBlock(key, timerVal); - store.DeleteBlock(key, storeVal); - store.DeleteBlock(key, timerVal); - - store.AddBlocks(new[] - { + store.AddBlocks(new[] + { new PSBlock { Type = BlockType.NAMED, - Flags = (version == PSVersion.WinModern) ? (uint)0x400 : 0, + Flags = 0x400, KeyAsStr = key, ValueAsStr = storeVal, - Data = kmsBindingData + Data = avmaBindingData, }, new PSBlock { Type = BlockType.TIMER, - Flags = (version == PSVersion.Win7) ? (uint)0 : 0x4, + Flags = 0x4, KeyAsStr = key, ValueAsStr = timerVal, - Data = kmsTimer.CastToArray() + Data = avmaTimer.CastToArray() } - }); - } + }); } - SPPUtils.RestartSPP(version); + SLApi.RefreshLicenseStatus(); SLApi.FireStateChangedEvent(appId); - Logger.WriteLine("Activated using KMS4k successfully."); + Logger.WriteLine("Activated using AVMA4k successfully."); } } } -// LibTSforge/Activators/ZeroCID.cs +// Activators/ZeroCID.cs namespace LibTSforge.Activators { using System; @@ -9363,7 +8307,7 @@ namespace LibTSforge.Activators } -// LibTSforge/TokenStore/Common.cs +// TokenStore/Common.cs namespace LibTSforge.TokenStore { using System.Collections.Generic; @@ -9433,7 +8377,7 @@ namespace LibTSforge.TokenStore } -// LibTSforge/TokenStore/ITokenStore.cs +// TokenStore/ITokenStore.cs namespace LibTSforge.TokenStore { using System; @@ -9453,7 +8397,7 @@ namespace LibTSforge.TokenStore } -// LibTSforge/TokenStore/TokenStoreModern.cs +// TokenStore/TokenStoreModern.cs namespace LibTSforge.TokenStore { using System; @@ -9739,7 +8683,7 @@ namespace LibTSforge.TokenStore } -// LibTSforge/PhysicalStore/Common.cs +// PhysicalStore/Common.cs namespace LibTSforge.PhysicalStore { using System.Runtime.InteropServices; @@ -9770,7 +8714,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/IPhysicalStore.cs +// PhysicalStore/IPhysicalStore.cs namespace LibTSforge.PhysicalStore { using System; @@ -9865,7 +8809,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/PhysicalStoreModern.cs +// PhysicalStore/PhysicalStoreModern.cs namespace LibTSforge.PhysicalStore { using System; @@ -10283,7 +9227,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/PhysicalStoreVista.cs +// PhysicalStore/PhysicalStoreVista.cs namespace LibTSforge.PhysicalStore { using System; @@ -10642,7 +9586,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/PhysicalStoreWin7.cs +// PhysicalStore/PhysicalStoreWin7.cs namespace LibTSforge.PhysicalStore { using System; @@ -11019,7 +9963,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/VariableBag.cs +// PhysicalStore/VariableBag.cs namespace LibTSforge.PhysicalStore { using System; @@ -11275,17 +10219,15 @@ namespace LibTSforge.PhysicalStore '@ $ErrorActionPreference = 'Stop' $binPath = "$env:_work\BIN\LibTSforge.dll" -$psMajorVer = (Get-Host).Version.Major -$build = [System.Environment]::OSVersion.Version.Build if (Test-Path -LiteralPath $binPath) { Write-Host "LibTSforge.dll found in BIN folder. Loading the DLL..." Add-Type -Path $binPath } else { - $cp = [CodeDom.Compiler.CompilerParameters] [string[]]@("System.dll", "System.Core.dll", "System.ServiceProcess.dll", "System.Xml.dll", "System.Xml.Linq.dll") - if ($psMajorVer -le 2) { $cp.CompilerOptions = "/define:POWERSHELL2 /unsafe" } else { $cp.CompilerOptions = "/unsafe" } - $lang = if ($psMajorVer -gt 2) { "CSharp" } else { "CSharpVersion3" } + $cp = [CodeDom.Compiler.CompilerParameters] [string[]]@("System.dll", "System.Core.dll", "System.ServiceProcess.dll", "System.Xml.dll") + $cp.CompilerOptions = "/unsafe" + $lang = If ((Get-Host).Version.Major -gt 2) { "CSharp" } Else { "CSharpVersion3" } $ctemp = "$env:SystemRoot\Temp\" if (-Not (Test-Path -Path $ctemp)) { New-Item -Path $ctemp -ItemType Directory > $null } @@ -11299,7 +10241,6 @@ else { if ($env:_debug -eq '0') { [LibTSforge.Logger]::HideOutput = $true } -[void][LibTSforge.Utils]::Wow64EnableWow64FsRedirection($false) $ver = [LibTSforge.Utils]::DetectVersion() $prod = [LibTSforge.SPP.SPPUtils]::DetectCurrentKey() $tsactids = @($args) @@ -11335,76 +10276,32 @@ function slGetSkuInfo($SkuId) { if (-not $env:resetstuff) { foreach ($tsactid in $tsactids) { try { - $activated = $null $prodDes = Get-WmiInfo -tsactid $tsactid -property "Description" $prodName = Get-WmiInfo -tsactid $tsactid -property "Name" if ($prodName) { $nameParts = $prodName -split ',', 2 $prodName = if ($nameParts.Count -gt 1) { ($nameParts[1].Trim() -split '[ ,]')[0] } else { $null } } - if (-not $env:_vis -and -not $env:oldks) { - [LibTSforge.Modifiers.GenPKeyInstall]::InstallGenPKey($ver, $prod, $tsactid) - } - if ($prodName -match 'Office' -and $prodDes -notmatch 'KMS' -and -not (slGetSkuInfo($tsactid))) { + if (-not $env:_vis) { + [LibTSforge.Modifiers.GenPKeyInstall]::InstallGenPKey($ver, $prod, $tsactid) + } + if ($prodName -match 'Office' -and -not (slGetSkuInfo($tsactid))) { $licenseStatus = Get-WmiInfo -tsactid $tsactid -property "LicenseStatus" if ($licenseStatus -eq 1) { Write-Host "[$prodName] is already permanently activated." -ForegroundColor White -BackgroundColor DarkGreen continue } } - if ($env:tsmethod -eq "StaticCID") { - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - $attempts = @( - @(100055, 1000043, 1338662172562478), - @(1345, 1003020, 6311608238084405) - ) - foreach ($params in $attempts) { - [LibTSforge.Modifiers.SetIIDParams]::SetParams($ver, $prod, $tsactid, [LibTSforge.SPP.PKeyAlgorithm]::PKEY2009, $params[0], $params[1], $params[2]) - $instId = [LibTSforge.SPP.SLApi]::GetInstallationID($tsactid) - $confId = [ActivationWs.ActivationHelper]::CallWebService(1, $instId, "31337-42069-123-456789-04-1337-2600.0000-2542001") - $result = [LibTSforge.SPP.SLApi]::DepositConfirmationID($tsactid, $instId, $confId) - if ($result -eq 0) { break } - } - [LibTSforge.SPP.SPPUtils]::RestartSPP($ver) - } - elseif ($env:tsmethod -eq "KMS4k") { - [LibTSforge.Activators.KMS4k]::Activate($ver, $prod, $tsactid) - } - else { - [LibTSforge.Activators.ZeroCID]::Activate($ver, $prod, $tsactid) - } - if ($env:tsmethod -eq "KMS4k") { - $GracePeriodStatus = Get-WmiInfo -tsactid $tsactid -property "GracePeriodRemaining" - if ($GracePeriodStatus -eq 259200 -or ([datetime]::Now.AddMinutes($GracePeriodStatus)).Year -gt 2038) { - if ((($build -ge 26100 -and $GracePeriodStatus -ge 259200) -or - ($build -lt 26100 -and $GracePeriodStatus -gt 259200))) { - $activated = 1 - } - } - } - else { - $licenseStatus = Get-WmiInfo -tsactid $tsactid -property "LicenseStatus" - if ($licenseStatus -eq 1) { $activated = 1 } - } - if ($activated) { + [LibTSforge.Activators.ZeroCID]::Activate($ver, $prod, $tsactid) + $licenseStatus = Get-WmiInfo -tsactid $tsactid -property "LicenseStatus" + if ($licenseStatus -eq 1) { if ($prodDes -match 'KMS' -and $prodDes -notmatch 'CLIENT') { [LibTSforge.Modifiers.KMSHostCharge]::Charge($ver, $prod, $tsactid) - Write-Host "[$prodName] CSVLK is permanently activated with $env:tsmethod." -ForegroundColor White -BackgroundColor DarkGreen + Write-Host "[$prodName] CSVLK is permanently activated with ZeroCID." -ForegroundColor White -BackgroundColor DarkGreen Write-Host "[$prodName] CSVLK is charged with 25 clients for 30 days." -ForegroundColor White -BackgroundColor DarkGreen } else { - if ($env:tsmethod -eq "KMS4k") { - if ($build -ge 26100) { - Write-Host "[$prodName] is activated with KMS4k for over 4,000 years." -ForegroundColor White -BackgroundColor DarkGreen - Write-Host "From build 26100.7019, Windows will always display and stay at 180 days remaining if the actual period is longer." -ForegroundColor White -BackgroundColor Darkgray - } - else { - Write-Host "[$prodName] is activated till $([DateTime]::Now.AddMinutes($GracePeriodStatus).ToString('yyyy-MM-dd HH:mm:ss')) with $env:tsmethod." -ForegroundColor White -BackgroundColor DarkGreen - } - } - else { - Write-Host "[$prodName] is permanently activated with $env:tsmethod." -ForegroundColor White -BackgroundColor DarkGreen - } + Write-Host "[$prodName] is permanently activated with ZeroCID." -ForegroundColor White -BackgroundColor DarkGreen } } else { @@ -11422,11 +10319,11 @@ if (-not $env:resetstuff) { if ($env:resetstuff) { try { - if (-not $env:_vis) { [LibTSforge.Modifiers.TamperedFlagsDelete]::DeleteTamperFlags($ver, $prod) } + if (-not $env:_vis) {[LibTSforge.Modifiers.TamperedFlagsDelete]::DeleteTamperFlags($ver, $prod)} [LibTSforge.SPP.SLApi]::RefreshLicenseStatus() [LibTSforge.Modifiers.RearmReset]::Reset($ver, $prod) [LibTSforge.Modifiers.GracePeriodReset]::Reset($ver, $prod) - if (-not $env:_vis) { [LibTSforge.Modifiers.KeyChangeLockDelete]::Delete($ver, $prod) } + if (-not $env:_vis) {[LibTSforge.Modifiers.KeyChangeLockDelete]::Delete($ver, $prod)} } catch { $errcode = 3 @@ -11671,7 +10568,7 @@ function Office-ActID { } } - $filterPreview = $filteredConfigs | Where-Object { $_.ProductDescription -notmatch 'preview|c2r' } + $filterPreview = $filteredConfigs | Where-Object { $_.ProductDescription -notmatch 'preview' } if ($filterPreview.Count -ne 0) { $filteredConfigs = $filterPreview @@ -11686,130 +10583,6 @@ Office-ActID -pkeypath "$env:pkeypath" -edition "$env:_License" -keytype "$env:k ::======================================================================================================================================== -:: 1st column = Office version -:: 2nd column = Volume or free retail product -:: 3rd column = Retail product names that needs to be converted to the Volume product mentioned in 2nd column -:: Separator = "_" - -:tsksdata - -set f= -for %%# in ( -:: Office 2013 -15_AccessVolume_-AccessRetail- -15_AccessRuntimeRetail -15_ExcelVolume_-ExcelRetail- -15_GrooveVolume_-GrooveRetail- -15_InfoPathVolume_-InfoPathRetail- -15_LyncAcademicRetail -15_LyncEntryRetail -15_LyncVolume_-LyncRetail- -15_MondoRetail -15_MondoVolume_-O365BusinessRetail-O365HomePremRetail-O365ProPlusRetail-O365SmallBusPremRetail- -15_OneNoteFreeRetail -15_OneNoteVolume_-OneNoteRetail- -15_OutlookVolume_-OutlookRetail- -15_PowerPointVolume_-PowerPointRetail- -15_ProjectProVolume_-ProjectProRetail- -15_ProjectStdVolume_-ProjectStdRetail- -15_ProPlusVolume_-ProPlusRetail-ProfessionalPipcRetail-ProfessionalRetail- -15_PublisherVolume_-PublisherRetail- -15_SPDRetail -15_StandardVolume_-StandardRetail-HomeBusinessPipcRetail-HomeBusinessRetail-HomeStudentARMRetail-HomeStudentPlusARMRetail-HomeStudentRetail-PersonalPipcRetail-PersonalRetail- -15_VisioProVolume_-VisioProRetail- -15_VisioStdVolume_-VisioStdRetail- -15_WordVolume_-WordRetail- -:: Office 2016 -16_AccessRuntimeRetail -16_AccessVolume_-AccessRetail- -16_ExcelVolume_-ExcelRetail- -16_MondoRetail -16_MondoVolume_-O365AppsBasicRetail-O365BusinessRetail-O365EduCloudRetail-O365HomePremRetail-O365ProPlusRetail-O365SmallBusPremRetail- -16_OneNoteFreeRetail -16_OneNoteVolume_-OneNoteRetail-OneNote2021Retail- -16_OutlookVolume_-OutlookRetail- -16_PowerPointVolume_-PowerPointRetail- -16_ProjectProVolume_-ProjectProRetail- -16_ProjectProXVolume -16_ProjectStdVolume_-ProjectStdRetail- -16_ProjectStdXVolume -16_ProPlusVolume_-ProPlusRetail-ProfessionalPipcRetail-ProfessionalRetail- -16_PublisherVolume_-PublisherRetail- -16_SkypeServiceBypassRetail -16_SkypeforBusinessEntryRetail -16_SkypeforBusinessVolume_-SkypeforBusinessRetail- -16_StandardVolume_-StandardRetail-HomeBusinessPipcRetail-HomeBusinessRetail-HomeStudentARMRetail-HomeStudentPlusARMRetail-HomeStudentRetail-HomeStudentVNextRetail-PersonalPipcRetail-PersonalRetail- -16_VisioProVolume_-VisioProRetail- -16_VisioProXVolume -16_VisioStdVolume_-VisioStdRetail- -16_VisioStdXVolume -16_WordVolume_-WordRetail- -:: Office 2019 -16_AccessRuntime2019Retail -16_Access2019Volume_-Access2019Retail- -16_Excel2019Volume_-Excel2019Retail- -16_Outlook2019Volume_-Outlook2019Retail- -16_PowerPoint2019Volume_-PowerPoint2019Retail- -16_ProjectPro2019Volume_-ProjectPro2019Retail- -16_ProjectStd2019Volume_-ProjectStd2019Retail- -16_ProPlus2019Volume_-ProPlus2019Retail-Professional2019Retail- -16_Publisher2019Volume_-Publisher2019Retail- -16_SkypeforBusiness2019Volume_-SkypeforBusiness2019Retail- -16_SkypeforBusinessEntry2019Retail -16_Standard2019Volume_-Standard2019Retail-HomeBusiness2019Retail-HomeStudentARM2019Retail-HomeStudentPlusARM2019Retail-HomeStudent2019Retail-Personal2019Retail- -16_VisioPro2019Volume_-VisioPro2019Retail- -16_VisioStd2019Volume_-VisioStd2019Retail- -16_Word2019Volume_-Word2019Retail- -:: Office 2021 -:: OneNote2021Volume KMS license is not available -16_AccessRuntime2021Retail -16_Access2021Volume_-Access2021Retail- -16_Excel2021Volume_-Excel2021Retail- -16_Outlook2021Volume_-Outlook2021Retail- -16_OneNoteFree2021Retail -16_PowerPoint2021Volume_-PowerPoint2021Retail- -16_ProjectPro2021Volume_-ProjectPro2021Retail- -16_ProjectStd2021Volume_-ProjectStd2021Retail- -16_ProPlus2021Volume_-ProPlus2021Retail-Professional2021Retail- -16_Publisher2021Volume_-Publisher2021Retail- -16_SkypeforBusiness2021Volume_-SkypeforBusiness2021Retail- -16_Standard2021Volume_-Standard2021Retail-HomeBusiness2021Retail-HomeStudent2021Retail-Personal2021Retail- -16_VisioPro2021Volume_-VisioPro2021Retail- -16_VisioStd2021Volume_-VisioStd2021Retail- -16_Word2021Volume_-Word2021Retail- -:: Office 2024 -16_Access2024Volume_-Access2024Retail- -16_Excel2024Volume_-Excel2024Retail- -16_Outlook2024Volume_-Outlook2024Retail- -16_PowerPoint2024Volume_-PowerPoint2024Retail- -16_ProjectPro2024Volume_-ProjectPro2024Retail- -16_ProjectStd2024Volume_-ProjectStd2024Retail- -16_ProPlus2024Volume_-ProPlus2024Retail- -16_SkypeforBusiness2024Volume -16_Standard2024Volume_-Home2024Retail-HomeBusiness2024Retail- -16_VisioPro2024Volume_-VisioPro2024Retail- -16_VisioStd2024Volume_-VisioStd2024Retail- -16_Word2024Volume_-Word2024Retail- -) do ( -for /f "tokens=1-3 delims=_" %%A in ("%%#") do ( - -if %1==chkprod if "%oVer%"=="%%A" if not defined foundprod ( -if /i "%%B"=="%2" set foundprod=1 -) - -if %1==getinfo if "%oVer%"=="%%A" ( -echo: %%C | find /i "-%2-" %nul% && ( -set _License=%%B -set _altoffid=%%B -) -) - -) -) -exit /b - -::======================================================================================================================================== - :ts_getedition set tsedition= @@ -12060,6 +10833,798 @@ exit /b :+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +:KMS38Activation + +:: To activate, run the script with "/KMS38" parameter or change 0 to 1 in below line +set _act=0 + +:: To remove KMS38 protection, run the script with /KMS38-RemoveProtection parameter or change 0 to 1 in below line +set _rem=0 + +:: To disable changing edition if current edition doesn't support KMS38 activation, change the value to 1 from 0 or run the script with "/KMS38-NoEditionChange" parameter +set _NoEditionChange=0 + +:: If value is changed in above lines or parameter is used then script will run in unattended mode + +::======================================================================================================================================== + +cls +color 07 +title KMS38 Activation %masver% + +set _args= +set _elev= +set _unattended=0 + +set _args=%* +if defined _args set _args=%_args:"=% +if defined _args ( +for %%A in (%_args%) do ( +if /i "%%A"=="/KMS38" set _act=1 +if /i "%%A"=="/KMS38-RemoveProtection" set _rem=1 +if /i "%%A"=="/KMS38-NoEditionChange" set _NoEditionChange=1 +if /i "%%A"=="-el" set _elev=1 +) +) + +for %%A in (%_act% %_rem% %_NoEditionChange%) do (if "%%A"=="1" set _unattended=1) + +::======================================================================================================================================== + +set _k38= +call :dk_setvar +set "specific_kms=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f" + +if %winbuild% LSS 14393 ( +%eline% +echo Unsupported OS version detected [%winbuild%]. +echo KMS38 activation is only supported on Windows 10/11/Server, build 14393 and later. +echo: +if %winbuild% LSS 10240 ( +call :dk_color %Blue% "Use TSforge activation option from the main menu." +) else ( +call :dk_color %Blue% "Use HWID activation option from the main menu." +) +goto dk_done +) + +::======================================================================================================================================== + +if %_rem%==1 goto :k_uninstall + +:k_menu + +if %_unattended%==0 ( +cls +if not defined terminal mode 76, 25 +title KMS38 Activation %masver% + +echo: +echo: +echo: +echo: +echo: ______________________________________________________ +echo: +echo [1] KMS38 Activation +echo ____________________________________________ +echo: +echo [2] Remove KM38 Protection +echo: +echo [0] %_exitmsg% +echo: ______________________________________________________ +echo: +call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard [1,2,0]" +choice /C:120 /N +set _el=!errorlevel! +if !_el!==3 exit /b +if !_el!==2 goto :k_uninstall +if !_el!==1 goto :k_menu2 +goto :k_menu +) + +::======================================================================================================================================== + +:k_menu2 + +cls +if not defined terminal ( +mode 110, 34 +if exist "%SysPath%\spp\store_test\" mode 134, 34 +) +title KMS38 Activation %masver% + +echo: +echo Initializing... +call :dk_chkmal + +if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*.mum" if not exist "%SysPath%\clipup.exe" set a_cor=1 +if not exist %SysPath%\sppsvc.exe (set _fmiss=sppsvc.exe) +if not exist %SysPath%\ClipUp.exe if not defined a_cor (set _fmiss=%_fmiss%ClipUp.exe) + +if defined _fmiss ( +%eline% +echo [%_fmiss%] file is missing, aborting... +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 +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +) +goto dk_done +) + +::======================================================================================================================================== + +set spp=SoftwareLicensingProduct +set sps=SoftwareLicensingService + +call :dk_ckeckwmic +call :dk_checksku +call :dk_product +call :dk_sppissue + +::======================================================================================================================================== + +:: Check if system is permanently activated or not + +call :dk_checkperm +if defined _perm ( +cls +echo ___________________________________________________________________________________________ +echo: +call :dk_color2 %_White% " " %Green% "%winos% is already permanently activated." +call :dk_color2 %_White% " " %Gray% "Activation is not required." +echo ___________________________________________________________________________________________ +if %_unattended%==1 goto dk_done +echo: +choice /C:10 /N /M "> [1] Activate Anyway [0] %_exitmsg% : " +if errorlevel 2 exit /b +) +cls + +::======================================================================================================================================== + +:: Check Evaluation version + +set _eval= +set _evalserv= + +if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" set _eval=1 +if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*EvalEdition~*.mum" set _evalserv=1 +if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*EvalCorEdition~*.mum" set _eval=1 & set _evalserv=1 + +if defined _eval ( +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% && ( +%eline% +echo [%winos% ^| %winbuild%] +if defined _evalserv ( +echo Server Evaluation cannot be activated. Convert it to full Server OS. +echo: +call :dk_color %Blue% "Go Back to main menu and use [Change Edition] option." +) else ( +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: +set fixes=%fixes% %mas%evaluation_editions +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" +) +goto dk_done +) +) + +::======================================================================================================================================== + +:: Check clipup.exe for the detection and activation of server cor and acor editions + +if defined a_cor ( +if not exist "!_work!\clipup.exe" ( +%eline% +echo clipup.exe doesn't exist in Server Cor/Acor [No GUI] versions. +echo The file is required for KMS38 activation. +echo Check the below page for instructions on how to activate it. +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%kms38" +goto dk_done +) +) + +:: Check file signature + +if defined a_cor ( +%psc% "if (-not (Get-AuthenticodeSignature -FilePath '!_work!\clipup.exe').IsOSBinary) {Exit 3}" %nul% +if !errorlevel!==3 ( +%eline% +echo Valid digital signature not found in clipup.exe file. +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +goto dk_done +) +) + +::======================================================================================================================================== + +set error= + +cls +echo: +call :dk_showosinfo + +::======================================================================================================================================== + +echo Initiating Diagnostic Tests... + +set "_serv=ClipSVC sppsvc KeyIso Winmgmt" + +:: Client License Service (ClipSVC) +:: Software Protection +:: CNG Key Isolation +:: Windows Management Instrumentation + +call :dk_errorcheck + +::======================================================================================================================================== + +:: Check if GVLK (KMS key) is already installed or not + +call :k_channel + +:: Detect Key + +set key= +set pkey= +set altkey= +set changekey= +set altedition= + +call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f +if defined allapps call :kms38data key +if not defined key call :k_gvlk %nul% +if defined allapps if not defined key call :kms38fallback + +if defined altkey (set key=%altkey%&set changekey=1) + +set /a UBR=0 +if %osSKU%==191 if defined altkey if defined altedition ( +for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR %nul6%') do if not errorlevel 1 set /a UBR=%%b +if %winbuild% LSS 22598 if !UBR! LSS 2788 ( +call :dk_color %Blue% "Windows must be updated to build 19044.2788 or higher for IotEnterpriseS KMS38 activation." +) +) + +if not defined key if defined notfoundaltactID ( +call :dk_color %Red% "Checking Alternate Edition for KMS38 [%altedition% Activation ID Not Found]" +) + +if not defined key if not defined _gvlk ( +echo: +echo [%winos% ^| %winbuild% ^| SKU:%osSKU%] + +if exist "%SysPath%\spp\tokens\skus\%osedition%\*GVLK*.xrm-ms" set sppks=1 + +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% +echo %mas% +) +echo: +goto dk_done +) + +::======================================================================================================================================== + +:: Install key + +echo: +if defined changekey ( +call :dk_color %Blue% "[%altedition%] edition product key will be used to enable KMS38 activation." +echo: +) + +if defined winsub ( +call :dk_color %Blue% "Windows Subscription edition [SKU ID-%slcSKU%] found. Script will activate the base edition [SKU ID-%regSKU%]." +echo: +) + +set _partial= +if not defined key ( +if %_wmic% EQU 1 for /f "tokens=2 delims==" %%# in ('wmic path %spp% where "ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and PartialProductKey<>null AND LicenseDependsOn is NULL" Get PartialProductKey /value %nul6%') do set "_partial=%%#" +if %_wmic% EQU 0 for /f "tokens=2 delims==" %%# in ('%psc% "(([WMISEARCHER]'SELECT PartialProductKey FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).PartialProductKey | %% {echo ('PartialProductKey='+$_)}" %nul6%') do set "_partial=%%#" +call echo Checking Installed Product Key [Partial Key - %%_partial%%] [Volume:GVLK] +) + +if defined key ( +set generickey=1 +call :dk_inskey "[%key%]" +) + +::======================================================================================================================================== + +:: Check activation ID for setting specific KMS host + +set app= +if %_wmic% EQU 1 for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL AND LicenseDependsOn is NULL) get ID /VALUE" %nul6%') do call set "app=%%a" +if %_wmic% EQU 0 for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND Description like ''%%KMSCLIENT%%'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).ID | %% {echo ('ID='+$_)}" %nul6%') do call set "app=%%a" + +if not defined app ( +call :dk_color %Red% "Checking Installed GVLK Activation ID [Not Found] Aborting..." +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +goto :dk_done +) + +::======================================================================================================================================== + +:: Set specific KMS host to Local Host +:: By doing this, global KMS IP can not replace KMS38 activation but can be used with Office and other Windows Editions + +echo: +%nul% reg delete "HKLM\%specific_kms%" /f +%nul% reg delete "HKU\S-1-5-20\%specific_kms%" /f + +%nul% reg query "HKLM\%specific_kms%" && ( +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regdel\:.*';iex ($f[1])" +%nul% reg delete "HKLM\%specific_kms%" /f +) + +set k_error= +%nul% reg add "HKLM\%specific_kms%\%app%" /f /v KeyManagementServiceName /t REG_SZ /d "127.0.0.2" || set k_error=1 +%nul% reg add "HKLM\%specific_kms%\%app%" /f /v KeyManagementServicePort /t REG_SZ /d "1688" || set k_error=1 + +if not defined k_error ( +echo Adding Specific KMS Host [LocalHost 127.0.0.2] [Successful] +) else ( +call :dk_color %Red% "Adding Specific KMS Host [LocalHost 127.0.0.2] [Failed]" +) + +::======================================================================================================================================== + +:: Copy clipup.exe to System32 directory to activate Server Cor/Acor editions + +if defined a_cor ( +set "_clipup=%systemroot%\System32\clipup.exe" +pushd "!_work!\" +copy /y /b "ClipUp.exe" "!_clipup!" %nul% +popd + +echo: +if exist "!_clipup!" ( +echo Copying clipup.exe File to [%systemroot%\System32\] [Successful] +) else ( +call :dk_color %Red% "Copying clipup.exe File to [%systemroot%\System32\] [Failed] Aborting..." +goto :k_final +) +) + +::======================================================================================================================================== + +:: Generate GenuineTicket.xml and apply +:: In some cases clipup -v -o method fails and in some cases service restart method fails as well +:: To maximize success rate and get better error details, script will install tickets two times (service restart + clipup -v -o) + +set "tdir=%ProgramData%\Microsoft\Windows\ClipSVC\GenuineTicket" +if not exist "%tdir%\" md "%tdir%\" %nul% + +if exist "%tdir%\Genuine*" del /f /q "%tdir%\Genuine*" %nul% +if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul% +if exist "%ProgramData%\Microsoft\Windows\ClipSVC\Install\Migration\*" del /f /q "%ProgramData%\Microsoft\Windows\ClipSVC\Install\Migration\*" %nul% + +:: Signature value is as it is, it's not encoded +:: Session ID is in Base64 encoded format. It's decoded value is "OSMajorVersion=5;OSMinorVersion=1;OSPlatformId=2;PP=0;GVLKExp=2038-01-19T03:14:07Z;DownlevelGenuineState=1;" +:: Check mass grave [.] dev/kms38#manual-activation to see how it's generated + +set "signature=C52iGEoH+1VqzI6kEAqOhUyrWuEObnivzaVjyef8WqItVYd/xGDTZZ3bkxAI9hTpobPFNJyJx6a3uriXq3HVd7mlXfSUK9ydeoUdG4eqMeLwkxeb6jQWJzLOz41rFVSMtBL0e+ycCATebTaXS4uvFYaDHDdPw2lKY8ADj3MLgsA=" +set "sessionId=TwBTAE0AYQBqAG8AcgBWAGUAcgBzAGkAbwBuAD0ANQA7AE8AUwBNAGkAbgBvAHIAVgBlAHIAcwBpAG8AbgA9ADEAOwBPAFMAUABsAGEAdABmAG8AcgBtAEkAZAA9ADIAOwBQAFAAPQAwADsARwBWAEwASwBFAHgAcAA9ADIAMAAzADgALQAwADEALQAxADkAVAAwADMAOgAxADQAOgAwADcAWgA7AEQAbwB3AG4AbABlAHYAZQBsAEcAZQBuAHUAaQBuAGUAUwB0AGEAdABlAD0AMQA7AAAA" +1.0OA3xOriginalProductId=;OA3xOriginalProductKey=;SessionId=%sessionId%;TimeStampClient=2022-10-11T12:00:00Z%signature%" >"%tdir%\GenuineTicket" + +copy /y /b "%tdir%\GenuineTicket" "%tdir%\GenuineTicket.xml" %nul% + +if not exist "%tdir%\GenuineTicket.xml" ( +call :dk_color %Red% "Generating GenuineTicket.xml [Failed, aborting...]" +if exist "%tdir%\Genuine*" del /f /q "%tdir%\Genuine*" %nul% +goto :k_final +) else ( +echo Generating GenuineTicket.xml [Successful] +) + +set "_xmlexist=if exist "%tdir%\GenuineTicket.xml"" + +:: Stop sppsvc + +%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null" + +%_xmlexist% ( +%psc% "Start-Job { Restart-Service ClipSVC } | Wait-Job -Timeout 20 | Out-Null" +%_xmlexist% timeout /t 2 %nul% +%_xmlexist% timeout /t 2 %nul% + +%_xmlexist% ( +set error=1 +if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul% +call :dk_color %Gray% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]" +) +) + +copy /y /b "%tdir%\GenuineTicket" "%tdir%\GenuineTicket.xml" %nul% +clipup -v -o + +set rebuildinfo= + +if not exist %ProgramData%\Microsoft\Windows\ClipSVC\tokens.dat ( +set error=1 +set rebuildinfo=1 +call :dk_color %Red% "Checking ClipSVC tokens.dat [Not Found]" +) + +%_xmlexist% ( +set error=1 +set rebuildinfo=1 +call :dk_color %Red% "Installing GenuineTicket.xml [Failed With clipup -v -o]" +) + +if exist "%ProgramData%\Microsoft\Windows\ClipSVC\Install\Migration\*.xml" ( +set error=1 +set rebuildinfo=1 +call :dk_color %Red% "Checking Ticket Migration [Failed]" +) + +if not defined showfix if defined rebuildinfo ( +set showfix=1 +call :dk_color %Blue% "%_fixmsg%" +) + +if exist "%tdir%\Genuine*" del /f /q "%tdir%\Genuine*" %nul% + +::========================================================================================================================================== + +call :dk_product + +echo: +echo Activating... +echo: + +call :k_checkexp +if defined _k38 ( +call :k_actinfo +goto :k_final +) + +:: Clear 180 Days KMS Activation lock with Windows SKU specific rearm and without the need to restart the system + +if %_wmic% EQU 1 wmic path %spp% where ID='%app%' call ReArmsku %nul% +if %_wmic% EQU 0 %psc% "$null=([WMI]'%spp%=''%app%''').ReArmsku()" %nul% + +if %errorlevel%==0 ( +echo Applying SKU-ID Rearm [Successful] +) else ( +call :dk_color %Red% "Applying SKU-ID Rearm [Failed]" +) +call :dk_refresh + +echo: +call :k_checkexp +if defined _k38 ( +call :k_actinfo +goto :k_final +) + +call :dk_color %Red% "Activation Failed" +if not defined error call :dk_color %Blue% "%_fixmsg%" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" + +::======================================================================================================================================== + +:k_final + +:: Remove the specific KMS host (LocalHost) added by the script if activation is not completed + +echo: +if not defined _k38 ( +%nul% reg delete "HKLM\%specific_kms%" /f +%nul% reg delete "HKU\S-1-5-20\%specific_kms%" /f +%nul% reg query "HKLM\%specific_kms%" && ( +call :dk_color %Red% "Removing the Added Specific KMS Host [Failed]" +) || ( +echo Removing the Added Specific KMS Host [Successful] +) +) + +:: Protect KMS38 if opted by the user and conditions are correct + +if defined _k38 ( +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regdel\:.*';& ([ScriptBlock]::Create($f[1])) -protect" +%nul% reg delete "HKLM\%specific_kms%" /f +%nul% reg query "HKLM\%specific_kms%" && ( +echo Protect KMS38 From KMS [Successful] [Locked a Registry Key] +) || ( +call :dk_color %Red% "Protect KMS38 From KMS [Failed to Lock a Registry Key]" +) +) + +:: clipup.exe does not exist in server cor and acor editions by default, it was copied there with this script + +if defined a_cor if exist "%_clipup%" del /f /q "%_clipup%" %nul% + +if defined a_cor ( +if exist "%_clipup%" ( +call :dk_color %Red% "Deleting Copied clipup.exe File [Failed]" +) else ( +echo Deleting Copied clipup.exe File [Successful] +) +) + +for %%# in (407) do if %osSKU%==%%# ( +call :dk_color %Red% "%winos% does not support activation on non-azure platforms." +) + +:: Trigger reevaluation of SPP's Scheduled Tasks + +if defined _k38 ( +call :dk_reeval %nul% +) +goto :dk_done + +::======================================================================================================================================== + +:k_uninstall + +cls +if not defined terminal mode 99, 28 +title Remove KMS38 Protection %masver% + +%nul% reg delete "HKLM\%specific_kms%" /f +%nul% reg delete "HKU\S-1-5-20\%specific_kms%" /f + +%nul% reg query "HKLM\%specific_kms%" && ( +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regdel\:.*';iex ($f[1])" +%nul% reg delete "HKLM\%specific_kms%" /f +) + +echo: +%nul% reg query "HKLM\%specific_kms%" && ( +call :dk_color %Red% "Removing Specific KMS Host [Failed]" +) || ( +echo Removing Specific KMS Host [Successful] +) + +goto :dk_done + +::======================================================================================================================================== + +:: This code runs to protect/undo below registry key for KMS38 protection +:: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f + +:: KMS38 protection stops 180 days KMS Activation from replacing KMS38 activation + +:regdel: +param ( + [switch]$protect +) + +$SID = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544') +$Admin = ($SID.Translate([System.Security.Principal.NTAccount])).Value + +if($protect) { +$ruleArgs = @("$Admin", "Delete, SetValue", "ContainerInherit", "None", "Deny") +} else { +$ruleArgs = @("$Admin", "FullControl", "Allow") +} + +$path = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f' +$key = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64').OpenSubKey($path, 'ReadWriteSubTree', 'ChangePermissions') +$acl = $key.GetAccessControl() + +$rule = [System.Security.AccessControl.RegistryAccessRule]::new.Invoke($ruleArgs) +$acl.ResetAccessRule($rule) +$key.SetAccessControl($acl) +:regdel: + +::======================================================================================================================================== + +:: Check KMS activation status + +:k_actinfo + +set xpr= +for /f "tokens=* delims=" %%# in ('%psc% "$([DateTime]::Now.addMinutes(%gpr%)).ToString('yyyy-MM-dd HH:mm:ss')" %nul6%') do set "xpr=%%#" +call :dk_color %Green% "%winos% is activated till !xpr!" +exit /b + +:: Check remaining KMS activation grace period + +:k_checkexp + +set gpr=0 +if %_wmic% EQU 1 for /f "tokens=2 delims==" %%# in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL AND LicenseDependsOn is NULL) get GracePeriodRemaining /VALUE" %nul6%') do set "gpr=%%#" +if %_wmic% EQU 0 for /f "tokens=2 delims==" %%# in ('%psc% "(([WMISEARCHER]'SELECT GracePeriodRemaining FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND Description like ''%%KMSCLIENT%%'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).GracePeriodRemaining | %% {echo ('GracePeriodRemaining='+$_)}" %nul6%') do set "gpr=%%#" +if %gpr% GTR 259200 (set _k38=1) else (set _k38=) +exit /b + +:: Get Windows installed key channel + +:k_channel + +set _gvlk= +if %_wmic% EQU 1 for /f "tokens=2 delims==" %%# in ('wmic path %spp% where "ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL and Description like '%%KMSCLIENT%%'" Get Name /value %nul6%') do (echo %%# findstr /i "Windows" %nul1% && set _gvlk=1) +if %_wmic% EQU 0 for /f "tokens=2 delims==" %%# in ('%psc% "(([WMISEARCHER]'SELECT Name FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL and Description like ''%%KMSCLIENT%%''').Get()).Name | %% {echo ('Name='+$_)}" %nul6%') do (echo %%# findstr /i "Windows" %nul1% && set _gvlk=1) +exit /b + +::======================================================================================================================================== + +:: Get Product Key from pkeyhelper.dll for future new editions +:: It works on Windows 10 1803 (17134) and later builds. + +:k_pkey + +call :dk_reflection + +set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SkuGetProductKeyForEdition', 'pkeyhelper.dll', 'Public, Static', 1, [int], @([int], [String], [String].MakeByRefType(), [String].MakeByRefType()), 1, 3); +set d1=%d1% $out = ''; [void]$TypeBuilder.CreateType()::SkuGetProductKeyForEdition(%1, %2, [ref]$out, [ref]$null); $out + +set pkey= +for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkey=%%a) +exit /b + +:: Get channel name for the key which was extracted from pkeyhelper.dll + +:k_pkeychannel + +set k=%1 +set m=[Runtime.InteropServices.Marshal] +set p=%SysPath%\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms + +set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('PidGenX', 'pidgenx.dll', 'Public, Static', 1, [int], @([String], [String], [String], [int], [IntPtr], [IntPtr], [IntPtr]), 1, 3); +set d1=%d1% $r = [byte[]]::new(0x04F8); $r[0] = 0xF8; $r[1] = 0x04; $f = %m%::AllocHGlobal(0x04F8); %m%::Copy($r, 0, $f, 0x04F8); +set d1=%d1% [void]$TypeBuilder.CreateType()::PidGenX('%k%', '%p%', '00000', 0, 0, 0, $f); %m%::Copy($f, $r, 0, 0x04F8); %m%::FreeHGlobal($f); [Text.Encoding]::Unicode.GetString($r, 1016, 128) + +set pkeychannel= +for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkeychannel=%%a) +exit /b + +:k_gvlk + +for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b +for %%# in (Volume:GVLK) do ( +call :k_pkey %osSKU% '%%#' +if defined pkey call :k_pkeychannel !pkey! +if /i "!pkeychannel!"=="%%#" ( +set key=!pkey! +exit /b +) +) +exit /b + +::======================================================================================================================================== + +:: 1st column = Activation ID +:: 2nd column = GVLK (Generic volume licensing key) +:: 3rd column = SKU ID +:: 4th column = WMI Edition ID (For reference only) +:: 5th column = Build Branch name incase same Edition ID is used in different OS versions with different key (For reference only) +:: Separator = "_" + +:kms38data + +set f= +for %%# in ( +:: Windows 10/11 +73111121-5638-40f6-bc11-f1d7b0d64300_NPPR9-FWDCX-D2C8J-H872K-2Y%f%T43___4_Enterprise +e272e3e2-732f-4c65-a8f0-484747d0d947_DPH2V-TTNVB-4X9Q3-TJR4H-KH%f%JW4__27_EnterpriseN +2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX__48_Professional +a80b5abf-76ad-428b-b05d-a47d2dffeebf_MH37W-N47XK-V7XM9-C7227-GC%f%QG9__49_ProfessionalN +7b9e1751-a8da-4f75-9560-5fadfe3d8e38_3KHY7-WNT83-DGQKR-F7HPR-84%f%4BM__98_CoreN +a9107544-f4a0-4053-a96a-1479abdef912_PVMJN-6DFY6-9CCP6-7BKTT-D3%f%WVR__99_CoreCountrySpecific +cd918a57-a41b-4c82-8dce-1a538e221a83_7HNRX-D7KGG-3K4RQ-4WPJ4-YT%f%DFH_100_CoreSingleLanguage +58e97c99-f377-4ef1-81d5-4ad5522b5fd8_TX9XD-98N7V-6WMQ6-BX7FG-H8%f%Q99_101_Core +e0c42288-980c-4788-a014-c080d2e1926e_NW6C2-QMPVW-D7KKK-3GKT6-VC%f%FB2_121_Education +3c102355-d027-42c6-ad23-2e7ef8a02585_2WH4N-8QGBV-H22JP-CT43Q-MD%f%WWJ_122_EducationN +32d2fab3-e4a8-42c2-923b-4bf4fd13e6ee_M7XTQ-FN8P6-TTKYV-9D4CC-J4%f%62D_125_EnterpriseS_RS5,VB,Ge +2d5a5a60-3040-48bf-beb0-fcd770c20ce0_DCPHK-NFMTC-H88MJ-PFHPY-QJ%f%4BJ_125_EnterpriseS_RS1 +7b51a46c-0c04-4e8f-9af4-8496cca90d5e_WNMTR-4C88C-JK8YV-HQ7T2-76%f%DF9_125_EnterpriseS_TH1 +7103a333-b8c8-49cc-93ce-d37c09687f92_92NFX-8DJQP-P6BBQ-THF9C-7C%f%G2H_126_EnterpriseSN_RS5,VB,Ge +9f776d83-7156-45b2-8a5c-359b9c9f22a3_QFFDN-GRT3P-VKWWX-X7T3R-8B%f%639_126_EnterpriseSN_RS1 +87b838b7-41b6-4590-8318-5797951d8529_2F77B-TNFGY-69QQF-B8YKP-D6%f%9TJ_126_EnterpriseSN_TH1 +82bbc092-bc50-4e16-8e18-b74fc486aec3_NRG8B-VKK3Q-CXVCJ-9G2XF-6Q%f%84J_161_ProfessionalWorkstation +4b1571d3-bafb-4b40-8087-a961be2caf65_9FNHH-K3HBT-3W4TD-6383H-6X%f%YWF_162_ProfessionalWorkstationN +3f1afc82-f8ac-4f6c-8005-1d233e606eee_6TP4R-GNPTD-KYYHQ-7B7DP-J4%f%47Y_164_ProfessionalEducation +5300b18c-2e33-4dc2-8291-47ffcec746dd_YVWGF-BXNMC-HTQYQ-CPQ99-66%f%QFC_165_ProfessionalEducationN +e0b2d383-d112-413f-8a80-97f373a5820c_YYVX9-NTFWV-6MDM3-9PT4T-4M%f%68B_171_EnterpriseG +e38454fb-41a4-4f59-a5dc-25080e354730_44RPN-FTY23-9VTTB-MP9BX-T8%f%4FV_172_EnterpriseGN +ec868e65-fadf-4759-b23e-93fe37f2cc29_CPWHC-NT2C7-VYW78-DHDB2-PG%f%3GK_175_ServerRdsh_RS5 +e4db50ea-bda1-4566-b047-0ca50abc6f07_7NBT4-WGBQX-MP4H7-QXFF8-YP%f%3KX_175_ServerRdsh_RS3 +0df4f814-3f57-4b8b-9a9d-fddadcd69fac_NBTWJ-3DR69-3C4V8-C26MC-GQ%f%9M6_183_CloudE +59eb965c-9150-42b7-a0ec-22151b9897c5_KBN8V-HFGQ4-MGXVD-347P6-PD%f%QGT_191_IoTEnterpriseS_VB,NI +d30136fc-cb4b-416e-a23d-87207abc44a9_6XN7V-PCBDC-BDBRH-8DQY7-G6%f%R44_202_CloudEditionN +ca7df2e3-5ea0-47b8-9ac1-b1be4d8edd69_37D7F-N49CB-WQR8W-TBJ73-FM%f%8RX_203_CloudEdition +:: Windows 2016/19/22/25 LTSC/SAC +7dc26449-db21-4e09-ba37-28f2958506a6_TVRH6-WHNXV-R9WG3-9XRFY-MY%f%832___7_ServerStandard_Ge +9bd77860-9b31-4b7b-96ad-2564017315bf_VDYBN-27WPP-V4HQT-9VMD4-VM%f%K7H___7_ServerStandard_FE +de32eafd-aaee-4662-9444-c1befb41bde2_N69G4-B89J2-4G8F4-WWYCC-J4%f%64C___7_ServerStandard_RS5 +8c1c5410-9f39-4805-8c9d-63a07706358f_WC2BQ-8NRM3-FDDYY-2BFGV-KH%f%KQY___7_ServerStandard_RS1 +c052f164-cdf6-409a-a0cb-853ba0f0f55a_D764K-2NDRG-47T6Q-P8T8W-YP%f%6DF___8_ServerDatacenter_Ge +ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae03_WX4NM-KYWYW-QJJR4-XV3QB-6V%f%M33___8_ServerDatacenter_FE +34e1ae55-27f8-4950-8877-7a03be5fb181_WMDGN-G9PQG-XVVXX-R3X43-63%f%DFG___8_ServerDatacenter_RS5 +21c56779-b449-4d20-adfc-eece0e1ad74b_CB7KF-BWN84-R7R2Y-793K2-8X%f%DDG___8_ServerDatacenter_RS1 +034d3cbb-5d4b-4245-b3f8-f84571314078_WVDHN-86M7X-466P6-VHXV7-YY%f%726__50_ServerSolution_RS5 +2b5a1b0f-a5ab-4c54-ac2f-a6d94824a283_JCKRF-N37P4-C2D82-9YXRT-4M%f%63B__50_ServerSolution_RS1 +7b4433f4-b1e7-4788-895a-c45378d38253_QN4C6-GBJD2-FB422-GHWJK-GJ%f%G2R_110_ServerCloudStorage +8de8eb62-bbe0-40ac-ac17-f75595071ea3_GRFBW-QNDC4-6QBHG-CCK3B-2P%f%R88_120_ServerARM64_RS5 +43d9af6e-5e86-4be8-a797-d072a046896c_K9FYF-G6NCK-73M32-XMVPY-F9%f%DRR_120_ServerARM64_RS4 +39e69c41-42b4-4a0a-abad-8e3c10a797cc_QFND9-D3Y9C-J3KKY-6RPVP-2D%f%PYV_145_ServerDatacenterACor_FE +90c362e5-0da1-4bfd-b53b-b87d309ade43_6NMRW-2C8FM-D24W7-TQWMY-CW%f%H2D_145_ServerDatacenterACor_RS5 +e49c08e7-da82-42f8-bde2-b570fbcae76c_2HXDN-KRXHB-GPYC7-YCKFJ-7F%f%VDG_145_ServerDatacenterACor_RS3 +f5e9429c-f50b-4b98-b15c-ef92eb5cff39_67KN8-4FYJW-2487Q-MQ2J7-4C%f%4RG_146_ServerStandardACor_FE +73e3957c-fc0c-400d-9184-5f7b6f2eb409_N2KJX-J94YW-TQVFB-DG9YT-72%f%4CC_146_ServerStandardACor_RS5 +61c5ef22-f14f-4553-a824-c4b31e84b100_PTXN8-JFHJM-4WC78-MPCBR-9W%f%4KR_146_ServerStandardACor_RS3 +45b5aff2-60a0-42f2-bc4b-ec6e5f7b527e_FCNV3-279Q9-BQB46-FTKXX-9H%f%PRH_168_ServerAzureCor_Ge +8c8f0ad3-9a43-4e05-b840-93b8d1475cbc_6N379-GGTMK-23C6M-XVVTC-CK%f%FRQ_168_ServerAzureCor_FE +a99cc1f0-7719-4306-9645-294102fbff95_FDNH6-VW9RW-BXPJ7-4XTYG-23%f%9TB_168_ServerAzureCor_RS5 +3dbf341b-5f6c-4fa7-b936-699dce9e263f_VP34G-4NPPG-79JTQ-864T4-R3%f%MQX_168_ServerAzureCor_RS1 +c2e946d1-cfa2-4523-8c87-30bc696ee584_XGN3F-F394H-FD2MY-PP6FD-8M%f%CRC_407_ServerTurbine_Ge +19b5e0fb-4431-46bc-bac1-2f1873e4ae73_NTBV8-9K7Q8-V27C6-M2BTV-KH%f%MXV_407_ServerTurbine_RS5 +) do ( +for /f "tokens=1-5 delims=_" %%A in ("%%#") do if %osSKU%==%%C ( +if %1==key if not defined key echo "!allapps!" | find /i "%%A" %nul1% && set key=%%B +) +) +exit /b + +::======================================================================================================================================== + +:: Below code is used to get alternate edition name and key if current edition doesn't support KMS38 activation + +:: 1st column = Current SKU ID +:: 2nd column = Current Edition Name +:: 3rd column = Current Edition Activation ID +:: 4th column = Alternate Edition Activation ID +:: 5th column = Alternate Edition GVLK +:: 6th column = Alternate Edition Name +:: Separator = _ + + +:kms38fallback + +set notfoundaltactID= +if %_NoEditionChange%==1 exit /b + +for %%# in ( +188_IoTEnterprise__________________8ab9bdd1-1f67-4997-82d9-8878520837d9_73111121-5638-40f6-bc11-f1d7b0d64300_NPPR9-FWDCX-D2C8J-H872K-2Y%f%T43_Enterprise +206_IoTEnterpriseK_________________80083eae-7031-4394-9e88-4901973d56fe_73111121-5638-40f6-bc11-f1d7b0d64300_NPPR9-FWDCX-D2C8J-H872K-2Y%f%T43_Enterprise +191_IoTEnterpriseS-2021____________ed655016-a9e8-4434-95d9-4345352c2552_32d2fab3-e4a8-42c2-923b-4bf4fd13e6ee_M7XTQ-FN8P6-TTKYV-9D4CC-J4%f%62D_EnterpriseS-2021 +205_IoTEnterpriseSK________________d4f9b41f-205c-405e-8e08-3d16e88e02be_59eb965c-9150-42b7-a0ec-22151b9897c5_KBN8V-HFGQ4-MGXVD-347P6-PD%f%QGT_IoTEnterpriseS +138_ProfessionalSingleLanguage_____a48938aa-62fa-4966-9d44-9f04da3f72f2_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional +139_ProfessionalCountrySpecific____f7af7d09-40e4-419c-a49b-eae366689ebd_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional +139_ProfessionalCountrySpecific-Zn_01eb852c-424d-4060-94b8-c10d799d7364_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional +) do ( +for /f "tokens=1-6 delims=_" %%A in ("%%#") do if %osSKU%==%%A ( +echo "!allapps!" | find /i "%%C" %nul1% && ( +echo "!allapps!" | find /i "%%D" %nul1% && ( +set altkey=%%E +set altedition=%%F +) || ( +set altedition=%%F +set notfoundaltactID=1 +) +) +) +) +exit /b + +:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + :KMSActivation :: To activate Windows with K-M-S activation, run the script with "/K-Windows" parameter or change 0 to 1 in below line @@ -12216,8 +11781,8 @@ 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%in-place_repair_upgrade -call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) goto dk_done ) @@ -12335,7 +11900,7 @@ set altedition= call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f if defined allapps call :ksdata winkey if not defined key call :k_gvlk %nul% -if defined allapps if not defined key call :kmsfallback +if defined allapps if not defined key call :kms38fallback if defined altkey (set key=%altkey%&set changekey=1) @@ -12497,7 +12062,7 @@ call :dk_color %Red% "Checking Installed Office [Not Found]" if defined ohub ( echo: -echo You only have the Office Dashboard app installed. You need to install the full version of Office. +echo You have only Office dashboard app installed, you need to install full Office version. ) call :dk_color %Blue% "Download and install Office from below URL and try again." set fixes=%fixes% %mas%genuine-installation-media @@ -12589,7 +12154,6 @@ set error=1 goto :ks_starto16c2r ) -call :oh_expiredpreview 2013 if "%_actprojvis%"=="0" call :oh_fixprids call :ks_process @@ -12630,7 +12194,6 @@ set error=1 goto :ks_startmsi ) -call :oh_expiredpreview 2016 2019 2021 2024 if "%_actprojvis%"=="0" call :oh_fixprids call :ks_process @@ -12656,7 +12219,7 @@ call :oh_licrefresh :ks_activate :: Opt out of sending KMSclient activation data to Microsoft -:: https://learn.microsoft.com/en-us/windows/privacy/manage-connections-from-windows-operating-system-components-to-microsoft-services#19-software-protection-platform +:: https://learn.microsoft.com/windows/privacy/manage-connections-from-windows-operating-system-components-to-microsoft-services#19-software-protection-platform if %winbuild% GEQ 9600 ( reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform" /v NoGenTicket /t REG_DWORD /d 1 /f %nul% @@ -12711,7 +12274,7 @@ if %winbuild% GEQ 9200 ( for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" set "_C16R=1" for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath /reg:32" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" set "_C16R=1" if defined _C16R ( -REM mass{}grave{dot}dev/office-license-is-not-genuine +REM mass grave[.]dev/office-license-is-not-genuine set _server=10.0.0.10 call :_taskregserv echo Keeping the non-existent IP address 10.0.0.10 as %KS% Server. @@ -12724,7 +12287,7 @@ echo Cleared %KS% Server from the registry. ) ) -:: https://learn.microsoft.com/en-us/azure/virtual-desktop/windows-10-multisession-faq +:: https://learn.microsoft.com/azure/virtual-desktop/windows-10-multisession-faq if %_actwin%==1 for %%# in (407) do if %osSKU%==%%# ( call :dk_color %Red% "%winos% does not support activation on non-azure platforms." @@ -12878,10 +12441,6 @@ call :ksdata getinfo !_prod! if defined _altoffid ( set _License=!_altoffid! echo Converting Retail To Volume [!_prod! To !_altoffid!] -echo %%# | find /i "O365" %nul% && ( -if "%oVer%"=="15" (call :dk_color %Gray% "Mondo 2013 is equivalent to O365 [15.0 version] in terms of the latest features.") -if "%oVer%"=="16" (call :dk_color %Gray% "Mondo 2016 is equivalent to O365 in terms of the latest features.") -) set _prod=!_altoffid! call :ks_osppready ) @@ -12978,9 +12537,6 @@ call :ks_clearstuff set error_=9 echo Failed to completely clear %KS% Cache. reg query "HKLM\%SPPk%\%_wApp%" /s %nul2% | findstr /i "127.0.0.2" %nul1% && echo KMS38 activation is locked. -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: ) || ( echo Cleared %KS% Cache successfully. ) @@ -12996,10 +12552,6 @@ echo %uline% echo %uline% echo: call :dk_color %Green% "Online %KS% has been successfully uninstalled." -echo: -call :dk_color %Gray% "If you want to reset the activation status," -call :dk_color %Blue% "%_fixmsg%" -echo: echo %uline% ) @@ -13056,7 +12608,8 @@ exit /b ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -13096,7 +12649,7 @@ set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowe set _tserror= set winbuild=1 set "nul=>nul 2>&1" -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set psc=powershell.exe -nop -c set _slexe=sppsvc.exe& set _slser=sppsvc @@ -13549,8 +13102,8 @@ set srvlist= set -= set "srvlist=kms.03%-%k.org kms-default.cangs%-%hui.net kms.six%-%yin.com kms.moe%-%club.org kms.cgt%-%soft.com" -set "srvlist=%srvlist% kms.id%-%ina.cn kms.moe%-%yuuko.com xinch%-%eng213618.cn kms.lol%-%i.best kms.mc%-%06.net" -set "srvlist=%srvlist% kms.0%-%t.net.cn win.k%-%ms.pub kms.wx%-%lost.com kms.moe%-%yuuko.top kms.gh%-%xi.com" +set "srvlist=%srvlist% kms.id%-%ina.cn kms.moe%-%yuuko.com xinch%-%eng213618.cn kms.lol%-%i.best kms.my%-%ds.cloud" +set "srvlist=%srvlist% kms.0%-%t.net.cn win.k%-%ms.pub kms.wx%-%lost.com kms.moe%-%yuuko.top kms.gh%-%pym.com" set n=1 for %%a in (%srvlist%) do (set %%a=&set server!n!=%%a&set /a n+=1) @@ -13609,7 +13162,7 @@ if not defined _int (s%nil%cht%nil%asks /cre%nil%ate /tn "Activation-Run_Once" / if exist "%_temp%\.*" rmdir /s /q "%_temp%\" %nul% call :ks_createInfo.txt -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split \":_extracttask\:.*`r`n\"; [io.file]::WriteAllText('%_dest%\Activation_task.cmd', '@::%randguid%' + [Environment]::NewLine + $f[1].Trim(), [System.Text.Encoding]::ASCII)" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split \":_extracttask\:.*`r`n\"; [io.file]::WriteAllText('%_dest%\Activation_task.cmd', '@::%randguid%' + [Environment]::NewLine + $f[1].Trim(), [System.Text.Encoding]::ASCII)" ::======================================================================================================================================== @@ -13639,7 +13192,7 @@ exit /b :ks_RenExport -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('%~2',$f[1].Trim(),[System.Text.Encoding]::%~3);" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('%~2',$f[1].Trim(),[System.Text.Encoding]::%~3);" exit /b ::======================================================================================================================================== @@ -13664,7 +13217,8 @@ echo ___________________________________________________________________________ echo: echo This Script is a part of MAS project. echo: -echo Homepage: mass%w%grave%w%.dev +echo Homepage: mass grave[.]dev +echo Email: mas.help@outlook.com )>"%_dest%\Info.txt" exit /b @@ -13908,63 +13462,6 @@ exit /b ::======================================================================================================================================== -:: Get Windows installed key channel - -:k_channel - -set _gvlk= -if %_wmic% EQU 1 for /f "tokens=2 delims==" %%# in ('wmic path %spp% where "ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL and Description like '%%KMSCLIENT%%'" Get Name /value %nul6%') do (echo %%# findstr /i "Windows" %nul1% && set _gvlk=1) -if %_wmic% EQU 0 for /f "tokens=2 delims==" %%# in ('%psc% "(([WMISEARCHER]'SELECT Name FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL and Description like ''%%KMSCLIENT%%''').Get()).Name | %% {echo ('Name='+$_)}" %nul6%') do (echo %%# findstr /i "Windows" %nul1% && set _gvlk=1) -exit /b - - -::======================================================================================================================================== - -:: Get Product Key from pkeyhelper.dll for future new editions -:: It works on Windows 10 1803 (17134) and later builds. - -:k_pkey - -call :dk_reflection - -set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SkuGetProductKeyForEdition', 'pkeyhelper.dll', 'Public, Static', 1, [int], @([int], [String], [String].MakeByRefType(), [String].MakeByRefType()), 1, 3); -set d1=%d1% $out = ''; [void]$TypeBuilder.CreateType()::SkuGetProductKeyForEdition(%1, %2, [ref]$out, [ref]$null); $out - -set pkey= -for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkey=%%a) -exit /b - -:: Get channel name for the key which was extracted from pkeyhelper.dll - -:k_pkeychannel - -set k=%1 -set m=[Runtime.InteropServices.Marshal] -set p=%SysPath%\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms - -set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('PidGenX', 'pidgenx.dll', 'Public, Static', 1, [int], @([String], [String], [String], [int], [IntPtr], [IntPtr], [IntPtr]), 1, 3); -set d1=%d1% $r = [byte[]]::new(0x04F8); $r[0] = 0xF8; $r[1] = 0x04; $f = %m%::AllocHGlobal(0x04F8); %m%::Copy($r, 0, $f, 0x04F8); -set d1=%d1% [void]$TypeBuilder.CreateType()::PidGenX('%k%', '%p%', '00000', 0, 0, 0, $f); %m%::Copy($f, $r, 0, 0x04F8); %m%::FreeHGlobal($f); [Text.Encoding]::Unicode.GetString($r, 1016, 128) - -set pkeychannel= -for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkeychannel=%%a) -exit /b - -:k_gvlk - -for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b -for %%# in (Volume:GVLK) do ( -call :k_pkey %osSKU% '%%#' -if defined pkey call :k_pkeychannel !pkey! -if /i "!pkeychannel!"=="%%#" ( -set key=!pkey! -exit /b -) -) -exit /b - -::======================================================================================================================================== - :: 1st column = Office version number :: 2nd column = Activation ID :: 3rd column = Product ID from branding.xml @@ -14439,44 +13936,6 @@ set _allactid=!_allactid! %%A ) exit /b -::======================================================================================================================================== - -:: Below code is used to get alternate edition name and key if current edition doesn't support K-M-S activation - -:: 1st column = Current SKU ID -:: 2nd column = Current Edition Name -:: 3rd column = Current Edition Activation ID -:: 4th column = Alternate Edition Activation ID -:: 5th column = Alternate Edition GVLK -:: 6th column = Alternate Edition Name -:: Separator = _ - - -:kmsfallback - -set notfoundaltactID= -if %_NoEditionChange%==1 exit /b - -for %%# in ( -205_IoTEnterpriseSK________________d4f9b41f-205c-405e-8e08-3d16e88e02be_59eb965c-9150-42b7-a0ec-22151b9897c5_KBN8V-HFGQ4-MGXVD-347P6-PD%f%QGT_IoTEnterpriseS -138_ProfessionalSingleLanguage_____a48938aa-62fa-4966-9d44-9f04da3f72f2_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional -139_ProfessionalCountrySpecific____f7af7d09-40e4-419c-a49b-eae366689ebd_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional -139_ProfessionalCountrySpecific-Zn_01eb852c-424d-4060-94b8-c10d799d7364_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional -) do ( -for /f "tokens=1-6 delims=_" %%A in ("%%#") do if %osSKU%==%%A ( -echo "!allapps!" | find /i "%%C" %nul1% && ( -echo "!allapps!" | find /i "%%D" %nul1% && ( -set altkey=%%E -set altedition=%%F -) || ( -set altedition=%%F -set notfoundaltactID=1 -) -) -) -) -exit /b - :+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ :check_actstatus @@ -14487,7 +13946,7 @@ mode 100, 36 %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=35;$B.Height=300;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}" %nul% ) -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':sppmgr\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[IO.File]::ReadAllText('!_batp!') -split ':sppmgr\:.*';iex ($f[1])" goto dk_done :sppmgr: @@ -14961,7 +14420,6 @@ function DetectSubscription { function DetectAdbaClient { $propADBA | foreach { set $_ (SlGetInfoSku $licID $_) } - DetectActType CONOUT "`nAD Activation client information:" CONOUT " Object Name: $ADActivationObjectName" CONOUT " Domain Name: $ADActivationObjectDN" @@ -15052,18 +14510,17 @@ function DetectKmsHost if ($null -NE $KeyManagementServiceNotificationRequests) {CONOUT " Notification: $KeyManagementServiceNotificationRequests"} } -function DetectActType -{ - $VLType = strGetRegistry ($SPKeyPath + '\' + $strApp + '\' + $licID) "VLActivationType" - if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp) "VLActivationType"} - if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath) "VLActivationType"} - if ($null -EQ $VLType -Or $VLType -GT 3) {$VLType = 0} - if ($null -NE $VLType) {CONOUT "Configured Activation Type: $($VLActTypes[$VLType])"} -} - function DetectKmsClient { - if ($win8) {DetectActType} + if ($win8) + { + $VLType = strGetRegistry ($SPKeyPath + '\' + $strApp + '\' + $licID) "VLActivationType" + if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp) "VLActivationType"} + if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath) "VLActivationType"} + if ($null -EQ $VLType -Or $VLType -GT 3) {$VLType = 0} + } + if ($null -NE $VLType) {CONOUT "Configured Activation Type: $($VLActTypes[$VLType])"} + CONOUT "`r" if ($LicenseStatus -NE 1) { CONOUT "Please activate the product in order to update KMS client information values." @@ -15311,7 +14768,6 @@ function GetResult($strSLP, $strApp, $entry) if ($win8 -And $VLActivationType -EQ 1) { DetectAdbaClient - $cKmsClient = $null } if ($winID -And $null -NE $cAvmClient) { @@ -16068,7 +15524,7 @@ if %_erl%==5 goto:retokens if %_erl%==4 goto:fixwmi if %_erl%==3 goto:sfcscan if %_erl%==2 goto:dism_rest -if %_erl%==1 (start %selfgit% & start %github% & start %mas%troubleshoot & goto at_menu) +if %_erl%==1 start %mas%troubleshoot.html &goto at_menu goto :at_menu ::======================================================================================================================================== @@ -16257,7 +15713,7 @@ call :dk_color %Blue% "Rebuilding ClipSVC Licenses..." echo: if %winbuild% LSS 10240 ( -echo ClipSVC license rebuilding is supported only on Windows 10/11. +echo ClipSVC license rebuilding is supported only on Windows 10/11 and their Server equivalents. echo Skipping... goto :rebuildspptok ) @@ -16268,40 +15724,6 @@ echo Skipping... goto :rebuildspptok ) -set _partial= -set _keymatch= -for /f "tokens=2 delims==" %%# in ('%psc% "(([WMISEARCHER]'SELECT PartialProductKey FROM SoftwareLicensingProduct WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).PartialProductKey | %% {echo ('PartialProductKey='+$_)}" %nul6%') do set "_partial=%%#" -for %%# in (8HV2C QPFCT 3V66T PKCKT WXCHW 8TYMD 6F4BT 8HVX7 KD72Y 7CFBY DRR8H P39PB DYJWX MDWWW 9HKR4 M7V2X 2YV77 WT2RQ MHBPB QPF8P 2YV66 VMJ2C DJ4F6 CKFFD YY74H J8JXD BHDCD T6R4W D32MH RRK69 3PJBP) do if /i "%_partial%"=="%%#" set _keymatch=1 - -if not defined _keymatch ( -echo HWID activation key is not installed. -echo Skipping... -goto :rebuildspptok -) - -%psc% "If([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet){Exit 0}Else{Exit 1}" -if errorlevel 1 ( -echo Internet is not connected. -echo Skipping... -goto :rebuildspptok -) - -set resfail= -for %%# in ( -licensing.mp.microsoft.com/v7.0/licenses/content -login.live.com/ppsecure/deviceaddcredential.srf -purchase.mp.microsoft.com/v7.0/users/me/orders -) do if not defined resfail ( -%psc% "try { [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; irm https://%%# -Method POST } catch { if ($_.Exception.Response -eq $null) { Write-Host """"[%%#] $($_.Exception.Message)"""" -ForegroundColor Red -BackgroundColor Black; exit 3 } }" -if !errorlevel!==3 set resfail=1 -) - -if defined resfail ( -echo Failed to connect to licensing servers. -echo Skipping... -goto :rebuildspptok -) - echo Stopping ClipSVC service... %psc% Stop-Service ClipSVC -force %nul% timeout /t 2 %nul% @@ -16396,25 +15818,6 @@ echo: call :dk_color %Blue% "Rebuilding SPP licensing tokens..." echo: -echo Clearing KMS Cache... -echo: -call :_taskclear-cache - -%nul% reg query "HKLM\%SPPk%\%_wApp%" && ( -echo Removing KMS38 protection... -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':regdel\:.*';. ([scriptblock]::Create($f[1]))" -%nul% reg delete "HKLM\%SPPk%\%_wApp%" /f -%nul% reg query "HKLM\%SPPk%\%_wApp%" && ( -call :dk_color %Red% "Failed to remove KMS38 protection." -) || ( -echo Successfully removed KMS38 protection. -echo Successfully cleared KMS Cache. -) -) || ( -echo Successfully cleared KMS Cache. -) -echo: - call :scandat check if not defined token ( @@ -16440,7 +15843,7 @@ echo Checking SPP permission related issues... call :checkperms if defined permerror ( call :dk_color %Red% "[!permerror!]" -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':fixsppperms\:.*';. ([scriptblock]::Create($f[1]))" %nul% +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':fixsppperms\:.*';iex ($f[1])" %nul% call :checkperms if defined permerror ( call :dk_color %Red% "[!permerror!] [Failed To Fix]" @@ -16467,7 +15870,7 @@ for %%# in (SppE%w%xtComObj.exe %_slexe%) do (reg delete "HKLM\SOFTWARE\Microsof if %winbuild% LSS 9200 if not defined _vis ( REM Fix issues caused by Update KB971033 in Windows 7 -REM https://support.microsoft.com/en-us/help/4487266 +REM https://support.microsoft.com/help/4487266 echo: echo Checking Update KB971033... %psc% "if (Get-Hotfix -Id KB971033 -ErrorAction SilentlyContinue) {Exit 3}" %nul% @@ -16510,8 +15913,8 @@ if defined _vis ( echo: echo Reinstalling system licenses... -%psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if %errorlevel% NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% +%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 ( echo [Successful] ) else ( @@ -16617,8 +16020,8 @@ for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v P 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 %_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 %_86%\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (set "c2r16_86=Office 16.0 C2R x86" & call :getc2r16repair c2r16repair86 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 :getc2r16repair c2r16repair68 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" & call :getc2rrepair c2r16repair86 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) set uwp16= if %winbuild% GEQ 10240 ( @@ -16660,11 +16063,13 @@ echo ________________________________________________________________ echo: ) -echo: if %counter% EQU 0 ( +echo: echo Office ^(2010 and later^) is not installed. goto :repairend -) else if not defined c2r16_68 if not defined c2r16_86 ( +echo: +) else ( +echo: call :dk_color %_Yellow% "A new window will appear, in that window you need to select [Quick Repair] option." if defined terminal ( call :dk_color %_Yellow% "Press [0] to continue..." @@ -16691,16 +16096,16 @@ echo Skipping repair for Office 14.0 C2R... echo: ) -if defined msi14_68 if exist "%msi14repair68%" echo Running - "%msi14repair68%" & "%msi14repair68%" -if defined msi14_86 if exist "%msi14repair86%" echo Running - "%msi14repair86%" & "%msi14repair86%" -if defined msi15_68 if exist "%msi15repair68%" echo Running - "%msi15repair68%" & "%msi15repair68%" -if defined msi15_86 if exist "%msi15repair86%" echo Running - "%msi15repair86%" & "%msi15repair86%" -if defined msi16_68 if exist "%msi16repair68%" echo Running - "%msi16repair68%" & "%msi16repair68%" -if defined msi16_86 if exist "%msi16repair86%" echo Running - "%msi16repair86%" & "%msi16repair86%" -if defined c2r15_68 if exist "%c2r15repair68%" echo Running - "%c2r15repair68%" REPAIRUI RERUNMODE & "%c2r15repair68%" REPAIRUI RERUNMODE -if defined c2r15_86 if exist "%c2r15repair86%" echo Running - "%c2r15repair86%" REPAIRUI RERUNMODE & "%c2r15repair86%" REPAIRUI RERUNMODE -if defined c2r16_68 if exist "%c2r16repair68%" echo Running - "%c2r16repair68%" Scenario=Repair RepairType=QuickRepair & "%c2r16repair68%" Scenario=Repair RepairType=QuickRepair -if defined c2r16_86 if exist "%c2r16repair86%" echo Running - "%c2r16repair86%" Scenario=Repair RepairType=QuickRepair & "%c2r16repair86%" Scenario=Repair RepairType=QuickRepair +if defined msi14_68 if exist "%msi14repair68%" echo Running - "%msi14repair68%" & "%msi14repair68%" +if defined msi14_86 if exist "%msi14repair86%" echo Running - "%msi14repair86%" & "%msi14repair86%" +if defined msi15_68 if exist "%msi15repair68%" echo Running - "%msi15repair68%" & "%msi15repair68%" +if defined msi15_86 if exist "%msi15repair86%" echo Running - "%msi15repair86%" & "%msi15repair86%" +if defined msi16_68 if exist "%msi16repair68%" echo Running - "%msi16repair68%" & "%msi16repair68%" +if defined msi16_86 if exist "%msi16repair86%" echo Running - "%msi16repair86%" & "%msi16repair86%" +if defined c2r15_68 if exist "%c2r15repair68%" echo Running - "%c2r15repair68%" REPAIRUI RERUNMODE & "%c2r15repair68%" REPAIRUI RERUNMODE +if defined c2r15_86 if exist "%c2r15repair86%" echo Running - "%c2r15repair86%" REPAIRUI RERUNMODE & "%c2r15repair86%" REPAIRUI RERUNMODE +if defined c2r16_68 if exist "%c2r16repair68%" echo Running - "%c2r16repair68%" scenario=Repair & "%c2r16repair68%" scenario=Repair +if defined c2r16_86 if exist "%c2r16repair86%" echo Running - "%c2r16repair86%" scenario=Repair & "%c2r16repair86%" scenario=Repair :repairend @@ -16720,13 +16125,6 @@ set "%1=%systemdrive%\Program Files\Microsoft Office 15\Client%%#\%2" ) exit /b -:getc2r16repair - -for %%# in (%_68% %_86%) do ( -for /f "skip=2 tokens=2*" %%a in ('"reg query %%#\ClickToRun\Configuration /v ClientFolder" %nul6%') do if exist "%%b\%2" (set "%1=%%b\%2") -) -exit /b - :getrepairsetup set "_common86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE%2\Office Setup Controller\setup.exe" @@ -16917,7 +16315,7 @@ goto :at_menu :: https://stackoverflow.com/a/46268232 -set "ddf="%SystemRoot%\Temp\%Random%%Random%%Random%%Random%"" +set "ddf="%SystemRoot%\Temp\ddf"" %nul% del /q /f %ddf% echo/.New Cabinet>%ddf% echo/.set Cabinet=ON>>%ddf% @@ -16969,7 +16367,7 @@ set "permerror=Error Found In SPP Registries" ) ) -REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application +REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application if not defined permerror ( reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( @@ -17015,7 +16413,7 @@ if ($env:permerror -eq 'Error Found In SPP Registries') { } # Fix perms for SPP in HKU\S-1-5-20 -# https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application +# https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application if ($env:permerror -ne 'Error Found In S-1-5-20 SPP') { exit @@ -17135,7 +16533,7 @@ exit /b :regownstart -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':regown\:.*';. ([scriptblock]::Create($f[1]));" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regown\:.*';iex ($f[1]);" exit /b :: Below code takes ownership of a volatile registry key and deletes it @@ -17165,36 +16563,6 @@ $acl.SetAccessRule($rule) $key.SetAccessControl($acl) :regown: -::======================================================================================================================================== - -:: This code runs to undo below registry key KMS38 protection -:: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f - -:: This option is not used in KMS38 anymore, it's here only to remove previous versions protection. - -:regdel: -param ( - [switch]$protect -) - -$SID = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544') -$Admin = ($SID.Translate([System.Security.Principal.NTAccount])).Value - -if($protect) { -$ruleArgs = @("$Admin", "Delete, SetValue", "ContainerInherit", "None", "Deny") -} else { -$ruleArgs = @("$Admin", "FullControl", "Allow") -} - -$path = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f' -$key = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64').OpenSubKey($path, 'ReadWriteSubTree', 'ChangePermissions') -$acl = $key.GetAccessControl() - -$rule = [System.Security.AccessControl.RegistryAccessRule]::new.Invoke($ruleArgs) -$acl.ResetAccessRule($rule) -$key.SetAccessControl($acl) -:regdel: - :+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ :change_winedition @@ -17230,8 +16598,8 @@ 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%in-place_repair_upgrade -call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) ) @@ -17263,7 +16631,8 @@ if not defined allapps ( %eline% echo Failed to find activation IDs. Aborting... echo: -call :dk_color %Blue% "To fix this issue, activate Windows from the main menu." +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -17285,7 +16654,8 @@ if not defined osedition ( %eline% echo Failed to detect OS edition, aborting... echo: -call :dk_color %Blue% "To fix this issue, activate Windows from the main menu." +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -17308,7 +16678,7 @@ set _ntarget= set _wtarget= if %winbuild% GEQ 10240 for /f "tokens=4" %%a in ('dism /online /english /Get-TargetEditions ^| findstr /i /c:"Target Edition : "') do (if defined _dtarget (set "_dtarget= !_dtarget! %%a ") else (set "_dtarget= %%a ")) -if %winbuild% LSS 10240 for /f "tokens=4" %%a in ('%psc% "$f=[System.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 17063 call :ced_edilist @@ -17377,11 +16747,7 @@ echo: for %%A in (%_ntarget%) do ( set /a counter+=1 -if /i %%A==IoTEnterprise ( -echo [!counter!] %%A [GAC, not LTSC] -) else ( echo [!counter!] %%A -) set targetedition!counter!=%%A ) @@ -17434,7 +16800,7 @@ set _dismapi=1 ) ) -set "keyflow=Retail OEM:NONSLP OEM:DM Volume:MAK Volume:GVLK PGS:TB Retail:TB:Eval" +set "keyflow=Retail Volume:GVLK Volume:MAK OEM:NONSLP OEM:DM PGS:TB Retail:TB:Eval" call :ced_targetSKU %targetedition% if defined targetSKU call :ced_windowskey @@ -17518,7 +16884,7 @@ echo: call :ced_prep if defined preperror goto dk_done -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':dismapi\:.*';. ([scriptblock]::Create($f[1])) %targetedition% %key%" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':dismapi\:.*';& ([ScriptBlock]::Create($f[1])) %targetedition% %key%" call :ced_postprep ) %line% @@ -17556,7 +16922,7 @@ call :ced_prep if defined preperror goto dk_done if %_stg%==0 (set stage=) else (set stage=-StageCurrent) -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':cbsxml\:.*';. ([scriptblock]::Create($f[1])) -SetEdition %targetedition% %stage%" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -SetEdition %targetedition% %stage%" call :ced_postprep %line% @@ -18003,55 +17369,55 @@ if %winbuild% GEQ 22000 exit /b ) if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*.mum" (set Cor=Cor) else (set Cor=) -set w= +set h= for %%# in ( -XGVPP-NMH47-7TTHJ-W3FW7-8HV%w%2C__OEM:NONSLP_Enterprise -D6RD9-D4N8T-RT9QX-YW6YT-FCW%w%WJ______Retail_Starter -3V6Q6-NQXCX-V8YXR-9QCYV-QPF%w%CT__Volume:MAK_EnterpriseN -3NFXW-2T27M-2BDW6-4GHRV-68X%w%RX______Retail_StarterN -VK7JG-NPHTM-C97JM-9MPGT-3V6%w%6T______Retail_Professional -2B87N-8KFHP-DKV6R-Y2C8J-PKC%w%KT______Retail_ProfessionalN -4CPRK-NM3K3-X6XXQ-RXX86-WXC%w%HW______Retail_CoreN -N2434-X9D7W-8PF6X-8DV9T-8TY%w%MD______Retail_CoreCountrySpecific -BT79Q-G7N6G-PGBYW-4YWX6-6F4%w%BT______Retail_CoreSingleLanguage -YTMG3-N6DKC-DKB77-7M9GH-8HV%w%X7______Retail_Core -XKCNC-J26Q9-KFHD2-FKTHY-KD7%w%2Y__OEM:NONSLP_PPIPro -YNMGQ-8RYV3-4PGQ3-C8XTP-7CF%w%BY______Retail_Education -84NGF-MHBT6-FXBX8-QWJK7-DRR%w%8H______Retail_EducationN -KCNVH-YKWX8-GJJB9-H9FDT-6F7%w%W2__Volume:MAK_EnterpriseS_VB -43TBQ-NH92J-XKTM7-KT3KK-P39%w%PB__OEM:NONSLP_EnterpriseS_RS5 -NK96Y-D9CD8-W44CQ-R8YTK-DYJ%w%WX__OEM:NONSLP_EnterpriseS_RS1 -FWN7H-PF93Q-4GGP8-M8RF3-MDW%w%WW__OEM:NONSLP_EnterpriseS_TH -RQFNW-9TPM3-JQ73T-QV4VQ-DV9%w%PT__Volume:MAK_EnterpriseSN_VB -M33WV-NHY3C-R7FPM-BQGPT-239%w%PG__Volume:MAK_EnterpriseSN_RS5 -2DBW3-N2PJG-MVHW3-G7TDK-9HK%w%R4__Volume:MAK_EnterpriseSN_RS1 -NTX6B-BRYC2-K6786-F6MVQ-M7V%w%2X__Volume:MAK_EnterpriseSN_TH -G3KNM-CHG6T-R36X3-9QDG6-8M8%w%K9______Retail_ProfessionalSingleLanguage -HNGCC-Y38KG-QVK8D-WMWRK-X86%w%VK______Retail_ProfessionalCountrySpecific -DXG7C-N36C4-C4HTG-X4T3X-2YV%w%77______Retail_ProfessionalWorkstation -WYPNQ-8C467-V2W6J-TX4WX-WT2%w%RQ______Retail_ProfessionalWorkstationN -8PTT6-RNW4C-6V7J2-C2D3X-MHB%w%PB______Retail_ProfessionalEducation -GJTYN-HDMQY-FRR76-HVGC7-QPF%w%8P______Retail_ProfessionalEducationN -C4NTJ-CX6Q2-VXDMR-XVKGM-F9D%w%JC__Volume:MAK_EnterpriseG -46PN6-R9BK9-CVHKB-HWQ9V-MBJ%w%Y8__Volume:MAK_EnterpriseGN -NJCF7-PW8QT-3324D-688JX-2YV%w%66______Retail_ServerRdsh -XQQYW-NFFMW-XJPBH-K8732-CKF%w%FD______OEM:DM_IoTEnterprise -QPM6N-7J2WJ-P88HH-P3YRH-YY7%w%4H__OEM:NONSLP_IoTEnterpriseS -K9VKN-3BGWV-Y624W-MCRMQ-BHD%w%CD______Retail_CloudEditionN -KY7PN-VR6RX-83W6Y-6DDYQ-T6R%w%4W______Retail_CloudEdition -V3WVW-N2PV2-CGWC3-34QGF-VMJ%w%2C______Retail_Cloud -NH9J3-68WK7-6FB93-4K3DF-DJ4%w%F6______Retail_CloudN -2HN6V-HGTM8-6C97C-RK67V-JQP%w%FD______Retail_CloudE -WC2BQ-8NRM3-FDDYY-2BFGV-KHK%w%QY_Volume:GVLK_ServerStandard%Cor%_RS1 -CB7KF-BWN84-R7R2Y-793K2-8XD%w%DG_Volume:GVLK_ServerDatacenter%Cor%_RS1 -JCKRF-N37P4-C2D82-9YXRT-4M6%w%3B_Volume:GVLK_ServerSolution_RS1 -QN4C6-GBJD2-FB422-GHWJK-GJG%w%2R_Volume:GVLK_ServerCloudStorage_RS1 -VP34G-4NPPG-79JTQ-864T4-R3M%w%QX_Volume:GVLK_ServerAzureCor_RS1 -9JQNQ-V8HQ6-PKB8H-GGHRY-R62%w%H6______Retail_ServerAzureNano_RS1 -VN8D3-PR82H-DB6BJ-J9P4M-92F%w%6J______Retail_ServerStorageStandard_RS1 -48TQX-NVK3R-D8QR3-GTHHM-8FH%w%XC______Retail_ServerStorageWorkgroup_RS1 -2HXDN-KRXHB-GPYC7-YCKFJ-7FV%w%DG_Volume:GVLK_ServerDatacenterACor_RS3 -PTXN8-JFHJM-4WC78-MPCBR-9W4%w%KR_Volume:GVLK_ServerStandardACor_RS3 +XGVPP-NMH47-7TTHJ-W3FW7-8HV%h%2C__OEM:NONSLP_Enterprise +D6RD9-D4N8T-RT9QX-YW6YT-FCW%h%WJ______Retail_Starter +3V6Q6-NQXCX-V8YXR-9QCYV-QPF%h%CT__Volume:MAK_EnterpriseN +3NFXW-2T27M-2BDW6-4GHRV-68X%h%RX______Retail_StarterN +VK7JG-NPHTM-C97JM-9MPGT-3V6%h%6T______Retail_Professional +2B87N-8KFHP-DKV6R-Y2C8J-PKC%h%KT______Retail_ProfessionalN +4CPRK-NM3K3-X6XXQ-RXX86-WXC%h%HW______Retail_CoreN +N2434-X9D7W-8PF6X-8DV9T-8TY%h%MD______Retail_CoreCountrySpecific +BT79Q-G7N6G-PGBYW-4YWX6-6F4%h%BT______Retail_CoreSingleLanguage +YTMG3-N6DKC-DKB77-7M9GH-8HV%h%X7______Retail_Core +XKCNC-J26Q9-KFHD2-FKTHY-KD7%h%2Y__OEM:NONSLP_PPIPro +YNMGQ-8RYV3-4PGQ3-C8XTP-7CF%h%BY______Retail_Education +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 +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 +NTX6B-BRYC2-K6786-F6MVQ-M7V%h%2X__Volume:MAK_EnterpriseSN_TH +G3KNM-CHG6T-R36X3-9QDG6-8M8%h%K9______Retail_ProfessionalSingleLanguage +HNGCC-Y38KG-QVK8D-WMWRK-X86%h%VK______Retail_ProfessionalCountrySpecific +DXG7C-N36C4-C4HTG-X4T3X-2YV%h%77______Retail_ProfessionalWorkstation +WYPNQ-8C467-V2W6J-TX4WX-WT2%h%RQ______Retail_ProfessionalWorkstationN +8PTT6-RNW4C-6V7J2-C2D3X-MHB%h%PB______Retail_ProfessionalEducation +GJTYN-HDMQY-FRR76-HVGC7-QPF%h%8P______Retail_ProfessionalEducationN +C4NTJ-CX6Q2-VXDMR-XVKGM-F9D%h%JC__Volume:MAK_EnterpriseG +46PN6-R9BK9-CVHKB-HWQ9V-MBJ%h%Y8__Volume:MAK_EnterpriseGN +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 +NH9J3-68WK7-6FB93-4K3DF-DJ4%h%F6______Retail_CloudN +2HN6V-HGTM8-6C97C-RK67V-JQP%h%FD______Retail_CloudE +WC2BQ-8NRM3-FDDYY-2BFGV-KHK%h%QY_Volume:GVLK_ServerStandard%Cor%_RS1 +CB7KF-BWN84-R7R2Y-793K2-8XD%h%DG_Volume:GVLK_ServerDatacenter%Cor%_RS1 +JCKRF-N37P4-C2D82-9YXRT-4M6%h%3B_Volume:GVLK_ServerSolution_RS1 +QN4C6-GBJD2-FB422-GHWJK-GJG%h%2R_Volume:GVLK_ServerCloudStorage_RS1 +VP34G-4NPPG-79JTQ-864T4-R3M%h%QX_Volume:GVLK_ServerAzureCor_RS1 +9JQNQ-V8HQ6-PKB8H-GGHRY-R62%h%H6______Retail_ServerAzureNano_RS1 +VN8D3-PR82H-DB6BJ-J9P4M-92F%h%6J______Retail_ServerStorageStandard_RS1 +48TQX-NVK3R-D8QR3-GTHHM-8FH%h%XC______Retail_ServerStorageWorkgroup_RS1 +2HXDN-KRXHB-GPYC7-YCKFJ-7FV%h%DG_Volume:GVLK_ServerDatacenterACor_RS3 +PTXN8-JFHJM-4WC78-MPCBR-9W4%h%KR_Volume:GVLK_ServerStandardACor_RS3 ) do ( for /f "tokens=1-4 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C ( @@ -18088,6 +17454,15 @@ echo: echo Initializing... echo: +if not exist %SysPath%\sppsvc.exe ( +%eline% +echo [%SysPath%\sppsvc.exe] file is missing. Aborting... +echo: +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +goto dk_done +) + ::======================================================================================================================================== set spp=SoftwareLicensingProduct @@ -18121,7 +17496,8 @@ if %osedition%==0 ( %eline% echo Failed to detect OS Edition. Aborting... echo: -call :dk_color %Blue% "To fix this issue, activate Windows from the main menu." +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -18170,7 +17546,6 @@ _updch _lang _clversion _version -_AudienceData _oIds _c2rXml _c2rExe @@ -18298,10 +17673,9 @@ goto :oe_edition :oe_editionchangepre cls -set editedition= call :ch_getinfo call :oe_tempcleanup -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getlist\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getlist\:.*';iex ($f[1])" :oe_editionchange @@ -18375,7 +17749,7 @@ cls set suites= echo %list% | find /i "Suites" %nul1% && ( set suites=1 -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getappnames\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getappnames\:.*';iex ($f[1])" if not exist %SystemRoot%\Temp\getAppIds.txt ( %eline% echo Failed to generate available apps list. @@ -18417,8 +17791,7 @@ if not defined terminal mode 98, 32 %line% echo: call :dk_color %Gray% "Target edition: %targetedition%" -call :dk_color %Gray% "To exclude the apps listed below from installation, toggle them from On to Off." -if defined editedition call :dk_color %Gray% "Note: The On/Off status below does not reflect the current status of the installed apps." +call :dk_color %Gray% "You can exclude the below apps from installation." %line% if defined suites echo: if defined Access_st echo [A] Access : %Access_st% @@ -18545,9 +17918,7 @@ goto :oe_goback :: 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 -call :oe_getlangs - -set "c2rcommand="%_c2rExe%" platform=%_oArch% culture=%_lang% productstoadd=%targetedition%.16_%_allLangs% 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 ( set "c2rcommand=!c2rcommand! productstoremove=AllProducts" @@ -18562,40 +17933,8 @@ set errorcode=%errorlevel% timeout /t 10 %nul% echo: -set suggestchannel= - if %errorcode% EQU 0 ( -if %change%==1 ( -echo %targetedition% | find /i "2019Volume" %nul% && ( -if not defined ltsc19 set suggestchannel=Production::LTSC -if /i not %_AudienceData%==Production::LTSC set suggestchannel=Production::LTSC -if /i not %_updch%==F2E724C1-748F-4B47-8FB8-8E0D210E9208 set suggestchannel=Production::LTSC -) - -echo %targetedition% | find /i "2021Volume" %nul% && ( -if not defined ltsc21 set suggestchannel=Production::LTSC2021 -if /i not %_AudienceData%==Production::LTSC2021 set suggestchannel=Production::LTSC2021 -if /i not %_updch%==5030841D-C919-4594-8D2D-84AE4F96E58E set suggestchannel=Production::LTSC2021 -) - -echo %targetedition% | find /i "2024Volume" %nul% && ( -if not defined ltsc24 set suggestchannel=Production::LTSC2024 -if /i not %_AudienceData%==Production::LTSC2024 set suggestchannel=Production::LTSC2024 -if /i not %_updch%==7983BAC0-E531-40CF-BE00-FD24FE66619C set suggestchannel=Production::LTSC2024 -) - -echo %targetedition% | findstr /R "20.*Volume" %nul% || ( -if defined ltscfound set suggestchannel=Production::CC -echo %_AudienceData% | find /i "LTSC" %nul% && set suggestchannel=Production::CC -) - -if defined suggestchannel ( -call :dk_color %Gray% "Mismatch found in update channel and installed product." -call :dk_color %Blue% "It is recommended to change the update channel to [!suggestchannel!] from the previous menu." -) -echo: -) -call :dk_color %Gray% "To activate Office, run the activation option from the main menu." +call :dk_color %Gray% "Now run the Office activation option from the main menu." ) else ( set fixes=%fixes% %mas%troubleshoot call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" @@ -18619,7 +17958,6 @@ goto :oe_goback ) set change=0 -set editedition=1 call :ch_getinfo cls @@ -18725,8 +18063,13 @@ if %verified%==0 goto :oe_removeedition cls if not defined terminal mode 105, 32 -call :oe_getlangs %targetedition% -set "c2rcommand="%_c2rExe%" platform=%_oArch% productstoremove=%targetedition%.16_%_allLangs%" +set _lang= +echo "%o16c2r_reg%" | find /i "Wow6432Node" %nul1% && (set _tok=10) || (set _tok=9) +for /f "tokens=%_tok% delims=\" %%a in ('reg query "%o16c2r_reg%\ProductReleaseIDs\%_actconfig%\%targetedition%.16" /f "-" /k ^| findstr /i ".*16\\.*-.*"') do ( +if defined _lang (set "_lang=!_lang!_%%a") else (set "_lang=_%%a") +) + +set "c2rcommand="%_c2rExe%" platform=%_oArch% productstoremove=%targetedition%.16%_lang%" echo: echo Running the below command, please wait... @@ -18768,12 +18111,6 @@ echo Installed Office editions: %_oIds% echo Unsupported Office edition is installed on your Windows build version %winbuild%. goto :oe_goback ) -if defined ltscfound ( -%eline% -echo Installed Office update channel: %ltsc19%%ltsc21%%ltsc24% -echo Unsupported Office update channel is installed on your Windows build version %winbuild%. -goto :oe_goback -) ) ::=============== @@ -18782,51 +18119,49 @@ set inpt= set counter=0 set verified=0 set targetFFN= -set bypassFFN= set targetchannel= %line% echo: call :dk_color %Gray% "Installed update channel: %_AudienceData%, %_version%, Client: %_clversion%" -call :dk_color %Gray% "Installed Office editions: %_oIds%" +call :dk_color %Gray% "Unsupported update channels are excluded from this list." %line% echo: for %%# in ( -"5440fd1f-7ecb-4221-8110-145efaa6372f_Beta / Insider Fast - Insiders::DevMain -" -"64256afe-f5d9-4f86-8936-8840a6a4f5be_Current / Monthly Preview - Insiders::CC -" -"492350f6-3a01-4f97-b9c0-c7c6ddf67d60_Current / Monthly - Production::CC -" -"55336b82-a18d-4dd6-b5f6-9e5095c314a6_Monthly Enterprise - Production::MEC -" -"7ffbc6bf-bc32-4f92-8982-f9dd17fd3114_Semi Annual Enterprise - Production::DC -" -"ea4a4090-de26-49d7-93c1-91bff9e53fc3_DevMain Channel - Dogfood::DevMain -" -"b61285dd-d9f7-41f2-9757-8f61cba4e9c8_Microsoft Elite - Microsoft::DevMain -" -"f2e724c1-748f-4b47-8fb8-8e0d210e9208_Perpetual2019 VL - Production::LTSC -" -"1d2d2ea6-1680-4c56-ac58-a441c8c24ff9_Microsoft2019 VL - Microsoft::LTSC -" -"5030841d-c919-4594-8d2d-84ae4f96e58e_Perpetual2021 VL - Production::LTSC2021 -" -"86752282-5841-4120-ac80-db03ae6b5fdb_Microsoft2021 VL - Microsoft::LTSC2021 -" -"7983bac0-e531-40cf-be00-fd24fe66619c_Perpetual2024 VL - Production::LTSC2024 -" -"c02d8fe6-5242-4da8-972f-82ee55e00671_Microsoft2024 VL - Microsoft::LTSC2024 -" +"5440FD1F-7ECB-4221-8110-145EFAA6372F_Insider Fast [Beta] - Insiders::DevMain" +"64256AFE-F5D9-4F86-8936-8840A6A4F5BE_Monthly Preview - Insiders::CC" +"492350F6-3A01-4F97-B9C0-C7C6DDF67D60_Monthly [Current] - Production::CC" +"55336B82-A18D-4DD6-B5F6-9E5095C314A6_Monthly Enterprise - Production::MEC" +"B8F9B850-328D-4355-9145-C59439A0C4CF_Semi Annual Preview - Insiders::FRDC" +"7FFBC6BF-BC32-4F92-8982-F9DD17FD3114_Semi Annual - Production::DC" +"EA4A4090-DE26-49D7-93C1-91BFF9E53FC3_DevMain Channel - Dogfood::DevMain" +"B61285DD-D9F7-41F2-9757-8F61CBA4E9C8_Microsoft Elite - Microsoft::DevMain" +"F2E724C1-748F-4B47-8FB8-8E0D210E9208_Perpetual2019 VL - Production::LTSC" +"1D2D2EA6-1680-4C56-AC58-A441C8C24FF9_Microsoft2019 VL - Microsoft::LTSC" +"5030841D-C919-4594-8D2D-84AE4F96E58E_Perpetual2021 VL - Production::LTSC2021" +"86752282-5841-4120-AC80-DB03AE6B5FDB_Microsoft2021 VL - Microsoft::LTSC2021" +"7983BAC0-E531-40CF-BE00-FD24FE66619C_Perpetual2024 VL - Production::LTSC2024" +"C02D8FE6-5242-4DA8-972F-82EE55E00671_Microsoft2024 VL - Microsoft::LTSC2024" ) do ( for /f "tokens=1-2 delims=_" %%A in ("%%~#") do ( -set bypass= set supported= if %winbuild% LSS 10240 (echo %%B | findstr /i "LTSC DevMain" %nul% || set supported=1) else (set supported=1) if %winbuild% GEQ 10240 ( -if defined ltsc19 echo %%B | find /i "2019 VL" %nul% || set bypass=1 -if defined ltsc21 echo %%B | find /i "2021 VL" %nul% || set bypass=1 -if defined ltsc24 echo %%B | find /i "2024 VL" %nul% || set bypass=1 -if not defined ltscfound echo %%B | find /i "LTSC" %nul% && set bypass=1 +if defined ltsc19 echo %%B | find /i "2019 VL" %nul% || set supported= +if defined ltsc21 echo %%B | find /i "2021 VL" %nul% || set supported= +if defined ltsc24 echo %%B | find /i "2024 VL" %nul% || set supported= +if not defined ltscfound echo %%B | find /i "LTSC" %nul% && set supported= ) if defined supported ( set /a counter+=1 if !counter! LSS 10 ( -if defined bypass (echo [!counter!] %%B Unofficial change method will be used) else (echo [!counter!] %%B) +echo [!counter!] %%B ) else ( -if defined bypass (echo [!counter!] %%B Unofficial change method will be used) else (echo [!counter!] %%B) +echo [!counter!] %%B ) set targetFFN!counter!=%%A set targetchannel!counter!=%%B -if defined bypass set bypassFFN=!bypassFFN!%%A ) ) ) @@ -18840,7 +18175,7 @@ call :dk_color %_Green% "Enter an option number using your keyboard and press En set /p inpt= if "%inpt%"=="" goto :oe_changeupdchnl if "%inpt%"=="0" goto :oemenu -if /i "%inpt%"=="R" start https://learn.microsoft.com/en-us/microsoft-365-apps/updates/overview-update-channels & goto :oe_changeupdchnl +if /i "%inpt%"=="R" start https://learn.microsoft.com/microsoft-365-apps/updates/overview-update-channels & goto :oe_changeupdchnl for /l %%i in (1,1,%counter%) do (if "%inpt%"=="%%i" set verified=1) set targetFFN=!targetFFN%inpt%! set targetchannel=!targetchannel%inpt%! @@ -18854,148 +18189,18 @@ if not defined terminal mode 105, 32 :: Get build number for the target FFN, using build number with OfficeC2RClient.exe command to trigger updates provides accurate results set build= -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getbuild\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do (set build=%%a) +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getbuild\:.*';iex ($f[1])" %nul6%') do (set build=%%a) echo "%build%" | find /i "16." %nul% || set build= -echo: -for /f "tokens=1 delims=-" %%A in ("%targetchannel%") do (echo Target update channel: %%A) -echo Target build number: %build% -echo: %bypassFFN% | find /i "%targetFFN%" %nul% && goto :oe_changeunoff - -call :oe_cleanupreg - -if not defined build ( -if %winbuild% GEQ 9200 call :dk_color %Gray% "Failed to detect build number for the target FFN." -set "updcommand="%_c2rCexe%" /update user" -) else ( -set "updcommand="%_c2rCexe%" /update user updatetoversion=%build%" -) -echo Running the below command to trigger updates... -echo: -echo %updcommand% -%updcommand% -echo: -echo Check this webpage for help - %mas%troubleshoot -goto :oe_goback - -::======================= - -:: Unofficial method to change channel - -:oe_changeunoff - -set abortchange= -echo %targetchannel% | find /i "2019 VL" %nul% && (for %%A in (%_oIds%) do (echo %%A | find /i "2019Volume" %nul% || set abortchange=1)) -echo %targetchannel% | find /i "2021 VL" %nul% && (for %%A in (%_oIds%) do (echo %%A | find /i "2021Volume" %nul% || set abortchange=1)) -echo %targetchannel% | find /i "2024 VL" %nul% && (for %%A in (%_oIds%) do (echo %%A | find /i "2024Volume" %nul% || set abortchange=1)) - -if defined abortchange ( -%eline% -echo Mismatch found in installed Office products and target update channel. Aborting... -echo Non-perpetual Office products are not suppported with Perpetual VL update channels. -goto :oe_goback -) - -if not defined build ( -%eline% -call :dk_color %Red% "Failed to detect build number for the target FFN." -echo: -set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" -goto :oe_goback -) - -set buildchk=0 -for /f "tokens=3 delims=." %%a in ("%build%") do set "buildchk=%%a" - -call :oe_getlangs %_firstoId% - -echo %targetchannel% | find /i "2019 VL" %nul% && ( -for %%A in (en-gb es-mx fr-ca) do ( -echo %_allLangs% | find /i "%%A" %nul% && ( -%eline% -echo [%%A] language is not supported on the Office 2019 Perpetual VL update channel. Aborting... -goto :oe_goback -) -) -) - -set "c2rcommand="%_c2rExe%" platform=%_oArch% culture=%_lang% productstoadd=%_firstoId%.16_%_allLangs% cdnbaseurl.16=http://officecdn.microsoft.com/pr/%targetFFN% baseurl.16=http://officecdn.microsoft.com/pr/%targetFFN% version.16=%build% mediatype.16=CDN sourcetype.16=CDN deliverymechanism=%targetFFN% %_firstoId%.excludedapps.16=%_firstoIdExcludelist% flt.useteamsaddon=disabled flt.usebingaddononinstall=disabled flt.usebingaddononupdate=disabled" -set "c2rclientupdate=!c2rcommand! scenario=CLIENTUPDATE" - -if %clverchk% LSS %buildchk% ( -echo: -call :dk_color %Blue% "Do not terminate the operation before it completes..." -echo: -echo Updating Office C2R client with the command below, please wait... -echo: -echo %c2rclientupdate% -%c2rclientupdate% -for /l %%i in (1,1,30) do (if !clverchk! LSS %buildchk% (call :ch_getinfo&timeout /t 10 %nul%)) -) - -if %clverchk% LSS %buildchk% ( -echo: -call :dk_color %Red% "Failed to update Office C2R client. Aborting..." -echo: -set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" -goto :oe_goback -) - -call :oe_cleanupreg - -echo Running the below command to change update channel, please wait... -echo: -echo %c2rcommand% -%c2rcommand% -set errorcode=%errorlevel% -timeout /t 10 %nul% - -echo: -if %errorcode% EQU 0 ( -call :dk_color %Gray% "Now run the Office activation option from the main menu." -) else ( -set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" -) - -::======================================================================================================================================== - -:oe_goback - -call :oe_tempcleanup - -echo: -if defined fixes ( -call :dk_color %White% "Follow ALL the ABOVE blue lines. " -call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" -choice /C:10 /N -if !errorlevel!==2 goto :oemenu -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) -) - -if defined terminal ( -call :dk_color %_Yellow% "Press [0] key to go back..." -choice /c 0 /n -) else ( -call :dk_color %_Yellow% "Press any key to go back..." -pause %nul1% -) -goto :oemenu - -::======================================================================================================================================== - -:oe_cleanupreg - :: Cleanup Office update related registries, thanks to @abbodi1406 :: https://techcommunity.microsoft.com/t5/office-365-blog/how-to-manage-office-365-proplus-channels-for-it-pros/ba-p/795813 :: https://learn.microsoft.com/en-us/microsoft-365-apps/updates/change-update-channels#considerations-when-changing-channels +echo: +for /f "tokens=1 delims=-" %%A in ("%targetchannel%") do (echo Target update channel: %%A) echo: echo Cleaning Office update registry keys... echo Adding new update channel to registry keys... -echo: %nul% reg add %o16c2r_reg%\Configuration /v CDNBaseUrl /t REG_SZ /d "https://officecdn.microsoft.com/pr/%targetFFN%" /f %nul% reg add %o16c2r_reg%\Configuration /v UpdateChannel /t REG_SZ /d "https://officecdn.microsoft.com/pr/%targetFFN%" /f @@ -19012,7 +18217,43 @@ echo: %nul% reg delete HKLM\SOFTWARE\Policies\Microsoft\cloud\office\16.0\Common\officeupdate /f /reg:32 %nul% reg delete HKCU\Software\Policies\Microsoft\cloud\office\16.0\Common\officeupdate /f -exit /b +if not defined build ( +if %winbuild% GEQ 9200 call :dk_color %Gray% "Failed to detect build number for the target FFN." +set "updcommand="%_c2rCexe%" /update user" +) else ( +set "updcommand="%_c2rCexe%" /update user updatetoversion=%build%" +) +echo Running the below command to trigger updates... +echo: +echo %updcommand% +%updcommand% +echo: +echo Check this webpage for help - %mas%troubleshoot +goto :oe_goback + +::======================================================================================================================================== + +:oe_goback + +call :oe_tempcleanup + +echo: +if defined fixes ( +call :dk_color %White% "Follow ALL the ABOVE blue lines. " +call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" +choice /C:10 /N +if !errorlevel!==2 goto :oemenu +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) +) + +if defined terminal ( +call :dk_color %_Yellow% "Press [0] key to go back..." +choice /c 0 /n +) else ( +call :dk_color %_Yellow% "Press any key to go back..." +pause %nul1% +) +goto :oemenu ::======================================================================================================================================== @@ -19035,7 +18276,6 @@ set _oRoot= set _oArch= set _updch= set _oIds= -set _firstoId= set _lang= set _cfolder= set _version= @@ -19066,13 +18306,9 @@ for /f "tokens=%_tok% delims=\" %%a in ('reg query "%o16c2r_reg%\ProductReleaseI if defined _oIds (set "_oIds=!_oIds! %%a") else (set "_oIds=%%a") ) set _oIds=%_oIds:.16=% -for /f "tokens=1" %%A in ("%_oIds%") do set _firstoId=%%A -for /f "skip=2 tokens=2*" %%a in ('"reg query %o16c2r_reg%\Configuration /v %_firstoId%.ExcludedApps" %nul6%') do (set "_firstoIdExcludelist=%%b") set verchk=0 -set clverchk=0 for /f "tokens=3 delims=." %%a in ("%_version%") do set "verchk=%%a" -for /f "tokens=3 delims=." %%a in ("%_clversion%") do set "clverchk=%%a" if exist "%_oRoot%\Licenses16\c2rpridslicensefiles_auto.xml" set "_c2rXml=%_oRoot%\Licenses16\c2rpridslicensefiles_auto.xml" @@ -19088,13 +18324,16 @@ if exist "%_cfolder%\OfficeC2RClient.exe" ( set "_c2rCexe=%_cfolder%\OfficeC2RClient.exe" ) -:: Check LTSC version files +set "audidata4=%_AudienceData:~-4%" -for /f "skip=2 tokens=2*" %%a in ('"reg query %o16c2r_reg%\ProductReleaseIDs\%_actconfig%" /s %nul6%') do ( -echo "%%b" %nul2% | findstr "16.0.103 16.0.104 16.0.105" %nul% && set ltsc19=LTSC -echo "%%b" %nul2% | findstr "16.0.14332" %nul% && set ltsc21=LTSC2021 -echo "%%b" %nul2% | findstr "16.0.17932" %nul% && set ltsc24=LTSC2024 -) +if /i "%audidata4%"=="LTSC" 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 %_clversion% %_version% | findstr "16.0.14332" %nul% && set ltsc21=LTSC2021 + +if /i "%audidata4%"=="2024" set ltsc24=LTSC2024 +:: LTSC 2024 build is not fixed yet if not "%ltsc19%%ltsc21%%ltsc24%"=="" set ltscfound=1 @@ -19102,27 +18341,6 @@ exit /b ::======================================================================================================================================== -:: Check all the installed languages - -:oe_getlangs - -if "%1"=="" ( -set langreg=culture -) else ( -set langreg=%1.16 -) - -set _allLangs= -echo "%o16c2r_reg%" | find /i "Wow6432Node" %nul1% && (set _tok=10) || (set _tok=9) -for /f "tokens=%_tok% delims=\" %%a in ('reg query "%o16c2r_reg%\ProductReleaseIDs\%_actconfig%\%langreg%" /f "-" /k ^| findstr /i "%langreg%\\.*-.*"') do ( -if defined _allLangs (set "_allLangs=!_allLangs!_%%a") else (set "_allLangs=%%a") -) - -set _allLangs=%_allLangs:.16=% -exit /b - -::======================================================================================================================================== - :: Check Internet connection :oe_chkinternet diff --git a/MAS/Separate-Files-Version/Activators/HWID_Activation.cmd b/MAS/Separate-Files-Version/Activators/HWID_Activation.cmd index 4332dd8..7e5bce3 100644 --- a/MAS/Separate-Files-Version/Activators/HWID_Activation.cmd +++ b/MAS/Separate-Files-Version/Activators/HWID_Activation.cmd @@ -1,11 +1,12 @@ -@set masver=3.9 +@set masver=3.2 @echo off ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -49,7 +50,6 @@ set "_cmdf=%~f0" for %%# in (%*) do ( if /i "%%#"=="re1" set re1=1 if /i "%%#"=="re2" set re2=1 -if /i "%%#"=="-qedit" (set re1=1&set re2=1) ) :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows @@ -100,8 +100,6 @@ set "nul=" set "blank=" set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" -set "github=ht%blank%tps%blank%://github.com/massgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" -set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/massg%blank%rave/Micr%blank%osoft-Act%blank%ivation-Scripts" :: Check if Null service is working, it's important for the batch script @@ -173,16 +171,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto dk_done ) -if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( -sc query gcs | find /i "RUNNING" %nul% && ( -%eline% -echo Windows Sandbox detected; activation is not supported. -echo The script cannot run due to missing licensing components. Aborting... -echo: -goto dk_done -) -) - if %winbuild% LSS 10240 ( %eline% echo Unsupported OS version detected [%winbuild%]. @@ -247,18 +235,16 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) +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% -for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) -echo Test 1 - %tstresult% -echo Test 2 - !tstresult2! -echo: +echo: %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" REM check LanguageMode -echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +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: @@ -271,9 +257,6 @@ 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... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" goto dk_done ) @@ -288,33 +271,10 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_ goto dk_done ) -REM check if .NET is working properly - -if /i "!tstresult2!"=="FullLanguage" ( -cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% -if !errorlevel!==3 ( -echo Windows Powershell failed to load .NET command. Aborting... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -goto dk_done -) -) - REM check antivirus and other errors echo PowerShell is not working properly. Aborting... - -if /i "!tstresult2!"=="FullLanguage" ( -echo: -echo Your antivirus software might be blocking the script. -echo: -sc query sense | find /i "RUNNING" %nul% && ( -echo Installed Antivirus - Microsoft Defender for Endpoint -) -cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" -) - +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" @@ -335,9 +295,7 @@ set terminal= if defined terminal ( set lines=0 -for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( -for %%B in (%%A) do set lines=%%B -) +for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A if !lines! GEQ 100 set terminal= ) @@ -398,7 +356,7 @@ echo: call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" choice /C:10 /N if !errorlevel!==2 rem -if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) +if !errorlevel!==1 (start %mas% & exit /b) ) ) @@ -427,8 +385,8 @@ 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%in-place_repair_upgrade -call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) goto dk_done ) @@ -537,7 +495,7 @@ set notworking= call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f if defined allapps call :hwiddata key if not defined key ( -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getactivationid\:.*';. ([scriptblock]::Create($f[1]))"') do (set altapplist=%%a) +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getactivationid\:.*';iex ($f[1])"') do (set altapplist=%%a) if defined altapplist call :hwiddata key ) @@ -595,15 +553,12 @@ call :dk_inskey "[%key%]" for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Control Panel\International\Geo" /v Name %nul6%') do set "name=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Control Panel\International\Geo" /v Nation %nul6%') do set "nation=%%b" -:: Skip changing region in top countries - +set regionchange= +if not "%name%"=="US" ( set regionchange=1 -for %%# in (US CN IN BR DE JP GB FR MX ID IT PK TR KR CA ES AU NG VN PL PH NL EG AR TH CO SA TW MY CL) do if /i "%name%"=="%%#" set regionchange= - -if defined regionchange ( %psc% "Set-WinHomeLocation -GeoId 244" %nul% if !errorlevel! EQU 0 ( -echo Changing Windows Region To USA [Successful] [Script will change it back] +echo Changing Windows Region To USA [Successful] ) else ( call :dk_color %Red% "Changing Windows Region To USA [Failed]" ) @@ -674,9 +629,7 @@ call :dk_color %Red% "Checking Ticket Migration [Failed]" if not defined altapplist if not defined showfix if defined rebuildinfo ( set showfix=1 -echo: call :dk_color %Blue% "%_fixmsg%" -echo: ) if exist "%tdir%\Genuine*" del /f /q "%tdir%\Genuine*" %nul% @@ -746,10 +699,8 @@ licensing.mp.microsoft.com findstr /i "%%#" "%SysPath%\drivers\etc\hosts" %nul1% && set "hosfail= [%%# Blocked in Hosts]" ) call :dk_color %Red% "Checking Licensing Servers [Failed to Connect]!hosfail!" -echo: set fixes=%fixes% %mas%licensing-servers-issue call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%licensing-servers-issue" -echo: ) ::========================================================================================================================================== @@ -762,17 +713,13 @@ reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWin reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DoNotConnectToWindowsUpdateInternetLocations %nul2% | find /i "0x1" %nul% && set wublock=1 if defined wublock ( call :dk_color %Red% "Checking Update Blocker In Registry [Found]" -echo: call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it." -echo: ) reg query "HKLM\SOFTWARE\Policies\Microsoft\WindowsStore" /v DisableStoreApps %nul2% | find /i "0x1" %nul% && ( set storeblock=1 call :dk_color %Red% "Checking Store Blocker In Registry [Found]" -echo: call :dk_color %Blue% "If you have used any tool to block Store, undo it." -echo: ) set wcount=0 @@ -789,14 +736,10 @@ set error=1 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." -echo: set fixes=%fixes% %mas%remove_mal%w%ware call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" -echo: ) else ( -echo: call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it." -echo: ) ) else ( %psc% "Start-Job { Start-Service wuauserv } | Wait-Job -Timeout 20 | Out-Null" @@ -805,9 +748,7 @@ set error=1 set wuerror=1 sc start wuauserv %nul% call :dk_color %Red% "Starting Windows Update Service [Failed] [!errorlevel!]" -echo: call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it." -echo: ) ) ) @@ -820,10 +761,8 @@ 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% && ( call :dk_color %Red% "Checking Internet Issues [Found] %error_code%" -echo: set fixes=%fixes% %mas%licensing-servers-issue call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%licensing-servers-issue" -echo: ) ) ) @@ -878,7 +817,7 @@ goto :dk_done set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=%ps% -nop -c set winbuild=1 -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +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) @@ -967,7 +906,7 @@ for /f "tokens=3 delims=." %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Con if %_wmic% EQU 1 for /f "tokens=2 delims==" %%a in ('"wmic Path Win32_OperatingSystem Get OperatingSystemSKU /format:LIST" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" if %_wmic% EQU 0 for /f "tokens=1" %%a in ('%psc% "([WMI]'Win32_OperatingSystem=@').OperatingSystemSKU" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" -if %winbuild% GEQ 15063 %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';. ([scriptblock]::Create($f[1]))" %nul2% | find /i "Subscription_is_activated" %nul% && ( +if %winbuild% GEQ 15063 %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';iex ($f[1])" %nul2% | find /i "Subscription_is_activated" %nul% && ( if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" ( set winsub=1 set osSKU=%regSKU% @@ -1030,11 +969,9 @@ if %sps%==SoftwareLicensingService call :dk_refresh echo %keyecho% %~1 [Successful] ) else ( call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" -if not defined showfix ( +if not defined error ( if defined altapplist call :dk_color %Red% "Activation ID not found for this key." -echo: call :dk_color %Blue% "%_fixmsg%" -echo: set showfix=1 ) set error=1 @@ -1157,11 +1094,6 @@ set spperror=%errorlevel% if %spperror% NEQ 1056 if %spperror% NEQ 0 ( %eline% echo sc start %_slser% [Error Code: %spperror%] -if %spperror% EQU 1053 ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and try again." -call :dk_color %Blue% "If it still does not work, go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -) ) echo: @@ -1239,8 +1171,7 @@ if not exist %SysPath%\%_slexe% if not exist %SysPath%\alg.exe (set "results=%re if not "%results%%pupfound%"=="" ( if defined pupfound call :dk_color %Gray% "Checking PUP Activators [Found%pupfound%]" if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..." -if defined results (call :dk_color %Red% "%results%"&set showfix=1) -echo: +if defined results call :dk_color %Red% "%results%" set fixes=%fixes% %mas%remove_mal%w%ware call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" echo: @@ -1261,118 +1192,40 @@ exit /b set showfix= call :dk_chkmal -::============================== - :: Check Sandboxing sc query Null %nul% || ( -call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly]" -if not defined showfix ( -echo: +set error=1 +set showfix=1 +call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly.]" call :dk_color %Blue% "If you are using any third-party antivirus, check if it is blocking the script." echo: ) -set error=1 -set showfix=1 -) -::============================== - -:: Check WinPE mode - -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( - -call :dk_color %Red% "Checking WinPE [Found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "WinPE mode found. Reboot the system and run in normal mode." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check Safe mode - -if defined safeboot_option ( -call :dk_color %Red% "Checking Boot Mode [%safeboot_option%]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Safe mode found. Reboot the system and run in normal mode." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check ImageState -:: https://learn.microsoft.com/en-us/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) - -if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" ( -call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]" -echo "%imagestate%" | find /i "RESEAL" %nul% && ( -if not defined showfix ( -echo: -call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode." -echo: -) -set error=1 -set showfix=1 -) -echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && ( -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -) -) - -::============================== +::======================================================================================================================================== :: Check corrupt services set serv_cor= for %%# in (%_serv%) do ( -set _regcorr= set _corrupt= sc start %%# %nul% if !errorlevel! EQU 1060 set _corrupt=1 sc query %%# %nul% || set _corrupt=1 -for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type) do if not defined _regcorr ( -reg query HKLM\SYSTEM\CurrentControlSet\Services\%%# /v %%G %nul% || (set _corrupt=1&set _regcorr=-RegistryError) +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 ) -if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#!_regcorr!") else (set "serv_cor=%%#!_regcorr!")) +if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#") else (set "serv_cor=%%#")) ) if defined serv_cor ( -call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" - -if not defined showfix ( -echo: -if /i "%serv_cor%"=="sppsvc-RegistryError" ( -set fixes=%fixes% %mas%fix_service -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_service" -) else ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) -echo: -) - set error=1 set showfix=1 +call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" ) -::============================== +::======================================================================================================================================== :: Check disabled services @@ -1407,26 +1260,11 @@ if defined serv_cste (set "serv_cste=!serv_cste! %%#") else (set "serv_cste=%%#" if defined serv_csts call :dk_color %Gray% "Enabling Disabled Services [Successful] [%serv_csts%]" if defined serv_cste ( -call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" - -if not defined showfix ( -echo: -echo %serv_cste% | findstr /i "ClipSVC sppsvc" %nul% && ( -echo A registry fix has been applied to enable the disabled service. -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -) || ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) -echo: -) - set error=1 -set showfix=1 +call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" ) -::============================== +::======================================================================================================================================== :: Check if the services are able to run or not :: Workarounds are added to get correct status and error code because sc query doesn't output correct results in some conditions @@ -1448,322 +1286,75 @@ if defined checkerror if defined serv_e (set "serv_e=!serv_e!, %%#-!errorcode!") ) if defined serv_e ( +set error=1 call :dk_color %Red% "Starting Services [Failed] [%serv_e%]" - -if not defined showfix ( -set listwospp=%_serv:sppsvc=% -echo %serv_e% | findstr /i "!listwospp!" %nul% && ( +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." set showfix=1 -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and run the script again." +) +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 +) +) + +::======================================================================================================================================== + +:: Various error checks + +if defined safeboot_option ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option%] " %Blue% "[Safe mode found. Run in normal mode.]" +) + + +:: 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) + +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 showfix=1 +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 service error is still not fixed, do this - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: +call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade" ) ) -set error=1 -) -::============================== -:: Check WMI - -set wmifailed= -if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 %_wmic% EQU 1 wmic path %sps% get Version %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% -cmd /c exit /b %error_code% -if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" - -echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants - -if defined wmifailed ( -call :dk_color %Red% "Checking WMI [Not Working]" - -if not defined showfix ( -echo: -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." -echo: -) +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( set error=1 set showfix=1 +call :dk_color2 %Red% "Checking WinPE " %Blue% "[WinPE mode found. Run in normal mode.]" ) -::============================== -:: Check SPP Registry Key - -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% || ( -call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found] [Most likely caused by gaming spoofers]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%issues_due_to_gaming_spoofers -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check TokenStore registry key - -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" -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" ( -call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set toerr=1 -set error=1 -set showfix=1 -) -) - -::============================== - -:: 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%\" ( - -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% 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)';" -set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" -set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" -set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" -%psc% "!d!" %nul% - -if exist "%tokenstore%\" ( -call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" -) else ( -call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set error=1 -set showfix=1 -) -) - -::============================== - -:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. - -set permerror= -if %winbuild% GEQ 9200 if not defined toerr if not defined ps32onArm if exist "%tokenstore%\" ( -for %%# in ( -"%tokenstore%+FullControl" -"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" -"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" -) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( -%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% -if !errorlevel!==2 ( -if "%%A"=="%tokenstore%" ( -set "permerror=Error Found In Token Folder" -) else ( -set "permerror=Error Found In SPP Registries" -) -) -) - -REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application - -if not defined permerror ( -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( -set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" -reg query "!pol!" %nul% || reg add "!pol!" %nul% -%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% -if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" -) -) - -if defined permerror ( -call :dk_color %Red% "Checking SPP Permissions [!permerror!]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -) -set error=1 -set showfix=1 -) -) - -::============================== - -:: Check WPA Registry Errors - -set chkalp= -set wpainfo=NotFound -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wpatest\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do (set wpainfo=%%a) -for /f "delims=0123456789" %%i in ("%wpainfo%") do set chkalp=%%i - -if defined chkalp ( -call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" -if not defined showfix ( +set wpainfo= +set wpaerror= +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1])" %nul6%') do (set wpainfo=%%a) echo "%wpainfo%" | find /i "Error Found" %nul% && ( -echo: -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -echo: set error=1 -set showfix=1 -) -) -set wpainfo=a -) - -if not defined chkalp ( -if %wpainfo% GEQ 5000 ( -call :dk_color %Gray% "Checking WPA Registry Count [%wpainfo%]" -echo: -call :dk_color %Blue% "A large number of WPA registries have been found, which may cause high CPU usage." -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -echo: -) else ( +set wpaerror=1 +call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" +) || ( echo Checking WPA Registry Count [%wpainfo%] ) -) -::============================== - -:: Check Rearm - -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( -call :dk_color %Red% "Checking Rearm [System is Rearmed]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -echo: -) -set error=1 -set showfix=1 -) - - -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( -call :dk_color %Red% "Checking ClipSVC PersistedSystemState [Found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check SoftwareLicensingService - -if %error_code% NEQ 0 ( -call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] [%error_code%]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check Activation IDs - -call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f - -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=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if not defined _vis if !errorlevel! NEQ 0 set rlicfailed=1 -call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f -) - -if not defined apps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -if not defined apps if defined allapps if not defined notwinact ( -call :dk_color %Gray% "Checking Activation IDs [Key Not Installed or Act ID Not Found]" -) - -if not defined apps if not defined allapps ( -call :dk_color %Red% "Checking Activation IDs [Not found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) -set error=1 -set showfix=1 -) - -if not defined showfix if defined rlicfailed ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) - -if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( -call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]" -) - -::============================== - -:: Check Eval Windows if not defined notwinact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || ( -call :dk_color %Red% "Checking Eval Packages [License swapping found. Non-Eval licenses are installed in Eval Windows]" -if not defined showfix ( -echo: -call :dk_color %Blue% "License swapping is not the right way to upgrade to the full version. Learn the correct method at the link below." +call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]" set fixes=%fixes% %mas%evaluation_editions call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" -echo: -) -set error=1 -set showfix=1 ) ) -::============================== - -:: Check HKU\S-1-5-20\Software registry, in some systems it's missing and that causes Windows activation problems - -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( -call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check license and package files for the current edition 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%')" @@ -1783,10 +1374,12 @@ if not defined notwinact ( if %osedition%==0 ( call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" ) 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" ( set skunotfound=1 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%Edition*.mum" ( call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" @@ -1795,9 +1388,31 @@ call :dk_color %Red% "Checking Package Files [Not Found] [%osed ) ) -::============================== -:: Check SKU value to find if there is any difference +if %_wmic% EQU 1 wmic path %sps% get Version %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% +cmd /c exit /b %error_code% +if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" +if %error_code% NEQ 0 ( +set error=1 +call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] %error_code%" +) + + +set wmifailed= +if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 +echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants +if defined wmifailed ( +set error=1 +call :dk_color %Red% "Checking WMI [Not Working]" +if not defined showfix call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." +set showfix=1 +) + if not defined notwinact ( if %winbuild% GEQ 10240 ( @@ -1815,19 +1430,35 @@ call :dk_color %Gray% "Checking SLC/WMI SKU [Difference Found ) ) -::============================== +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Rearm " %Blue% "[System Restart Is Required]" +) + + +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System Restart Is Required]" +) + :: 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. -sc query wlms %nul% - -if %errorlevel% NEQ 1060 ( +if exist "%SysPath%\wlms\wlms.exe" ( echo Checking Eval WLMS Service [Found] ) -::============================== -:: Check SPP interference in IFEO +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( +set error=1 +set showfix=1 +call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" +set fixes=%fixes% %mas%in-place_repair_upgrade +call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +) + for %%# in (SppEx%w%tComObj.exe SLsvc.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=%%#")) @@ -1835,56 +1466,156 @@ reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu if defined _sppint ( echo %_sppint% | find /i "PerfOptions" %nul% && ( call :dk_color %Red% "Checking SPP Interference In IFEO [%_sppint% - System might deactivate later]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -) +if not defined showfix call :dk_color %Blue% "%_fixmsg%" set showfix=1 ) || ( echo Checking SPP In IFEO [%_sppint%] ) ) -::============================== - -:: Check and fix SkipRearm registry value 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 ( reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul% -call :dk_color %Gray% "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" ) -::============================== -:: Check SvcRestartTask status, this task helps in making sure system remains activated +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% || ( +call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]" +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" +set error=1 +set showfix=1 +) + + +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" +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" ( +set toerr=1 +set error=1 +set showfix=1 +call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +) +) + +:: 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%\" ( +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% 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)';" +set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" +set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" +set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" +%psc% "!d!" %nul% +if exist "%tokenstore%\" ( +call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" +) else ( +call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" +set error=1 +set showfix=1 +) +) + + +if not defined notwinact ( +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +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% +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined apps ( +set "_notfoundids=Key Not Installed / Act ID Not Found" +call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined allapps ( +set error=1 +set "_notfoundids=Not found" +) +call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]" +) +) +) + + +if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( +set error=1 +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" ( %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% "$s=New-Object -ComObject 'Schedule.Service'; $s.Connect(); $state=$s.GetFolder('\Microsoft\Windows\SoftwareProtectionPlatform').GetTask('SvcRestartTask').State; @{0='Unknown';1='Disabled';2='Queued';3='Ready';4='Running'}[$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% || ( 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 if "!taskinfo!"=="" set "taskinfo=Not Found" +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." +) +) +) -call :dk_color %Gray% "Checking SvcRestartTask Status [!taskinfo!. System might deactivate later.]" + +:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. + +set permerror= +if %winbuild% GEQ 9200 if not defined ps32onArm ( +for %%# in ( +"%tokenstore%+FullControl" +"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" +"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" +) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( +%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% +if !errorlevel!==2 ( +if "%%A"=="%tokenstore%" ( +set "permerror=Error Found In Token Folder" +) else ( +set "permerror=Error Found In SPP Registries" +) +) +) + +REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application + +if not defined permerror ( +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( +set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" +reg query "!pol!" %nul% || reg add "!pol!" %nul% +%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% +if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" +) +) + +if defined permerror ( +set error=1 +call :dk_color %Red% "Checking SPP Permissions [!permerror!]" +if not defined showfix call :dk_color %Blue% "%_fixmsg%" +set showfix=1 +) +) + + +:: If required services are not disabled or corrupted + if there is any error + SoftwareLicensingService errorlevel is not Zero + no fix was shown before + +if not defined serv_cor if not defined serv_cste if defined error if /i not %error_code%==0 if not defined showfix ( +if not defined permerror if defined wpaerror (call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." & set showfix=1) if not defined showfix ( -echo: -echo "!taskinfo!" | findstr /i "Removed Not Found" %nul1% && ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) || ( -call :dk_color %Blue% "Reboot your machine using the restart option and run the script again." -) -echo: -) -) +set showfix=1 +call :dk_color %Blue% "%_fixmsg%" +if not defined permerror call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." ) ) -::============================== +if not defined showfix if defined wpaerror ( +set showfix=1 +call :dk_color %Blue% "If activation fails then go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." +) exit /b @@ -1976,7 +1707,7 @@ call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" choice /C:10 /N if !errorlevel!==2 exit /b -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -1995,10 +1726,11 @@ exit /b :: 2nd column = Generic Retail/OEM/MAK Key :: 3rd column = SKU ID :: 4th column = Key part number -:: 5th column = 1 = activation is not working (at the time of writing this), 0 = activation is working -:: 6th column = Key Type -:: 7th column = WMI Edition ID (For reference only) -:: 8th column = Version name incase same Edition ID is used in different OS versions with different key +:: 5th column = Ticket signature value. It's as it is, it's not encoded. (Check mass grave[.]dev/hwid#manual-activation to see how it's generated) +:: 6th column = 1 = activation is not working (at the time of writing this), 0 = activation is working +:: 7th column = Key Type +:: 8th column = WMI Edition ID (For reference only) +:: 9th column = Version name incase same Edition ID is used in different OS versions with different key :: Separator = _ @@ -2006,40 +1738,39 @@ exit /b set f= for %%# in ( -8b351c9c-f398-4515-9900-09df49427262_XGVPP-NMH47-7TTHJ-W3FW7-8H%f%V2C___4_X19-99683_0_OEM:NONSLP_Enterprise -c83cef07-6b72-4bbc-a28f-a00386872839_3V6Q6-NQXCX-V8YXR-9QCYV-QP%f%FCT__27_X19-98746_0_Volume:MAK_EnterpriseN -4de7cb65-cdf1-4de9-8ae8-e3cce27b9f2c_VK7JG-NPHTM-C97JM-9MPGT-3V%f%66T__48_X19-98841_0_____Retail_Professional -9fbaf5d6-4d83-4422-870d-fdda6e5858aa_2B87N-8KFHP-DKV6R-Y2C8J-PK%f%CKT__49_X19-98859_0_____Retail_ProfessionalN -f742e4ff-909d-4fe9-aacb-3231d24a0c58_4CPRK-NM3K3-X6XXQ-RXX86-WX%f%CHW__98_X19-98877_0_____Retail_CoreN -1d1bac85-7365-4fea-949a-96978ec91ae0_N2434-X9D7W-8PF6X-8DV9T-8T%f%YMD__99_X19-99652_0_____Retail_CoreCountrySpecific -3ae2cc14-ab2d-41f4-972f-5e20142771dc_BT79Q-G7N6G-PGBYW-4YWX6-6F%f%4BT_100_X19-99661_0_____Retail_CoreSingleLanguage -2b1f36bb-c1cd-4306-bf5c-a0367c2d97d8_YTMG3-N6DKC-DKB77-7M9GH-8H%f%VX7_101_X19-98868_0_____Retail_Core -2a6137f3-75c0-4f26-8e3e-d83d802865a4_XKCNC-J26Q9-KFHD2-FKTHY-KD%f%72Y_119_X19-99606_0_OEM:NONSLP_PPIPro -e558417a-5123-4f6f-91e7-385c1c7ca9d4_YNMGQ-8RYV3-4PGQ3-C8XTP-7C%f%FBY_121_X19-98886_0_____Retail_Education -c5198a66-e435-4432-89cf-ec777c9d0352_84NGF-MHBT6-FXBX8-QWJK7-DR%f%R8H_122_X19-98892_0_____Retail_EducationN -f6e29426-a256-4316-88bf-cc5b0f95ec0c_PJB47-8PN2T-MCGDY-JTY3D-CB%f%CPV_125_X23-50331_1_Volume:MAK_EnterpriseS_Ge -cce9d2de-98ee-4ce2-8113-222620c64a27_KCNVH-YKWX8-GJJB9-H9FDT-6F%f%7W2_125_X22-66075_1_Volume:MAK_EnterpriseS_VB -d06934ee-5448-4fd1-964a-cd077618aa06_43TBQ-NH92J-XKTM7-KT3KK-P3%f%9PB_125_X21-83233_0_OEM:NONSLP_EnterpriseS_RS5 -706e0cfd-23f4-43bb-a9af-1a492b9f1302_NK96Y-D9CD8-W44CQ-R8YTK-DY%f%JWX_125_X21-05035_0_OEM:NONSLP_EnterpriseS_RS1 -faa57748-75c8-40a2-b851-71ce92aa8b45_FWN7H-PF93Q-4GGP8-M8RF3-MD%f%WWW_125_X19-99617_0_OEM:NONSLP_EnterpriseS_TH -3d1022d8-969f-4222-b54b-327f5a5af4c9_2DBW3-N2PJG-MVHW3-G7TDK-9H%f%KR4_126_X21-04921_0_Volume:MAK_EnterpriseSN_RS1 -60c243e1-f90b-4a1b-ba89-387294948fb6_NTX6B-BRYC2-K6786-F6MVQ-M7%f%V2X_126_X19-98770_0_Volume:MAK_EnterpriseSN_TH -01eb852c-424d-4060-94b8-c10d799d7364_3XP6D-CRND4-DRYM2-GM84D-4G%f%G8Y_139_X23-37869_1_____Retail_ProfessionalCountrySpecific_Zn -eb6d346f-1c60-4643-b960-40ec31596c45_DXG7C-N36C4-C4HTG-X4T3X-2Y%f%V77_161_X21-43626_0_____Retail_ProfessionalWorkstation -89e87510-ba92-45f6-8329-3afa905e3e83_WYPNQ-8C467-V2W6J-TX4WX-WT%f%2RQ_162_X21-43644_0_____Retail_ProfessionalWorkstationN -62f0c100-9c53-4e02-b886-a3528ddfe7f6_8PTT6-RNW4C-6V7J2-C2D3X-MH%f%BPB_164_X21-04955_0_____Retail_ProfessionalEducation -13a38698-4a49-4b9e-8e83-98fe51110953_GJTYN-HDMQY-FRR76-HVGC7-QP%f%F8P_165_X21-04956_0_____Retail_ProfessionalEducationN -df96023b-dcd9-4be2-afa0-c6c871159ebe_NJCF7-PW8QT-3324D-688JX-2Y%f%V66_175_X21-41295_0_____Retail_ServerRdsh -d4ef7282-3d2c-4cf0-9976-8854e64a8d1e_V3WVW-N2PV2-CGWC3-34QGF-VM%f%J2C_178_X21-32983_0_____Retail_Cloud -af5c9381-9240-417d-8d35-eb40cd03e484_NH9J3-68WK7-6FB93-4K3DF-DJ%f%4F6_179_X21-32987_0_____Retail_CloudN -8ab9bdd1-1f67-4997-82d9-8878520837d9_XQQYW-NFFMW-XJPBH-K8732-CK%f%FFD_188_X21-99378_0_____OEM:DM_IoTEnterprise -ed655016-a9e8-4434-95d9-4345352c2552_QPM6N-7J2WJ-P88HH-P3YRH-YY%f%74H_191_X21-99682_0_OEM:NONSLP_IoTEnterpriseS_VB -6c4de1b8-24bb-4c17-9a77-7b939414c298_CGK42-GYN6Y-VD22B-BX98W-J8%f%JXD_191_X23-12617_0_OEM:NONSLP_IoTEnterpriseS_Ge -d4bdc678-0a4b-4a32-a5b3-aaa24c3b0f24_K9VKN-3BGWV-Y624W-MCRMQ-BH%f%DCD_202_X22-53884_0_____Retail_CloudEditionN -92fb8726-92a8-4ffc-94ce-f82e07444653_KY7PN-VR6RX-83W6Y-6DDYQ-T6%f%R4W_203_X22-53847_0_____Retail_CloudEdition -5a85300a-bfce-474f-ac07-a30983e3fb90_N979K-XWD77-YW3GB-HBGH6-D3%f%2MH_205_X23-15042_0_____OEM:DM_IoTEnterpriseSK -80083eae-7031-4394-9e88-4901973d56fe_P8Q7T-WNK7X-PMFXY-VXHBG-RR%f%K69_206_X23-62084_0_____OEM:DM_IoTEnterpriseK -1bc2140b-285b-4351-b99c-26a126104b29_TMP2N-KGFHJ-PWM6F-68KCQ-3P%f%JBP_210_X23-60513_0_____Retail_WNC +8b351c9c-f398-4515-9900-09df49427262_XGVPP-NMH47-7TTHJ-W3FW7-8H%f%V2C___4_X19-99683_HGNKjkKcKQHO6n8srMUrDh/MElffBZarLqCMD9rWtgFKf3YzYOLDPEMGhuO/auNMKCeiU7ebFbQALS/MyZ7TvidMQ2dvzXeXXKzPBjfwQx549WJUU7qAQ9Txg9cR9SAT8b12Pry2iBk+nZWD9VtHK3kOnEYkvp5WTCTsrSi6Re4_0_OEM:NONSLP_Enterprise +c83cef07-6b72-4bbc-a28f-a00386872839_3V6Q6-NQXCX-V8YXR-9QCYV-QP%f%FCT__27_X19-98746_NHn2n0N1UfVf00CfaI5LCDMDsKdVAWpD/HAfUrcTAKsw9d2Sks4h5MhyH/WUx+B6dFi8ol7D3AHorR8y9dqVS1Bd2FdZNJl/tTR1PGwYn6KL88NS19aHmFNdX8s4438vaa+Ty8Qk8EDcwm/wscC8lQmi3/RgUKYdyGFvpbGSVlk_0_Volume:MAK_EnterpriseN +4de7cb65-cdf1-4de9-8ae8-e3cce27b9f2c_VK7JG-NPHTM-C97JM-9MPGT-3V%f%66T__48_X19-98841_Yl/jNfxJ1SnaIZCIZ4m6Pf3ySNoQXifNeqfltNaNctx+onwiivOx7qcSn8dFtURzgMzSOFnsRQzb5IrvuqHoxWWl1S3JIQn56FvKsvSx7aFXIX3+2Q98G1amPV/WEQ0uHA5d7Ya6An+g0Z0zRP7evGoomTs4YuweaWiZQjQzSpA_0_____Retail_Professional +9fbaf5d6-4d83-4422-870d-fdda6e5858aa_2B87N-8KFHP-DKV6R-Y2C8J-PK%f%CKT__49_X19-98859_Ge0mRQbW8ALk7T09V+1k1yg66qoS0lhkgPIROOIOgxKmWPAvsiLAYPKDqM4+neFCA/qf1dHFmdh0VUrwFBPYsK251UeWuElj4bZFVISL6gUt1eZwbGfv5eurQ0i+qZiFv+CcQOEFsd5DD4Up6xPLLQS3nAXODL5rSrn2sHRoCVY_0_____Retail_ProfessionalN +f742e4ff-909d-4fe9-aacb-3231d24a0c58_4CPRK-NM3K3-X6XXQ-RXX86-WX%f%CHW__98_X19-98877_vel4ytVtnE8FhvN87Cflz9sbh5QwHD1YGOeej9QP7hF3vlBR4EX2/S/09gRneeXVbQnjDOCd2KFMKRUWHLM7ZhFBk8AtlG+kvUawPZ+CIrwrD3mhi7NMv8UX/xkLK3HnBupMEuEwsMJgCUD8Pn6om1mEiQebHBAqu4cT7GN9Y0g_0_____Retail_CoreN +1d1bac85-7365-4fea-949a-96978ec91ae0_N2434-X9D7W-8PF6X-8DV9T-8T%f%YMD__99_X19-99652_Nv17eUTrr1TmUX6frlI7V69VR6yWb7alppCFJPcdjfI+xX4/Cf2np3zm7jmC+zxFb9nELUs477/ydw2KCCXFfM53bKpBQZKHE5+MdGJGxebOCcOtJ3hrkDJtwlVxTQmUgk5xnlmpk8PHg82M2uM5B7UsGLxGKK4d3hi0voSyKeI_0_____Retail_CoreCountrySpecific +3ae2cc14-ab2d-41f4-972f-5e20142771dc_BT79Q-G7N6G-PGBYW-4YWX6-6F%f%4BT_100_X19-99661_FV2Eao/R5v8sGrfQeOjQ4daokVlNOlqRCDZXuaC45bQd5PsNU3t1b4AwWeYM8TAwbHauzr4tPG0UlsUqUikCZHy0poROx35bBBMBym6Zbm9wDBVyi7nCzBtwS86eOonQ3cU6WfZxhZRze0POdR33G3QTNPrnVIM2gf6nZJYqDOA_0_____Retail_CoreSingleLanguage +2b1f36bb-c1cd-4306-bf5c-a0367c2d97d8_YTMG3-N6DKC-DKB77-7M9GH-8H%f%VX7_101_X19-98868_GH/jwFxIcdQhNxJIlFka8c1H48PF0y7TgJwaryAUzqSKXynONLw7MVciDJFVXTkCjbXSdxLSWpPIC50/xyy1rAf8aC7WuN/9cRNAvtFPC1IVAJaMeq1vf4mCqRrrxJQP6ZEcuAeHFzLe/LLovGWCd8rrs6BbBwJXCvAqXImvycQ_0_____Retail_Core +2a6137f3-75c0-4f26-8e3e-d83d802865a4_XKCNC-J26Q9-KFHD2-FKTHY-KD%f%72Y_119_X19-99606_hci78IRWDLBtdbnAIKLDgV9whYgtHc1uYyp9y6FszE9wZBD5Nc8CUD2pI2s2RRd3M04C4O7M3tisB3Ov/XVjpAbxlX3MWfUR5w4MH0AphbuQX0p5MuHEDYyfqlRgBBRzOKePF06qfYvPQMuEfDpKCKFwNojQxBV8O0Arf5zmrIw_0_OEM:NONSLP_PPIPro +e558417a-5123-4f6f-91e7-385c1c7ca9d4_YNMGQ-8RYV3-4PGQ3-C8XTP-7C%f%FBY_121_X19-98886_x9tPFDZmjZMf29zFeHV5SHbXj8Wd8YAcCn/0hbpLcId4D7OWqkQKXxXHIegRlwcWjtII0sZ6WYB0HQV2KH3LvYRnWKpJ5SxeOgdzBIJ6fhegYGGyiXsBv9sEb3/zidPU6ZK9LugVGAcRZ6HQOiXyOw+Yf5H35iM+2oDZXSpjvJw_0_____Retail_Education +c5198a66-e435-4432-89cf-ec777c9d0352_84NGF-MHBT6-FXBX8-QWJK7-DR%f%R8H_122_X19-98892_jkL4YZkmBCJtvL1fT30ZPBcjmzshBSxjwrE0Q00AZ1hYnhrH+npzo1MPCT6ZRHw19ZLTz7wzyBb0qqcBVbtEjZW0Xs2MYLxgriyoONkhnPE6KSUJBw7C0enFVLHEqnVu/nkaOFfockN3bc+Eouw6W2lmHjklPHc9c6Clo04jul0_0_____Retail_EducationN +f6e29426-a256-4316-88bf-cc5b0f95ec0c_PJB47-8PN2T-MCGDY-JTY3D-CB%f%CPV_125_X23-50331_OPGhsyx+Ctw7w/KLMRNrY+fNBmKPjUG0R9RqkWk4e8ez+ExSJxSLLex5WhO5QSNgXLmEra+cCsN6C638aLjIdH2/L7D+8z/C6EDgRvbHMmidHg1lX3/O8lv0JudHkGtHJYewjorn/xXGY++vOCTQdZNk6qzEgmYSvPehKfdg8js_1_Volume:MAK_EnterpriseS_Ge +cce9d2de-98ee-4ce2-8113-222620c64a27_KCNVH-YKWX8-GJJB9-H9FDT-6F%f%7W2_125_X22-66075_GCqWmJOsTVun9z4QkE9n2XqBvt3ZWSPl9QmIh9Q2mXMG/QVt2IE7S+ES/NWlyTSNjLVySr1D2sGjxgEzy9kLwn7VENQVJ736h1iOdMj/3rdqLMSpTa813+nPSQgKpqJ3uMuvIvRP0FdB7Y4qt8qf9kNKK25A1QknioD/6YubL/4_1_Volume:MAK_EnterpriseS_VB +d06934ee-5448-4fd1-964a-cd077618aa06_43TBQ-NH92J-XKTM7-KT3KK-P3%f%9PB_125_X21-83233_EpB6qOCo8pRgO5kL4vxEHck2J1vxyd9OqvxUenDnYO9AkcGWat/D74ZcFg5SFlIya1U8l5zv+tsvZ4wAvQ1IaFW1PwOKJLOaGgejqZ41TIMdFGGw+G+s1RHsEnrWr3UOakTodby1aIMUMoqf3NdaM5aWFo8fOmqWC5/LnCoighs_0_OEM:NONSLP_EnterpriseS_RS5 +706e0cfd-23f4-43bb-a9af-1a492b9f1302_NK96Y-D9CD8-W44CQ-R8YTK-DY%f%JWX_125_X21-05035_ntcKmazIvLpZOryft28gWBHu1nHSbR+Gp143f/BiVe+BD2UjHBZfSR1q405xmQZsygz6VRK6+zm8FPR++71pkmArgCLhodCQJ5I4m7rAJNw/YX99pILphi1yCRcvHsOTGa825GUVXgf530tHT6hr0HQ1lGeGgG1hPekpqqBbTlg_0_OEM:NONSLP_EnterpriseS_RS1 +faa57748-75c8-40a2-b851-71ce92aa8b45_FWN7H-PF93Q-4GGP8-M8RF3-MD%f%WWW_125_X19-99617_Fe9CDClilrAmwwT7Yhfx67GafWRQEpwyj8R+a4eaTqbpPcAt7d1hv1rx8Sa9AzopEGxIrb7IhiPoDZs0XaT1HN0/olJJ/MnD73CfBP4sdQdLTsSJE3dKMWYTQHpnjqRaS/pNBYRr8l9Mv8yfcP8uS2MjIQ1cRTqRmC7WMpShyCg_0_OEM:NONSLP_EnterpriseS_TH +3d1022d8-969f-4222-b54b-327f5a5af4c9_2DBW3-N2PJG-MVHW3-G7TDK-9H%f%KR4_126_X21-04921_zLPNvcl1iqOefy0VLg+WZgNtRNhuGpn8+BFKjMqjaNOSKiuDcR6GNDS5FF1Aqk6/e6shJ+ohKzuwrnmYq3iNQ3I2MBlYjM5kuNfKs8Vl9dCjSpQr//GBGps6HtF2xrG/2g/yhtYC7FbtGDIE16uOeNKFcVg+XMb0qHE/5Etyfd8_0_Volume:MAK_EnterpriseSN_RS1 +60c243e1-f90b-4a1b-ba89-387294948fb6_NTX6B-BRYC2-K6786-F6MVQ-M7%f%V2X_126_X19-98770_kbXfe0z9Vi1S0yfxMWzI5+UtWsJKzxs7wLGUDLjrckFDn1bDQb4MvvuCK1w+Qrq33lemiGpNDspa+ehXiYEeSPFcCvUBpoMlGBFfzurNCHWiv3o1k3jBoawJr/VoDoVZfxhkps0fVoubf9oy6C6AgrkZ7PjCaS58edMcaUWvYYg_0_Volume:MAK_EnterpriseSN_TH +01eb852c-424d-4060-94b8-c10d799d7364_3XP6D-CRND4-DRYM2-GM84D-4G%f%G8Y_139_X23-37869_PVW0XnRJnsWYjTqxb6StCi2tge/uUwegjdiFaFUiZpwdJ620RK+MIAsSq5S+egXXzIWNntoy2fB6BO8F1wBFmxP/mm/3rn5C33jtF5QrbNqY7X9HMbqSiC7zhs4v4u2Xa4oZQx8JQkwr8Q2c/NgHrOJKKRASsSckhunxZ+WVEuM_1_____Retail_ProfessionalCountrySpecific_Zn +eb6d346f-1c60-4643-b960-40ec31596c45_DXG7C-N36C4-C4HTG-X4T3X-2Y%f%V77_161_X21-43626_MaVqTkRrGnOqYizl15whCOKWzx01+BZTVAalvEuHXM+WV55jnIfhWmd/u1GqCd5OplqXdU959zmipK2Iwgu2nw/g91nW//sQiN/cUcvg1Lxo6pC3gAo1AjTpHmGIIf9XlZMYlD+Vl6gXsi/Auwh3yrSSFh5s7gOczZoDTqQwHXA_0_____Retail_ProfessionalWorkstation +89e87510-ba92-45f6-8329-3afa905e3e83_WYPNQ-8C467-V2W6J-TX4WX-WT%f%2RQ_162_X21-43644_JVGQowLiCcPtGY9ndbBDV+rTu/q5ljmQTwQWZgBIQsrAeQjLD8jLEk/qse7riZ7tMT6PKFVNXeWqF7PhLAmACbE8O3Lvp65XMd/Oml9Daynj5/4n7unsffFHIHH8TGyO5j7xb4dkFNqC5TX3P8/1gQEkTIdZEOTQQXFu0L2SP5c_0_____Retail_ProfessionalWorkstationN +62f0c100-9c53-4e02-b886-a3528ddfe7f6_8PTT6-RNW4C-6V7J2-C2D3X-MH%f%BPB_164_X21-04955_CEDgxI8f/fxMBiwmeXw5Of55DG32sbGALzHihXkdbYTDaE3pY37oAA4zwGHALzAFN/t254QImGPYR6hATgl+Cp804f7serJqiLeXY965Zy67I4CKIMBm49lzHLFJeDnVTjDB0wVyN29pvgO3+HLhZ22KYCpkRHFFMy2OKxS68Yc_0_____Retail_ProfessionalEducation +13a38698-4a49-4b9e-8e83-98fe51110953_GJTYN-HDMQY-FRR76-HVGC7-QP%f%F8P_165_X21-04956_r35zp9OfxKSBcTxKWon3zFtbOiCufAPo6xRGY5DJqCRFKdB0jgZalNQitvjmaZ/Rlez2vjRJnEart4LrvyW4d9rrukAjR3+c3UkeTKwoD3qBl9AdRJbXCa2BdsoXJs1WVS4w4LuVzpB/SZDuggZt0F2DlMB427F5aflook/n1pY_0_____Retail_ProfessionalEducationN +df96023b-dcd9-4be2-afa0-c6c871159ebe_NJCF7-PW8QT-3324D-688JX-2Y%f%V66_175_X21-41295_rVpetYUmiRB48YJfCvJHiaZapJ0bO8gQDRoql+rq5IobiSRu//efV1VXqVpBkwILQRKgKIVONSTUF5y2TSxlDLbDSPKp7UHfbz17g6vRKLwOameYEz0ZcK3NTbApN/cMljHvvF/mBag1+sHjWu+eoFzk8H89k9nw8LMeVOPJRDc_0_____Retail_ServerRdsh +d4ef7282-3d2c-4cf0-9976-8854e64a8d1e_V3WVW-N2PV2-CGWC3-34QGF-VM%f%J2C_178_X21-32983_Xzme9hDZR6H0Yx0deURVdE6LiTOkVqWng5W/OTbkxRc0rq+mSYpo/f/yqhtwYlrkBPWx16Yok5Bvcb34vbKHvEAtxfYp4te20uexLzVOtBcoeEozARv4W/6MhYfl+llZtR5efsktj4N4/G4sVbuGvZ9nzNfQO9TwV6NGgGEj2Ec_0_____Retail_Cloud +af5c9381-9240-417d-8d35-eb40cd03e484_NH9J3-68WK7-6FB93-4K3DF-DJ%f%4F6_179_X21-32987_QGRDZOU/VZhYLOSdp2xDnFs8HInNZctcQlWCIrORVnxTQr55IJwN4vK3PJHjkfRLQ/bgUrcEIhyFbANqZFUq8yD1YNubb2bjNORgI/m8u85O9V7nDGtxzO/viEBSWyEHnrzLKKWYqkRQKbbSW3ungaZR0Ti5O2mAUI4HzAFej50_0_____Retail_CloudN +8ab9bdd1-1f67-4997-82d9-8878520837d9_XQQYW-NFFMW-XJPBH-K8732-CK%f%FFD_188_X21-99378_djy0od0uuKd2rrIl+V1/2+MeRltNgW7FEeTNQsPMkVSL75NBphgoso4uS0JPv2D7Y1iEEvmVq6G842Kyt52QOwXgFWmP/IQ6Sq1dr+fHK/4Et7bEPrrGBEZoCfWqk0kdcZRPBij2KN6qCRWhrk1hX2g+U40smx/EYCLGh9HCi24_0_____OEM:DM_IoTEnterprise +ed655016-a9e8-4434-95d9-4345352c2552_QPM6N-7J2WJ-P88HH-P3YRH-YY%f%74H_191_X21-99682_qHs/PzfhYWdtSys2edzcz4h+Qs8aDqb8BIiQ/mJ/+0uyoJh1fitbRCIgiFh2WAGZXjdgB8hZeheNwHibd8ChXaXg4u+0XlOdFlaDTgTXblji8fjETzDBk9aGkeMCvyVXRuUYhTSdp83IqGHz7XuLwN2p/6AUArx9JZCoLGV8j3w_0_OEM:NONSLP_IoTEnterpriseS_VB +6c4de1b8-24bb-4c17-9a77-7b939414c298_CGK42-GYN6Y-VD22B-BX98W-J8%f%JXD_191_X23-12617_J/fpIRynsVQXbp4qZNKp6RvOgZ/P2klILUKQguMlcwrBZybwNkHg/kM5LNOF/aDzEktbPnLnX40GEvKkYT6/qP4cMhn/SOY0/hYOkIdR34ilzNlVNq5xP7CMjCjaUYJe+6ydHPK6FpOuEoWOYYP5BZENKNGyBy4w4shkMAw19mA_0_OEM:NONSLP_IoTEnterpriseS_Ge +d4bdc678-0a4b-4a32-a5b3-aaa24c3b0f24_K9VKN-3BGWV-Y624W-MCRMQ-BH%f%DCD_202_X22-53884_kyoNx2s93U6OUSklB1xn+GXcwCJO1QTEtACYnChi8aXSoxGQ6H2xHfUdHVCwUA1OR0UeNcRrMmOzZBOEUBtdoGWSYPg9AMjvxlxq9JOzYAH+G6lT0UbCWgMSGGrqdcIfmshyEak3aUmsZK6l+uIAFCCZZ/HbbCRkkHC5rWKstMI_0_____Retail_CloudEditionN +92fb8726-92a8-4ffc-94ce-f82e07444653_KY7PN-VR6RX-83W6Y-6DDYQ-T6%f%R4W_203_X22-53847_gD6HnT4jP4rcNu9u83gvDiQq1xs7QSujcDbo60Di5iSVa9/ihZ7nlhnA0eDEZfnoDXriRiPPqc09T6AhSnFxLYitAkOuPJqL5UMobIrab9dwTKlowqFolxoHhLOO4V92Hsvn/9JLy7rEzoiAWHhX/0cpMr3FCzVYPeUW1OyLT1A_0_____Retail_CloudEdition +5a85300a-bfce-474f-ac07-a30983e3fb90_N979K-XWD77-YW3GB-HBGH6-D3%f%2MH_205_X23-15042_blZopkUuayCTgZKH4bOFiisH9GTAHG5/js6UX/qcMWWc3sWNxKSX1OLp1k3h8Xx1cFuvfG/fNAw/I83ssEtPY+A0Gx1JF4QpRqsGOqJ5ruQ2tGW56CJcCVHkB+i46nJAD759gYmy3pEYMQbmpWbhLx3MJ6kvwxKfU+0VCio8k50_0_____OEM:DM_IoTEnterpriseSK +80083eae-7031-4394-9e88-4901973d56fe_P8Q7T-WNK7X-PMFXY-VXHBG-RR%f%K69_206_X23-62084_habUJ0hhAG0P8iIKaRQ74/wZQHyAdFlwHmrejNjOSRG08JeqilJlTM6V8G9UERLJ92/uMDVHIVOPXfN8Zdh8JuYO8oflPnqymIRmff/pU+Gpb871jV2JDA4Cft5gmn+ictKoN4VoSfEZRR+R5hzF2FsoCExDNNw6gLdjtiX94uA_0_____OEM:DM_IoTEnterpriseK ) do ( for /f "tokens=1-9 delims=_" %%A in ("%%#") do ( @@ -2047,7 +1778,7 @@ REM Detect key if %1==key if %osSKU%==%%C if not defined key ( echo "!allapps! !altapplist!" | find /i "%%A" %nul1% && ( -if %%E==1 set notworking=1 +if %%F==1 set notworking=1 set key=%%B ) ) @@ -2055,8 +1786,11 @@ set key=%%B REM Generate ticket if %1==ticket if "%key%"=="%%B" ( -set "SessionIdStr=OSMajorVersion=5;OSMinorVersion=1;OSPlatformId=2;PP=0;Pfn=Microsoft.Windows.%%C.%%D_8wekyb3d8bbwe;PKeyIID=465145217131314304264339481117862266242033457260311819664735280;" -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':sign\:.*';. ([scriptblock]::Create($f[1]))" +set "string=OSMajorVersion=5;OSMinorVersion=1;OSPlatformId=2;PP=0;Pfn=Microsoft.Windows.%%C.%%D_8wekyb3d8bbwe;PKeyIID=465145217131314304264339481117862266242033457260311819664735280;$([char]0)" +for /f "tokens=* delims=" %%i in ('%psc% [conv%f%ert]::ToBas%f%e64String([Text.En%f%coding]::Uni%f%code.GetBytes("""!string!"""^)^)') do set "encoded=%%i" +echo "!encoded!" | find "AAAA" %nul1% || exit /b + +1.0OA3xOriginalProductId=;OA3xOriginalProductKey=;SessionId=!encoded!;TimeStampClient=2022-10-11T12:00:00Z%%E=" >"%tdir%\GenuineTicket" ) ) @@ -2065,77 +1799,6 @@ exit /b ::======================================================================================================================================== -:sign: -$ErrorActionPreference = "Stop" - -function SignProperties { - param ( - $Properties, - $rsa - ) - - $sha256 = [Security.Cryptography.SHA256]::Create() - $bytes = [Text.Encoding]::UTF8.GetBytes($Properties) - $hash = $sha256.ComputeHash($bytes) - - $signature = $rsa.SignHash($hash, [Security.Cryptography.HashAlgorithmName]::SHA256, [Security.Cryptography.RSASignaturePadding]::Pkcs1) - return [Convert]::ToBase64String($signature) - -} - -[byte[]] $key = 0x07,0x02,0x00,0x00,0x00,0xA4,0x00,0x00,0x52,0x53,0x41,0x32,0x00,0x04,0x00,0x00, - 0x01,0x00,0x01,0x00,0x29,0x87,0xBA,0x3F,0x52,0x90,0x57,0xD8,0x12,0x26,0x6B,0x38, - 0xB2,0x3B,0xF9,0x67,0x08,0x4F,0xDD,0x8B,0xF5,0xE3,0x11,0xB8,0x61,0x3A,0x33,0x42, - 0x51,0x65,0x05,0x86,0x1E,0x00,0x41,0xDE,0xC5,0xDD,0x44,0x60,0x56,0x3D,0x14,0x39, - 0xB7,0x43,0x65,0xE9,0xF7,0x2B,0xA5,0xF0,0xA3,0x65,0x68,0xE9,0xE4,0x8B,0x5C,0x03, - 0x2D,0x36,0xFE,0x28,0x4C,0xD1,0x3C,0x3D,0xC1,0x90,0x75,0xF9,0x6E,0x02,0xE0,0x58, - 0x97,0x6A,0xCA,0x80,0x02,0x42,0x3F,0x6C,0x15,0x85,0x4D,0x83,0x23,0x6A,0x95,0x9E, - 0x38,0x52,0x59,0x38,0x6A,0x99,0xF0,0xB5,0xCD,0x53,0x7E,0x08,0x7C,0xB5,0x51,0xD3, - 0x8F,0xA3,0x0D,0xA0,0xFA,0x8D,0x87,0x3C,0xFC,0x59,0x21,0xD8,0x2E,0xD9,0x97,0x8B, - 0x40,0x60,0xB1,0xD7,0x2B,0x0A,0x6E,0x60,0xB5,0x50,0xCC,0x3C,0xB1,0x57,0xE4,0xB7, - 0xDC,0x5A,0x4D,0xE1,0x5C,0xE0,0x94,0x4C,0x5E,0x28,0xFF,0xFA,0x80,0x6A,0x13,0x53, - 0x52,0xDB,0xF3,0x04,0x92,0x43,0x38,0xB9,0x1B,0xD9,0x85,0x54,0x7B,0x14,0xC7,0x89, - 0x16,0x8A,0x4B,0x82,0xA1,0x08,0x02,0x99,0x23,0x48,0xDD,0x75,0x9C,0xC8,0xC1,0xCE, - 0xB0,0xD7,0x1B,0xD8,0xFB,0x2D,0xA7,0x2E,0x47,0xA7,0x18,0x4B,0xF6,0x29,0x69,0x44, - 0x30,0x33,0xBA,0xA7,0x1F,0xCE,0x96,0x9E,0x40,0xE1,0x43,0xF0,0xE0,0x0D,0x0A,0x32, - 0xB4,0xEE,0xA1,0xC3,0x5E,0x9B,0xC7,0x7F,0xF5,0x9D,0xD8,0xF2,0x0F,0xD9,0x8F,0xAD, - 0x75,0x0A,0x00,0xD5,0x25,0x43,0xF7,0xAE,0x51,0x7F,0xB7,0xDE,0xB7,0xAD,0xFB,0xCE, - 0x83,0xE1,0x81,0xFF,0xDD,0xA2,0x77,0xFE,0xEB,0x27,0x1F,0x10,0xFA,0x82,0x37,0xF4, - 0x7E,0xCC,0xE2,0xA1,0x58,0xC8,0xAF,0x1D,0x1A,0x81,0x31,0x6E,0xF4,0x8B,0x63,0x34, - 0xF3,0x05,0x0F,0xE1,0xCC,0x15,0xDC,0xA4,0x28,0x7A,0x9E,0xEB,0x62,0xD8,0xD8,0x8C, - 0x85,0xD7,0x07,0x87,0x90,0x2F,0xF7,0x1C,0x56,0x85,0x2F,0xEF,0x32,0x37,0x07,0xAB, - 0xB0,0xE6,0xB5,0x02,0x19,0x35,0xAF,0xDB,0xD4,0xA2,0x9C,0x36,0x80,0xC6,0xDC,0x82, - 0x08,0xE0,0xC0,0x5F,0x3C,0x59,0xAA,0x4E,0x26,0x03,0x29,0xB3,0x62,0x58,0x41,0x59, - 0x3A,0x37,0x43,0x35,0xE3,0x9F,0x34,0xE2,0xA1,0x04,0x97,0x12,0x9D,0x8C,0xAD,0xF7, - 0xFB,0x8C,0xA1,0xA2,0xE9,0xE4,0xEF,0xD9,0xC5,0xE5,0xDF,0x0E,0xBF,0x4A,0xE0,0x7A, - 0x1E,0x10,0x50,0x58,0x63,0x51,0xE1,0xD4,0xFE,0x57,0xB0,0x9E,0xD7,0xDA,0x8C,0xED, - 0x7D,0x82,0xAC,0x2F,0x25,0x58,0x0A,0x58,0xE6,0xA4,0xF4,0x57,0x4B,0xA4,0x1B,0x65, - 0xB9,0x4A,0x87,0x46,0xEB,0x8C,0x0F,0x9A,0x48,0x90,0xF9,0x9F,0x76,0x69,0x03,0x72, - 0x77,0xEC,0xC1,0x42,0x4C,0x87,0xDB,0x0B,0x3C,0xD4,0x74,0xEF,0xE5,0x34,0xE0,0x32, - 0x45,0xB0,0xF8,0xAB,0xD5,0x26,0x21,0xD7,0xD2,0x98,0x54,0x8F,0x64,0x88,0x20,0x2B, - 0x14,0xE3,0x82,0xD5,0x2A,0x4B,0x8F,0x4E,0x35,0x20,0x82,0x7E,0x1B,0xFE,0xFA,0x2C, - 0x79,0x6C,0x6E,0x66,0x94,0xBB,0x0A,0xEB,0xBA,0xD9,0x70,0x61,0xE9,0x47,0xB5,0x82, - 0xFC,0x18,0x3C,0x66,0x3A,0x09,0x2E,0x1F,0x61,0x74,0xCA,0xCB,0xF6,0x7A,0x52,0x37, - 0x1D,0xAC,0x8D,0x63,0x69,0x84,0x8E,0xC7,0x70,0x59,0xDD,0x2D,0x91,0x1E,0xF7,0xB1, - 0x56,0xED,0x7A,0x06,0x9D,0x5B,0x33,0x15,0xDD,0x31,0xD0,0xE6,0x16,0x07,0x9B,0xA5, - 0x94,0x06,0x7D,0xC1,0xE9,0xD6,0xC8,0xAF,0xB4,0x1E,0x2D,0x88,0x06,0xA7,0x63,0xB8, - 0xCF,0xC8,0xA2,0x6E,0x84,0xB3,0x8D,0xE5,0x47,0xE6,0x13,0x63,0x8E,0xD1,0x7F,0xD4, - 0x81,0x44,0x38,0xBF - -$rsa = New-Object Security.Cryptography.RSACryptoServiceProvider -$rsa.ImportCspBlob($key) -$SessionId = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($env:SessionIdStr + [char]0)) -$PropertiesStr = "OA3xOriginalProductId=;OA3xOriginalProductKey=;SessionId=$SessionId;TimeStampClient=2022-10-11T12:00:00Z" -$SignatureStr = SignProperties $PropertiesStr $rsa - -$xml = @" -1.0$PropertiesStr$SignatureStr -"@ -[System.IO.File]::WriteAllText("$env:ProgramData\Microsoft\Windows\ClipSVC\GenuineTicket\GenuineTicket", ($xml -join ""), [System.Text.Encoding]::ASCII) -:sign: - -::======================================================================================================================================== - :: Below code is used to get alternate edition name and key if current edition doesn't support HWID activation :: 1st column = Current SKU ID diff --git a/MAS/Separate-Files-Version/Activators/KMS38_Activation.cmd b/MAS/Separate-Files-Version/Activators/KMS38_Activation.cmd new file mode 100644 index 0000000..4dbf2ca --- /dev/null +++ b/MAS/Separate-Files-Version/Activators/KMS38_Activation.cmd @@ -0,0 +1,1983 @@ +@set masver=3.2 +@echo off + + + +::============================================================================ +:: +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com +:: +::============================================================================ + + + +:: To activate, run the script with "/KMS38" parameter or change 0 to 1 in below line +set _act=0 + +:: To remove KMS38 protection, run the script with /KMS38-RemoveProtection parameter or change 0 to 1 in below line +set _rem=0 + +:: To disable changing edition if current edition doesn't support KMS38 activation, change the value to 1 from 0 or run the script with "/KMS38-NoEditionChange" parameter +set _NoEditionChange=0 + +:: To run the script in debug mode, change 0 to "/KMS38" in below line +set "_debug=0" + +:: If value is changed in above lines or parameter is used then script will run in unattended mode + + + +::======================================================================================================================================== + +:: Set environment variables, it helps if they are misconfigured in the system + +setlocal EnableExtensions +setlocal DisableDelayedExpansion + +set "PathExt=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC" + +set "SysPath=%SystemRoot%\System32" +set "Path=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" +if exist "%SystemRoot%\Sysnative\reg.exe" ( +set "SysPath=%SystemRoot%\Sysnative" +set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%" +) + +set "ComSpec=%SysPath%\cmd.exe" +set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" + +set re1= +set re2= +set "_cmdf=%~f0" +for %%# in (%*) do ( +if /i "%%#"=="re1" set re1=1 +if /i "%%#"=="re2" set re2=1 +) + +:: 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 + +if exist %SystemRoot%\Sysnative\cmd.exe if not defined re1 ( +setlocal EnableDelayedExpansion +start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" %* re1" +exit /b +) + +:: 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 ( +setlocal EnableDelayedExpansion +start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" %* re2" +exit /b +) + +::======================================================================================================================================== + +:: Debug code + +if "%_debug%" EQU "0" ( +set "nul1=1>nul" +set "nul2=2>nul" +set "nul6=2^>nul" +set "nul=>nul 2>&1" +goto :_debug +) + +set "nul1=" +set "nul2=" +set "nul6=" +set "nul=" + +@echo on +@prompt $G +@call :_debug "%_debug%" >"%~dp0_tmp.log" 2>&1 +@cmd /u /c type "%~dp0_tmp.log">"%~dp0_Debug.log" +@del "%~dp0_tmp.log" +@echo off +@exit /b + +:_debug + +::======================================================================================================================================== + +set "blank=" +set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" + +:: Check if Null service is working, it's important for the batch script + +sc query Null | find /i "RUNNING" +if %errorlevel% NEQ 0 ( +echo: +echo Null service is not running, script may crash... +echo: +echo: +echo Check this webpage for help - %mas%fix_service +echo: +echo: +ping 127.0.0.1 -n 20 +) +cls + +:: Check LF line ending + +pushd "%~dp0" +>nul findstr /v "$" "%~nx0" && ( +echo: +echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. +echo: +echo: +echo Check this webpage for help - %mas%troubleshoot +echo: +echo: +ping 127.0.0.1 -n 20 >nul +popd +exit /b +) +popd + +::======================================================================================================================================== + +cls +color 07 +title KMS38 Activation %masver% + +set _args= +set _elev= +set _unattended=0 + +set _args=%* +if defined _args set _args=%_args:"=% +if defined _args set _args=%_args:re1=% +if defined _args set _args=%_args:re2=% +if defined _args ( +for %%A in (%_args%) do ( +if /i "%%A"=="/KMS38" set _act=1 +if /i "%%A"=="/KMS38-RemoveProtection" set _rem=1 +if /i "%%A"=="/KMS38-NoEditionChange" set _NoEditionChange=1 +if /i "%%A"=="-el" set _elev=1 +) +) + +for %%A in (%_act% %_rem% %_NoEditionChange%) do (if "%%A"=="1" set _unattended=1) + +::======================================================================================================================================== + +set _k38= +call :dk_setvar +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 ( +%eline% +echo Unsupported OS version detected [%winbuild%]. +echo KMS38 activation is only supported on Windows 10/11/Server, build 14393 and later. +echo: +if %winbuild% LSS 10240 ( +call :dk_color %Blue% "Use TSforge activation option from the main menu." +) else ( +call :dk_color %Blue% "Use HWID activation option from the main menu." +) +goto dk_done +) + +::======================================================================================================================================== + +:: Fix special character limitations in path name + +set "_work=%~dp0" +if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%" + +set "_batf=%~f0" +set "_batp=%_batf:'=''%" + +set _PSarg="""%~f0""" -el %_args% +set _PSarg=%_PSarg:'=''% + +set "_ttemp=%userprofile%\AppData\Local\Temp" + +setlocal EnableDelayedExpansion + +::======================================================================================================================================== + +echo "!_batf!" | find /i "!_ttemp!" %nul1% && ( +if /i not "!_work!"=="!_ttemp!" ( +%eline% +echo The script was launched from the temp folder. +echo You are most likely running the script directly from the archive file. +echo: +echo Extract the archive file and launch the script from the extracted folder. +goto dk_done +) +) + +::======================================================================================================================================== + +:: Elevate script as admin and pass arguments and preventing loop + +%nul1% fltmc || ( +if not defined _elev %psc% "start cmd.exe -arg '/c \"!_PSarg!\"' -verb runas" && exit /b +%eline% +echo This script needs admin rights. +echo Right click on this script and select 'Run as administrator'. +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 + +if %winbuild% GEQ 17763 ( +set terminal=1 +) else ( +set terminal= +) + +:: Check if script is running in Terminal app + +if defined terminal ( +set lines=0 +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 +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 ( +start conhost.exe "!_batf!" %_args% -qedit +start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1% +exit /b +) 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 +) + +:skipQE + +::======================================================================================================================================== + +:: Check for updates + +set -= +set old= +set pingp= +set upver=%masver:.=% + +for %%A in ( +activ%-%ated.win +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 ( +echo ________________________________________________ +%eline% +echo Your version of MAS [%masver%] is outdated. +echo ________________________________________________ +echo: +if not %_unattended%==1 ( +echo [1] Get Latest MAS +echo [0] Continue Anyway +echo: +call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" +choice /C:10 /N +if !errorlevel!==2 rem +if !errorlevel!==1 (start %mas% & exit /b) +) +) +cls + +::======================================================================================================================================== + +if %_rem%==1 goto :k_uninstall + +:k_menu + +if %_unattended%==0 ( +cls +if not defined terminal mode 76, 25 +title KMS38 Activation %masver% + +echo: +echo: +echo: +echo: +echo: ______________________________________________________ +echo: +echo [1] KMS38 Activation +echo ____________________________________________ +echo: +echo [2] Remove KM38 Protection +echo: +echo [0] %_exitmsg% +echo: ______________________________________________________ +echo: +call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard [1,2,0]" +choice /C:120 /N +set _el=!errorlevel! +if !_el!==3 exit /b +if !_el!==2 goto :k_uninstall +if !_el!==1 goto :k_menu2 +goto :k_menu +) + +::======================================================================================================================================== + +:k_menu2 + +cls +if not defined terminal ( +mode 110, 34 +if exist "%SysPath%\spp\store_test\" mode 134, 34 +) +title KMS38 Activation %masver% + +echo: +echo Initializing... +call :dk_chkmal + +if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*.mum" if not exist "%SysPath%\clipup.exe" set a_cor=1 +if not exist %SysPath%\sppsvc.exe (set _fmiss=sppsvc.exe) +if not exist %SysPath%\ClipUp.exe if not defined a_cor (set _fmiss=%_fmiss%ClipUp.exe) + +if defined _fmiss ( +%eline% +echo [%_fmiss%] file is missing, aborting... +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 +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +) +goto dk_done +) + +::======================================================================================================================================== + +set spp=SoftwareLicensingProduct +set sps=SoftwareLicensingService + +call :dk_ckeckwmic +call :dk_checksku +call :dk_product +call :dk_sppissue + +::======================================================================================================================================== + +:: Check if system is permanently activated or not + +call :dk_checkperm +if defined _perm ( +cls +echo ___________________________________________________________________________________________ +echo: +call :dk_color2 %_White% " " %Green% "%winos% is already permanently activated." +call :dk_color2 %_White% " " %Gray% "Activation is not required." +echo ___________________________________________________________________________________________ +if %_unattended%==1 goto dk_done +echo: +choice /C:10 /N /M "> [1] Activate Anyway [0] %_exitmsg% : " +if errorlevel 2 exit /b +) +cls + +::======================================================================================================================================== + +:: Check Evaluation version + +set _eval= +set _evalserv= + +if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" set _eval=1 +if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*EvalEdition~*.mum" set _evalserv=1 +if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*EvalCorEdition~*.mum" set _eval=1 & set _evalserv=1 + +if defined _eval ( +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% && ( +%eline% +echo [%winos% ^| %winbuild%] +if defined _evalserv ( +echo Server Evaluation cannot be activated. Convert it to full Server OS. +echo: +call :dk_color %Blue% "Go Back to main menu and use [Change Edition] option." +) else ( +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: +set fixes=%fixes% %mas%evaluation_editions +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" +) +goto dk_done +) +) + +::======================================================================================================================================== + +:: Check clipup.exe for the detection and activation of server cor and acor editions + +if defined a_cor ( +if not exist "!_work!\clipup.exe" ( +%eline% +echo clipup.exe doesn't exist in Server Cor/Acor [No GUI] versions. +echo The file is required for KMS38 activation. +echo Check the below page for instructions on how to activate it. +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%kms38" +goto dk_done +) +) + +:: Check file signature + +if defined a_cor ( +%psc% "if (-not (Get-AuthenticodeSignature -FilePath '!_work!\clipup.exe').IsOSBinary) {Exit 3}" %nul% +if !errorlevel!==3 ( +%eline% +echo Valid digital signature not found in clipup.exe file. +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +goto dk_done +) +) + +::======================================================================================================================================== + +set error= + +cls +echo: +call :dk_showosinfo + +::======================================================================================================================================== + +echo Initiating Diagnostic Tests... + +set "_serv=ClipSVC sppsvc KeyIso Winmgmt" + +:: Client License Service (ClipSVC) +:: Software Protection +:: CNG Key Isolation +:: Windows Management Instrumentation + +call :dk_errorcheck + +::======================================================================================================================================== + +:: Check if GVLK (KMS key) is already installed or not + +call :k_channel + +:: Detect Key + +set key= +set pkey= +set altkey= +set changekey= +set altedition= + +call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f +if defined allapps call :kms38data key +if not defined key call :k_gvlk %nul% +if defined allapps if not defined key call :kms38fallback + +if defined altkey (set key=%altkey%&set changekey=1) + +set /a UBR=0 +if %osSKU%==191 if defined altkey if defined altedition ( +for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR %nul6%') do if not errorlevel 1 set /a UBR=%%b +if %winbuild% LSS 22598 if !UBR! LSS 2788 ( +call :dk_color %Blue% "Windows must be updated to build 19044.2788 or higher for IotEnterpriseS KMS38 activation." +) +) + +if not defined key if defined notfoundaltactID ( +call :dk_color %Red% "Checking Alternate Edition for KMS38 [%altedition% Activation ID Not Found]" +) + +if not defined key if not defined _gvlk ( +echo: +echo [%winos% ^| %winbuild% ^| SKU:%osSKU%] + +if exist "%SysPath%\spp\tokens\skus\%osedition%\*GVLK*.xrm-ms" set sppks=1 + +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% +echo %mas% +) +echo: +goto dk_done +) + +::======================================================================================================================================== + +:: Install key + +echo: +if defined changekey ( +call :dk_color %Blue% "[%altedition%] edition product key will be used to enable KMS38 activation." +echo: +) + +if defined winsub ( +call :dk_color %Blue% "Windows Subscription edition [SKU ID-%slcSKU%] found. Script will activate the base edition [SKU ID-%regSKU%]." +echo: +) + +set _partial= +if not defined key ( +if %_wmic% EQU 1 for /f "tokens=2 delims==" %%# in ('wmic path %spp% where "ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and PartialProductKey<>null AND LicenseDependsOn is NULL" Get PartialProductKey /value %nul6%') do set "_partial=%%#" +if %_wmic% EQU 0 for /f "tokens=2 delims==" %%# in ('%psc% "(([WMISEARCHER]'SELECT PartialProductKey FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).PartialProductKey | %% {echo ('PartialProductKey='+$_)}" %nul6%') do set "_partial=%%#" +call echo Checking Installed Product Key [Partial Key - %%_partial%%] [Volume:GVLK] +) + +if defined key ( +set generickey=1 +call :dk_inskey "[%key%]" +) + +::======================================================================================================================================== + +:: Check activation ID for setting specific KMS host + +set app= +if %_wmic% EQU 1 for /f "tokens=2 delims==" %%a in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL AND LicenseDependsOn is NULL) get ID /VALUE" %nul6%') do call set "app=%%a" +if %_wmic% EQU 0 for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND Description like ''%%KMSCLIENT%%'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).ID | %% {echo ('ID='+$_)}" %nul6%') do call set "app=%%a" + +if not defined app ( +call :dk_color %Red% "Checking Installed GVLK Activation ID [Not Found] Aborting..." +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +goto :dk_done +) + +::======================================================================================================================================== + +:: Set specific KMS host to Local Host +:: By doing this, global KMS IP can not replace KMS38 activation but can be used with Office and other Windows Editions + +echo: +%nul% reg delete "HKLM\%specific_kms%" /f +%nul% reg delete "HKU\S-1-5-20\%specific_kms%" /f + +%nul% reg query "HKLM\%specific_kms%" && ( +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regdel\:.*';iex ($f[1])" +%nul% reg delete "HKLM\%specific_kms%" /f +) + +set k_error= +%nul% reg add "HKLM\%specific_kms%\%app%" /f /v KeyManagementServiceName /t REG_SZ /d "127.0.0.2" || set k_error=1 +%nul% reg add "HKLM\%specific_kms%\%app%" /f /v KeyManagementServicePort /t REG_SZ /d "1688" || set k_error=1 + +if not defined k_error ( +echo Adding Specific KMS Host [LocalHost 127.0.0.2] [Successful] +) else ( +call :dk_color %Red% "Adding Specific KMS Host [LocalHost 127.0.0.2] [Failed]" +) + +::======================================================================================================================================== + +:: Copy clipup.exe to System32 directory to activate Server Cor/Acor editions + +if defined a_cor ( +set "_clipup=%systemroot%\System32\clipup.exe" +pushd "!_work!\" +copy /y /b "ClipUp.exe" "!_clipup!" %nul% +popd + +echo: +if exist "!_clipup!" ( +echo Copying clipup.exe File to [%systemroot%\System32\] [Successful] +) else ( +call :dk_color %Red% "Copying clipup.exe File to [%systemroot%\System32\] [Failed] Aborting..." +goto :k_final +) +) + +::======================================================================================================================================== + +:: Generate GenuineTicket.xml and apply +:: In some cases clipup -v -o method fails and in some cases service restart method fails as well +:: To maximize success rate and get better error details, script will install tickets two times (service restart + clipup -v -o) + +set "tdir=%ProgramData%\Microsoft\Windows\ClipSVC\GenuineTicket" +if not exist "%tdir%\" md "%tdir%\" %nul% + +if exist "%tdir%\Genuine*" del /f /q "%tdir%\Genuine*" %nul% +if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul% +if exist "%ProgramData%\Microsoft\Windows\ClipSVC\Install\Migration\*" del /f /q "%ProgramData%\Microsoft\Windows\ClipSVC\Install\Migration\*" %nul% + +:: Signature value is as it is, it's not encoded +:: Session ID is in Base64 encoded format. It's decoded value is "OSMajorVersion=5;OSMinorVersion=1;OSPlatformId=2;PP=0;GVLKExp=2038-01-19T03:14:07Z;DownlevelGenuineState=1;" +:: Check mass grave [.] dev/kms38#manual-activation to see how it's generated + +set "signature=C52iGEoH+1VqzI6kEAqOhUyrWuEObnivzaVjyef8WqItVYd/xGDTZZ3bkxAI9hTpobPFNJyJx6a3uriXq3HVd7mlXfSUK9ydeoUdG4eqMeLwkxeb6jQWJzLOz41rFVSMtBL0e+ycCATebTaXS4uvFYaDHDdPw2lKY8ADj3MLgsA=" +set "sessionId=TwBTAE0AYQBqAG8AcgBWAGUAcgBzAGkAbwBuAD0ANQA7AE8AUwBNAGkAbgBvAHIAVgBlAHIAcwBpAG8AbgA9ADEAOwBPAFMAUABsAGEAdABmAG8AcgBtAEkAZAA9ADIAOwBQAFAAPQAwADsARwBWAEwASwBFAHgAcAA9ADIAMAAzADgALQAwADEALQAxADkAVAAwADMAOgAxADQAOgAwADcAWgA7AEQAbwB3AG4AbABlAHYAZQBsAEcAZQBuAHUAaQBuAGUAUwB0AGEAdABlAD0AMQA7AAAA" +1.0OA3xOriginalProductId=;OA3xOriginalProductKey=;SessionId=%sessionId%;TimeStampClient=2022-10-11T12:00:00Z%signature%" >"%tdir%\GenuineTicket" + +copy /y /b "%tdir%\GenuineTicket" "%tdir%\GenuineTicket.xml" %nul% + +if not exist "%tdir%\GenuineTicket.xml" ( +call :dk_color %Red% "Generating GenuineTicket.xml [Failed, aborting...]" +if exist "%tdir%\Genuine*" del /f /q "%tdir%\Genuine*" %nul% +goto :k_final +) else ( +echo Generating GenuineTicket.xml [Successful] +) + +set "_xmlexist=if exist "%tdir%\GenuineTicket.xml"" + +:: Stop sppsvc + +%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null" + +%_xmlexist% ( +%psc% "Start-Job { Restart-Service ClipSVC } | Wait-Job -Timeout 20 | Out-Null" +%_xmlexist% timeout /t 2 %nul% +%_xmlexist% timeout /t 2 %nul% + +%_xmlexist% ( +set error=1 +if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul% +call :dk_color %Gray% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]" +) +) + +copy /y /b "%tdir%\GenuineTicket" "%tdir%\GenuineTicket.xml" %nul% +clipup -v -o + +set rebuildinfo= + +if not exist %ProgramData%\Microsoft\Windows\ClipSVC\tokens.dat ( +set error=1 +set rebuildinfo=1 +call :dk_color %Red% "Checking ClipSVC tokens.dat [Not Found]" +) + +%_xmlexist% ( +set error=1 +set rebuildinfo=1 +call :dk_color %Red% "Installing GenuineTicket.xml [Failed With clipup -v -o]" +) + +if exist "%ProgramData%\Microsoft\Windows\ClipSVC\Install\Migration\*.xml" ( +set error=1 +set rebuildinfo=1 +call :dk_color %Red% "Checking Ticket Migration [Failed]" +) + +if not defined showfix if defined rebuildinfo ( +set showfix=1 +call :dk_color %Blue% "%_fixmsg%" +) + +if exist "%tdir%\Genuine*" del /f /q "%tdir%\Genuine*" %nul% + +::========================================================================================================================================== + +call :dk_product + +echo: +echo Activating... +echo: + +call :k_checkexp +if defined _k38 ( +call :k_actinfo +goto :k_final +) + +:: Clear 180 Days KMS Activation lock with Windows SKU specific rearm and without the need to restart the system + +if %_wmic% EQU 1 wmic path %spp% where ID='%app%' call ReArmsku %nul% +if %_wmic% EQU 0 %psc% "$null=([WMI]'%spp%=''%app%''').ReArmsku()" %nul% + +if %errorlevel%==0 ( +echo Applying SKU-ID Rearm [Successful] +) else ( +call :dk_color %Red% "Applying SKU-ID Rearm [Failed]" +) +call :dk_refresh + +echo: +call :k_checkexp +if defined _k38 ( +call :k_actinfo +goto :k_final +) + +call :dk_color %Red% "Activation Failed" +if not defined error call :dk_color %Blue% "%_fixmsg%" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" + +::======================================================================================================================================== + +:k_final + +:: Remove the specific KMS host (LocalHost) added by the script if activation is not completed + +echo: +if not defined _k38 ( +%nul% reg delete "HKLM\%specific_kms%" /f +%nul% reg delete "HKU\S-1-5-20\%specific_kms%" /f +%nul% reg query "HKLM\%specific_kms%" && ( +call :dk_color %Red% "Removing the Added Specific KMS Host [Failed]" +) || ( +echo Removing the Added Specific KMS Host [Successful] +) +) + +:: Protect KMS38 if opted by the user and conditions are correct + +if defined _k38 ( +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regdel\:.*';& ([ScriptBlock]::Create($f[1])) -protect" +%nul% reg delete "HKLM\%specific_kms%" /f +%nul% reg query "HKLM\%specific_kms%" && ( +echo Protect KMS38 From KMS [Successful] [Locked a Registry Key] +) || ( +call :dk_color %Red% "Protect KMS38 From KMS [Failed to Lock a Registry Key]" +) +) + +:: clipup.exe does not exist in server cor and acor editions by default, it was copied there with this script + +if defined a_cor if exist "%_clipup%" del /f /q "%_clipup%" %nul% + +if defined a_cor ( +if exist "%_clipup%" ( +call :dk_color %Red% "Deleting Copied clipup.exe File [Failed]" +) else ( +echo Deleting Copied clipup.exe File [Successful] +) +) + +for %%# in (407) do if %osSKU%==%%# ( +call :dk_color %Red% "%winos% does not support activation on non-azure platforms." +) + +:: Trigger reevaluation of SPP's Scheduled Tasks + +if defined _k38 ( +call :dk_reeval %nul% +) +goto :dk_done + +::======================================================================================================================================== + +:k_uninstall + +cls +if not defined terminal mode 99, 28 +title Remove KMS38 Protection %masver% + +%nul% reg delete "HKLM\%specific_kms%" /f +%nul% reg delete "HKU\S-1-5-20\%specific_kms%" /f + +%nul% reg query "HKLM\%specific_kms%" && ( +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regdel\:.*';iex ($f[1])" +%nul% reg delete "HKLM\%specific_kms%" /f +) + +echo: +%nul% reg query "HKLM\%specific_kms%" && ( +call :dk_color %Red% "Removing Specific KMS Host [Failed]" +) || ( +echo Removing Specific KMS Host [Successful] +) + +goto :dk_done + +::======================================================================================================================================== + +:: This code runs to protect/undo below registry key for KMS38 protection +:: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f + +:: KMS38 protection stops 180 days KMS Activation from replacing KMS38 activation + +:regdel: +param ( + [switch]$protect +) + +$SID = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544') +$Admin = ($SID.Translate([System.Security.Principal.NTAccount])).Value + +if($protect) { +$ruleArgs = @("$Admin", "Delete, SetValue", "ContainerInherit", "None", "Deny") +} else { +$ruleArgs = @("$Admin", "FullControl", "Allow") +} + +$path = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f' +$key = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64').OpenSubKey($path, 'ReadWriteSubTree', 'ChangePermissions') +$acl = $key.GetAccessControl() + +$rule = [System.Security.AccessControl.RegistryAccessRule]::new.Invoke($ruleArgs) +$acl.ResetAccessRule($rule) +$key.SetAccessControl($acl) +:regdel: + +::======================================================================================================================================== + +:: Set variables + +:dk_setvar + +set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe +set psc=%ps% -nop -c +set winbuild=1 +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 +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) + +echo "%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%" | find /i "ARM64" %nul1% && (if %winbuild% LSS 21277 set ps32onArm=1) + +if %_NCS% EQU 1 ( +for /F %%a in ('echo prompt $E ^| cmd') do set "esc=%%a" +set "Red="41;97m"" +set "Gray="100;97m"" +set "Green="42;97m"" +set "Blue="44;97m"" +set "White="107;91m"" +set "_Red="40;91m"" +set "_White="40;37m"" +set "_Green="40;92m"" +set "_Yellow="40;93m"" +) else ( +set "Red="Red" "white"" +set "Gray="Darkgray" "white"" +set "Green="DarkGreen" "white"" +set "Blue="Blue" "white"" +set "White="White" "Red"" +set "_Red="Black" "Red"" +set "_White="Black" "Gray"" +set "_Green="Black" "Green"" +set "_Yellow="Black" "Yellow"" +) + +set "nceline=echo: &echo ==== ERROR ==== &echo:" +set "eline=echo: &call :dk_color %Red% "==== ERROR ====" &echo:" +if %~z0 GEQ 200000 ( +set "_exitmsg=Go back" +set "_fixmsg=Go back to Main Menu, select Troubleshoot and run Fix Licensing option." +) else ( +set "_exitmsg=Exit" +set "_fixmsg=In MAS folder, run Troubleshoot script and select Fix Licensing option." +) +exit /b + +:: Show OS info + +:dk_showosinfo + +for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE') do set osarch=%%b + +for /f "tokens=6-7 delims=[]. " %%i in ('ver') do if not "%%j"=="" ( +set fullbuild=%%i.%%j +) else ( +for /f "tokens=3" %%G in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR" %nul6%') do if not errorlevel 1 set /a "UBR=%%G" +for /f "skip=2 tokens=3,4 delims=. " %%G in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v BuildLabEx') do ( +if defined UBR (set "fullbuild=%%G.!UBR!") else (set "fullbuild=%%G.%%H") +) +) + +echo Checking OS Info [%winos% ^| %fullbuild% ^| %osarch%] +exit /b + +:: Check SKU value + +:dk_checksku + +call :dk_reflection + +set osSKU= +set slcSKU= +set wmiSKU= +set regSKU= +set winsub= + +if %winbuild% GEQ 14393 (set info=Kernel-BrandingInfo) else (set info=Kernel-ProductInfo) +set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 'Public, Static', 1, [int], @([String], [int].MakeByRefType()), 1, 3); +set d1=%d1% $Sku = 0; [void]$TypeBuilder.CreateType()::SLGetWindowsInformationDWORD('%info%', [ref]$Sku); $Sku +for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set slcSKU=%%s) +set slcSKU=%slcSKU: =% +if "%slcSKU%"=="0" set slcSKU= +for /f "tokens=* delims=0123456789" %%a in ("%slcSKU%") do (if not "[%%a]"=="[]" set slcSKU=) + +for /f "tokens=3 delims=." %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" /v OSProductPfn %nul6%') do set "regSKU=%%a" +if %_wmic% EQU 1 for /f "tokens=2 delims==" %%a in ('"wmic Path Win32_OperatingSystem Get OperatingSystemSKU /format:LIST" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" +if %_wmic% EQU 0 for /f "tokens=1" %%a in ('%psc% "([WMI]'Win32_OperatingSystem=@').OperatingSystemSKU" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" + +if %winbuild% GEQ 15063 %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';iex ($f[1])" %nul2% | find /i "Subscription_is_activated" %nul% && ( +if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" ( +set winsub=1 +set osSKU=%regSKU% +) +) + +if not defined osSKU set osSKU=%slcSKU% +if not defined osSKU set osSKU=%wmiSKU% +if not defined osSKU set osSKU=%regSKU% +exit /b + +:: Get Windows Subscription status + +:winsubstatus: +$DM = [AppDomain]::CurrentDomain.DefineDynamicAssembly(6, 1).DefineDynamicModule(4).DefineType(2) +[void]$DM.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) +$m = [System.Runtime.InteropServices.Marshal] +$p = $m::AllocHGlobal(12) +$r = $DM.CreateType()::ClipGetSubscriptionStatus([ref]$p) +if ($r -eq 0) { + $enabled = $m::ReadInt32($p) + if ($enabled -ge 1) { + $state = $m::ReadInt32($p, 8) + if ($state -eq 1) { + "Subscription_is_activated." + } + } +} +:winsubstatus: + +:: Check KMS activation status + +:k_actinfo + +set xpr= +for /f "tokens=* delims=" %%# in ('%psc% "$([DateTime]::Now.addMinutes(%gpr%)).ToString('yyyy-MM-dd HH:mm:ss')" %nul6%') do set "xpr=%%#" +call :dk_color %Green% "%winos% is activated till !xpr!" +exit /b + +:: Check remaining KMS activation grace period + +:k_checkexp + +set gpr=0 +if %_wmic% EQU 1 for /f "tokens=2 delims==" %%# in ('"wmic path %spp% where (ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and Description like '%%KMSCLIENT%%' and PartialProductKey is not NULL AND LicenseDependsOn is NULL) get GracePeriodRemaining /VALUE" %nul6%') do set "gpr=%%#" +if %_wmic% EQU 0 for /f "tokens=2 delims==" %%# in ('%psc% "(([WMISEARCHER]'SELECT GracePeriodRemaining FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND Description like ''%%KMSCLIENT%%'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).GracePeriodRemaining | %% {echo ('GracePeriodRemaining='+$_)}" %nul6%') do set "gpr=%%#" +if %gpr% GTR 259200 (set _k38=1) else (set _k38=) +exit /b + +:: Get Windows permanent activation status + +:dk_checkperm + +if %_wmic% EQU 1 wmic path %spp% where (LicenseStatus='1' and GracePeriodRemaining='0' and PartialProductKey is not NULL AND LicenseDependsOn is NULL) get Name /value %nul2% | findstr /i "Windows" %nul1% && set _perm=1||set _perm= +if %_wmic% EQU 0 %psc% "(([WMISEARCHER]'SELECT Name FROM %spp% WHERE LicenseStatus=1 AND GracePeriodRemaining=0 AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).Name | %% {echo ('Name='+$_)}" %nul2% | findstr /i "Windows" %nul1% && set _perm=1||set _perm= +exit /b + +:: Refresh license status + +:dk_refresh + +if %_wmic% EQU 1 wmic path %sps% where __CLASS='%sps%' call RefreshLicenseStatus %nul% +if %_wmic% EQU 0 %psc% "$null=(([WMICLASS]'%sps%').GetInstances()).RefreshLicenseStatus()" %nul% +exit /b + +:: Install Key + +:dk_inskey + +if %_wmic% EQU 1 wmic path %sps% where __CLASS='%sps%' call InstallProductKey ProductKey="%key%" %nul% +if %_wmic% EQU 0 %psc% "try { $null=(([WMISEARCHER]'SELECT Version FROM %sps%').Get()).InstallProductKey('%key%'); exit 0 } catch { exit $_.Exception.InnerException.HResult }" %nul% +set keyerror=%errorlevel% +cmd /c exit /b %keyerror% +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 %sps%==SoftwareLicensingService call :dk_refresh +echo %keyecho% %~1 [Successful] +) else ( +call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" +if not defined error ( +if defined altapplist call :dk_color %Red% "Activation ID not found for this key." +call :dk_color %Blue% "%_fixmsg%" +set showfix=1 +) +set error=1 +) + +set generickey= +exit /b + +:: Get Windows installed key channel + +:k_channel + +set _gvlk= +if %_wmic% EQU 1 for /f "tokens=2 delims==" %%# in ('wmic path %spp% where "ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' and PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL and Description like '%%KMSCLIENT%%'" Get Name /value %nul6%') do (echo %%# findstr /i "Windows" %nul1% && set _gvlk=1) +if %_wmic% EQU 0 for /f "tokens=2 delims==" %%# in ('%psc% "(([WMISEARCHER]'SELECT Name FROM %spp% WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL and Description like ''%%KMSCLIENT%%''').Get()).Name | %% {echo ('Name='+$_)}" %nul6%') do (echo %%# findstr /i "Windows" %nul1% && set _gvlk=1) +exit /b + +:: Get all products Activation IDs + +:dk_actids + +set allapps= +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 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM %spp% WHERE ApplicationID=''%1''').Get()).ID ^| %% {echo ('ID='+$_)}" %nul6%')" +%chkapp% do (if defined allapps (call set "allapps=!allapps! %%a") else (call set "allapps=%%a")) +exit /b + +:: Get installed products Activation IDs + +:dk_actid + +set apps= +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'' AND PartialProductKey IS NOT NULL').Get()).ID ^| %% {echo ('ID='+$_)}" %nul6%')" +%chkapp% do (if defined apps (call set "apps=!apps! %%a") else (call set "apps=%%a")) +exit /b + +:: Trigger reevaluation, it helps in updating SPP tasks + +: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 + +set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState" +reg delete "%ruleskey%" /v "State" /f %nul% +reg delete "%ruleskey%" /v "SuppressRulesEngine" /f %nul% + +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 d1=%r2% [void]$TB.CreateType()::SLpTriggerServiceWorker(0, 0, 'reeval', 0) +%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null; %d1%" +exit /b + +:: Install License files using Powershell/WMI instead of slmgr.vbs + +:xrm: +function InstallLicenseFile($Lsc) { + try { + $null = $sls.InstallLicense([IO.File]::ReadAllText($Lsc)) + } catch { + $host.SetShouldExit($_.Exception.HResult) + } +} +function InstallLicenseArr($Str) { + $a = $Str -split ';' + ForEach ($x in $a) {InstallLicenseFile "$x"} +} +function InstallLicenseDir($Loc) { + Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName} +} +function ReinstallLicenses() { + $Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens") + foreach ($Path in $Paths) { + if (Test-Path $Path) { InstallLicenseDir "$Path" } + } +} +:xrm: + +:: Check wmic.exe + +:dk_ckeckwmic + +if %winbuild% LSS 9200 (set _wmic=1&exit /b) +set _wmic=0 +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 +) +exit /b + +:: Show info for potential script stuck scenario + +:dk_sppissue + +sc start %_slser% %nul% +set spperror=%errorlevel% + +if %spperror% NEQ 1056 if %spperror% NEQ 0 ( +%eline% +echo sc start %_slser% [Error Code: %spperror%] +) + +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'}" +exit /b + +:: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) + +:dk_product + +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 winos= +for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) +echo "%winos%" | find /i "Windows" %nul1% || ( +for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName %nul6%') do set "winos=%%b" +if %winbuild% GEQ 22000 ( +set winos=!winos:Windows 10=Windows 11! +) +) + +if not defined winsub exit /b + +:: Check base edition product name if Windows subscription license is found + +for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b +set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('GetEditionNameFromId', 'pkeyhelper.dll', 'Public, Static', 1, [int], @([int], [IntPtr].MakeByRefType()), 1, 3); +set d1=%d1% $out = 0; [void]$TypeBuilder.CreateType()::GetEditionNameFromId(%regSKU%, [ref]$out);$s=[Runtime.InteropServices.Marshal]::PtrToStringUni($out); $s + +for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 ( +if %winbuild% GEQ 22000 ( +set winos=Windows 11 %%a +) else ( +set winos=Windows 10 %%a +) +) +exit /b + +:: Common lines used in PowerShell reflection code + +:dk_reflection + +set ref=$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1); +set ref=%ref% $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False); +set ref=%ref% $TypeBuilder = $ModuleBuilder.DefineType(0); +exit /b + +::======================================================================================================================================== + +:: Get Product Key from pkeyhelper.dll for future new editions +:: It works on Windows 10 1803 (17134) and later builds. + +:k_pkey + +call :dk_reflection + +set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('SkuGetProductKeyForEdition', 'pkeyhelper.dll', 'Public, Static', 1, [int], @([int], [String], [String].MakeByRefType(), [String].MakeByRefType()), 1, 3); +set d1=%d1% $out = ''; [void]$TypeBuilder.CreateType()::SkuGetProductKeyForEdition(%1, %2, [ref]$out, [ref]$null); $out + +set pkey= +for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkey=%%a) +exit /b + +:: Get channel name for the key which was extracted from pkeyhelper.dll + +:k_pkeychannel + +set k=%1 +set m=[Runtime.InteropServices.Marshal] +set p=%SysPath%\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms + +set d1=%ref% [void]$TypeBuilder.DefinePInvokeMethod('PidGenX', 'pidgenx.dll', 'Public, Static', 1, [int], @([String], [String], [String], [int], [IntPtr], [IntPtr], [IntPtr]), 1, 3); +set d1=%d1% $r = [byte[]]::new(0x04F8); $r[0] = 0xF8; $r[1] = 0x04; $f = %m%::AllocHGlobal(0x04F8); %m%::Copy($r, 0, $f, 0x04F8); +set d1=%d1% [void]$TypeBuilder.CreateType()::PidGenX('%k%', '%p%', '00000', 0, 0, 0, $f); %m%::Copy($f, $r, 0, 0x04F8); %m%::FreeHGlobal($f); [Text.Encoding]::Unicode.GetString($r, 1016, 128) + +set pkeychannel= +for /f %%a in ('%psc% "%d1%"') do if not errorlevel 1 (set pkeychannel=%%a) +exit /b + +:k_gvlk + +for %%# in (pkeyhelper.dll) do @if "%%~$PATH:#"=="" exit /b +for %%# in (Volume:GVLK) do ( +call :k_pkey %osSKU% '%%#' +if defined pkey call :k_pkeychannel !pkey! +if /i "!pkeychannel!"=="%%#" ( +set key=!pkey! +exit /b +) +) +exit /b + +::======================================================================================================================================== + +:dk_chkmal + +:: Many users unknowingly download mal-ware by using activators found through Google search. +:: This code aims to notify users that their system has been affected by mal-ware. + +set w= +set results= +if exist "%ProgramFiles%\KM%w%Spico" set pupfound= KM%w%Spico +if not defined pupfound ( +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\taskcache\tasks" /f Path /s | find /i "AutoPico" %nul% && set pupfound= KM%w%Spico +) + +set hcount=0 +for %%# in (avira.com kaspersky.com virustotal.com mcafee.com) do ( +find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1) +if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]" + +sc start %_slser% %nul% +echo "%errorlevel%" | findstr "577 225" %nul% && ( +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 "%results%%pupfound%"=="" ( +if defined pupfound call :dk_color %Gray% "Checking PUP Activators [Found%pupfound%]" +if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..." +if defined results call :dk_color %Red% "%results%" +set fixes=%fixes% %mas%remove_mal%w%ware +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" +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 + +::======================================================================================================================================== + +:dk_errorcheck + +set showfix= +call :dk_chkmal + +:: Check Sandboxing + +sc query Null %nul% || ( +set error=1 +set showfix=1 +call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly.]" +call :dk_color %Blue% "If you are using any third-party antivirus, check if it is blocking the script." +echo: +) + +::======================================================================================================================================== + +:: Check corrupt services + +set serv_cor= +for %%# in (%_serv%) do ( +set _corrupt= +sc start %%# %nul% +if !errorlevel! EQU 1060 set _corrupt=1 +sc query %%# %nul% || set _corrupt=1 +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 +) + +if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#") else (set "serv_cor=%%#")) +) + +if defined serv_cor ( +set error=1 +set showfix=1 +call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" +) + +::======================================================================================================================================== + +:: Check disabled services + +set serv_ste= +for %%# in (%_serv%) do ( +sc start %%# %nul% +if !errorlevel! EQU 1058 (if defined serv_ste (set "serv_ste=!serv_ste! %%#") else (set "serv_ste=%%#")) +) + +:: Change disabled services startup type to default + +set serv_csts= +set serv_cste= + +if defined serv_ste ( +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 %%#==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 %%#==SLsvc sc config %%# start= auto %nul% +if /i %%#==KeyIso sc config %%# start= demand %nul% +if /i %%#==LicenseManager sc config %%# start= demand %nul% +if /i %%#==Winmgmt sc config %%# start= auto %nul% +if !errorlevel!==0 ( +if defined serv_csts (set "serv_csts=!serv_csts! %%#") else (set "serv_csts=%%#") +) else ( +if defined serv_cste (set "serv_cste=!serv_cste! %%#") else (set "serv_cste=%%#") +) +) +) + +if defined serv_csts call :dk_color %Gray% "Enabling Disabled Services [Successful] [%serv_csts%]" + +if defined serv_cste ( +set error=1 +call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" +) + +::======================================================================================================================================== + +:: Check if the services are able to run or not +:: Workarounds are added to get correct status and error code because sc query doesn't output correct results in some conditions + +set serv_e= +for %%# in (%_serv%) do ( +set errorcode= +set checkerror= + +sc query %%# | find /i "RUNNING" %nul% || ( +%psc% "Start-Job { Start-Service %%# } | Wait-Job -Timeout 20 | Out-Null" +set errorcode=!errorlevel! +sc query %%# | find /i "RUNNING" %nul% || set checkerror=1 +) + +sc start %%# %nul% +if !errorlevel! NEQ 1056 if !errorlevel! NEQ 0 (set errorcode=!errorlevel!&set checkerror=1) +if defined checkerror if defined serv_e (set "serv_e=!serv_e!, %%#-!errorcode!") else (set "serv_e=%%#-!errorcode!") +) + +if defined serv_e ( +set error=1 +call :dk_color %Red% "Starting Services [Failed] [%serv_e%]" +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." +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 +) +) + +::======================================================================================================================================== + +:: Various error checks + +if defined safeboot_option ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option%] " %Blue% "[Safe mode found. Run in normal mode.]" +) + + +:: 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) + +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 showfix=1 +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" +) +) + + +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking WinPE " %Blue% "[WinPE mode found. Run in normal mode.]" +) + + +set wpainfo= +set wpaerror= +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1])" %nul6%') do (set wpainfo=%%a) +echo "%wpainfo%" | find /i "Error Found" %nul% && ( +set error=1 +set wpaerror=1 +call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" +) || ( +echo Checking WPA Registry Count [%wpainfo%] +) + + +if not defined notwinact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || ( +call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]" +set fixes=%fixes% %mas%evaluation_editions +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" +) +) + + +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%')" +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 + +if not %osedition%==0 ( +if "%osSKU%"=="164" set osedition=ProfessionalEducation +if "%osSKU%"=="165" set osedition=ProfessionalEducationN +) + +if not defined notwinact ( +if %osedition%==0 ( +call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" +) 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" ( +set skunotfound=1 +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%Edition*.mum" ( +call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" +) +) +) +) + + +if %_wmic% EQU 1 wmic path %sps% get Version %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% +cmd /c exit /b %error_code% +if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" +if %error_code% NEQ 0 ( +set error=1 +call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] %error_code%" +) + + +set wmifailed= +if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 +echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants +if defined wmifailed ( +set error=1 +call :dk_color %Red% "Checking WMI [Not Working]" +if not defined showfix call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." +set showfix=1 +) + + +if not defined notwinact ( +if %winbuild% GEQ 10240 ( +%nul% set /a "sum=%slcSKU%+%regSKU%+%wmiSKU%" +set /a "sum/=3" +if not "!sum!"=="%slcSKU%" ( +call :dk_color %Gray% "Checking SLC/WMI/REG SKU [Difference Found - SLC:%slcSKU% WMI:%wmiSKU% Reg:%regSKU%]" +) +) else ( +%nul% set /a "sum=%slcSKU%+%wmiSKU%" +set /a "sum/=2" +if not "!sum!"=="%slcSKU%" ( +call :dk_color %Gray% "Checking SLC/WMI SKU [Difference Found - SLC:%slcSKU% WMI:%wmiSKU%]" +) +) +) + +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Rearm " %Blue% "[System Restart Is Required]" +) + + +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System Restart Is Required]" +) + + +:: 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" ( +echo Checking Eval WLMS Service [Found] +) + + +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( +set error=1 +set showfix=1 +call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" +set fixes=%fixes% %mas%in-place_repair_upgrade +call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +) + + +for %%# in (SppEx%w%tComObj.exe SLsvc.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=%%#")) +) +if defined _sppint ( +echo %_sppint% | find /i "PerfOptions" %nul% && ( +call :dk_color %Red% "Checking SPP Interference In IFEO [%_sppint% - System might deactivate later]" +if not defined showfix call :dk_color %Blue% "%_fixmsg%" +set showfix=1 +) || ( +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 ( +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]" +%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null" +) + + +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% || ( +call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]" +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" +set error=1 +set showfix=1 +) + + +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" +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" ( +set toerr=1 +set error=1 +set showfix=1 +call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +) +) + +:: 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%\" ( +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% 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)';" +set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" +set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" +set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" +%psc% "!d!" %nul% +if exist "%tokenstore%\" ( +call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" +) else ( +call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" +set error=1 +set showfix=1 +) +) + + +if not defined notwinact ( +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +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% +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined apps ( +set "_notfoundids=Key Not Installed / Act ID Not Found" +call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined allapps ( +set error=1 +set "_notfoundids=Not found" +) +call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]" +) +) +) + + +if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( +set error=1 +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" ( +%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) +echo !taskinfo! | find /i "Ready" %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 +if "!taskinfo!"=="" set "taskinfo=Not Found" +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." +) +) +) + + +:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. + +set permerror= +if %winbuild% GEQ 9200 if not defined ps32onArm ( +for %%# in ( +"%tokenstore%+FullControl" +"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" +"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" +) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( +%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% +if !errorlevel!==2 ( +if "%%A"=="%tokenstore%" ( +set "permerror=Error Found In Token Folder" +) else ( +set "permerror=Error Found In SPP Registries" +) +) +) + +REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application + +if not defined permerror ( +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( +set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" +reg query "!pol!" %nul% || reg add "!pol!" %nul% +%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% +if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" +) +) + +if defined permerror ( +set error=1 +call :dk_color %Red% "Checking SPP Permissions [!permerror!]" +if not defined showfix call :dk_color %Blue% "%_fixmsg%" +set showfix=1 +) +) + + +:: If required services are not disabled or corrupted + if there is any error + SoftwareLicensingService errorlevel is not Zero + no fix was shown before + +if not defined serv_cor if not defined serv_cste if defined error if /i not %error_code%==0 if not defined showfix ( +if not defined permerror if defined wpaerror (call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." & set showfix=1) +if not defined showfix ( +set showfix=1 +call :dk_color %Blue% "%_fixmsg%" +if not defined permerror call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." +) +) + +if not defined showfix if defined wpaerror ( +set showfix=1 +call :dk_color %Blue% "If activation fails then go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." +) + +exit /b + +:: This code checks for invalid registry keys in HKLM\SYSTEM\WPA. This issue may appear even on healthy systems + +:wpatest: +$wpaKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("SYSTEM\\WPA") +$count = 0 +foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { + if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + $count++ + } +} +$osVersion = [System.Environment]::OSVersion.Version +$minBuildNumber = 14393 +if ($osVersion.Build -ge $minBuildNumber) { + $subkeyHashTable = @{} + foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { + if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + $keyNumber = $subkeyName -replace '.*-', '' + $subkeyHashTable[$keyNumber] = $true + } + } + for ($i=1; $i -le $count; $i++) { + if (-not $subkeyHashTable.ContainsKey("$i")) { + Write-Output "Total Keys $count. Error Found - $i key does not exist." + $wpaKey.Close() + exit + } + } +} +$wpaKey.GetSubKeyNames() | ForEach-Object { + if ($_ -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($PSVersionTable.PSVersion.Major -lt 3) { + cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1" + if ($LASTEXITCODE -ne 0) { + Write-Host "Total Keys $count. Error Found - Binary Data is corrupt." + $wpaKey.Close() + exit + } + } else { + $subkey = $wpaKey.OpenSubKey($_) + $p = $subkey.GetValueNames() + if (($p | Where-Object { $subkey.GetValueKind($_) -eq [Microsoft.Win32.RegistryValueKind]::Binary }).Count -eq 0) { + Write-Host "Total Keys $count. Error Found - Binary Data is corrupt." + $wpaKey.Close() + exit + } + } + } +} +$count +$wpaKey.Close() +:wpatest: + +::======================================================================================================================================== + +: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 + +echo: +if %_unattended%==1 timeout /t 2 & exit /b + +if defined fixes ( +call :dk_color %White% "Follow ALL the ABOVE blue lines. " +call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" +choice /C:10 /N +if !errorlevel!==2 exit /b +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) +) + +if defined terminal ( +call :dk_color %_Yellow% "Press [0] key to %_exitmsg%..." +choice /c 0 /n +) else ( +call :dk_color %_Yellow% "Press any key to %_exitmsg%..." +pause %nul1% +) + +exit /b + +::======================================================================================================================================== + +:: 1st column = Activation ID +:: 2nd column = GVLK (Generic volume licensing key) +:: 3rd column = SKU ID +:: 4th column = WMI Edition ID (For reference only) +:: 5th column = Build Branch name incase same Edition ID is used in different OS versions with different key (For reference only) +:: Separator = "_" + +:kms38data + +set f= +for %%# in ( +:: Windows 10/11 +73111121-5638-40f6-bc11-f1d7b0d64300_NPPR9-FWDCX-D2C8J-H872K-2Y%f%T43___4_Enterprise +e272e3e2-732f-4c65-a8f0-484747d0d947_DPH2V-TTNVB-4X9Q3-TJR4H-KH%f%JW4__27_EnterpriseN +2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX__48_Professional +a80b5abf-76ad-428b-b05d-a47d2dffeebf_MH37W-N47XK-V7XM9-C7227-GC%f%QG9__49_ProfessionalN +7b9e1751-a8da-4f75-9560-5fadfe3d8e38_3KHY7-WNT83-DGQKR-F7HPR-84%f%4BM__98_CoreN +a9107544-f4a0-4053-a96a-1479abdef912_PVMJN-6DFY6-9CCP6-7BKTT-D3%f%WVR__99_CoreCountrySpecific +cd918a57-a41b-4c82-8dce-1a538e221a83_7HNRX-D7KGG-3K4RQ-4WPJ4-YT%f%DFH_100_CoreSingleLanguage +58e97c99-f377-4ef1-81d5-4ad5522b5fd8_TX9XD-98N7V-6WMQ6-BX7FG-H8%f%Q99_101_Core +e0c42288-980c-4788-a014-c080d2e1926e_NW6C2-QMPVW-D7KKK-3GKT6-VC%f%FB2_121_Education +3c102355-d027-42c6-ad23-2e7ef8a02585_2WH4N-8QGBV-H22JP-CT43Q-MD%f%WWJ_122_EducationN +32d2fab3-e4a8-42c2-923b-4bf4fd13e6ee_M7XTQ-FN8P6-TTKYV-9D4CC-J4%f%62D_125_EnterpriseS_RS5,VB,Ge +2d5a5a60-3040-48bf-beb0-fcd770c20ce0_DCPHK-NFMTC-H88MJ-PFHPY-QJ%f%4BJ_125_EnterpriseS_RS1 +7b51a46c-0c04-4e8f-9af4-8496cca90d5e_WNMTR-4C88C-JK8YV-HQ7T2-76%f%DF9_125_EnterpriseS_TH1 +7103a333-b8c8-49cc-93ce-d37c09687f92_92NFX-8DJQP-P6BBQ-THF9C-7C%f%G2H_126_EnterpriseSN_RS5,VB,Ge +9f776d83-7156-45b2-8a5c-359b9c9f22a3_QFFDN-GRT3P-VKWWX-X7T3R-8B%f%639_126_EnterpriseSN_RS1 +87b838b7-41b6-4590-8318-5797951d8529_2F77B-TNFGY-69QQF-B8YKP-D6%f%9TJ_126_EnterpriseSN_TH1 +82bbc092-bc50-4e16-8e18-b74fc486aec3_NRG8B-VKK3Q-CXVCJ-9G2XF-6Q%f%84J_161_ProfessionalWorkstation +4b1571d3-bafb-4b40-8087-a961be2caf65_9FNHH-K3HBT-3W4TD-6383H-6X%f%YWF_162_ProfessionalWorkstationN +3f1afc82-f8ac-4f6c-8005-1d233e606eee_6TP4R-GNPTD-KYYHQ-7B7DP-J4%f%47Y_164_ProfessionalEducation +5300b18c-2e33-4dc2-8291-47ffcec746dd_YVWGF-BXNMC-HTQYQ-CPQ99-66%f%QFC_165_ProfessionalEducationN +e0b2d383-d112-413f-8a80-97f373a5820c_YYVX9-NTFWV-6MDM3-9PT4T-4M%f%68B_171_EnterpriseG +e38454fb-41a4-4f59-a5dc-25080e354730_44RPN-FTY23-9VTTB-MP9BX-T8%f%4FV_172_EnterpriseGN +ec868e65-fadf-4759-b23e-93fe37f2cc29_CPWHC-NT2C7-VYW78-DHDB2-PG%f%3GK_175_ServerRdsh_RS5 +e4db50ea-bda1-4566-b047-0ca50abc6f07_7NBT4-WGBQX-MP4H7-QXFF8-YP%f%3KX_175_ServerRdsh_RS3 +0df4f814-3f57-4b8b-9a9d-fddadcd69fac_NBTWJ-3DR69-3C4V8-C26MC-GQ%f%9M6_183_CloudE +59eb965c-9150-42b7-a0ec-22151b9897c5_KBN8V-HFGQ4-MGXVD-347P6-PD%f%QGT_191_IoTEnterpriseS_VB,NI +d30136fc-cb4b-416e-a23d-87207abc44a9_6XN7V-PCBDC-BDBRH-8DQY7-G6%f%R44_202_CloudEditionN +ca7df2e3-5ea0-47b8-9ac1-b1be4d8edd69_37D7F-N49CB-WQR8W-TBJ73-FM%f%8RX_203_CloudEdition +:: Windows 2016/19/22/25 LTSC/SAC +7dc26449-db21-4e09-ba37-28f2958506a6_TVRH6-WHNXV-R9WG3-9XRFY-MY%f%832___7_ServerStandard_Ge +9bd77860-9b31-4b7b-96ad-2564017315bf_VDYBN-27WPP-V4HQT-9VMD4-VM%f%K7H___7_ServerStandard_FE +de32eafd-aaee-4662-9444-c1befb41bde2_N69G4-B89J2-4G8F4-WWYCC-J4%f%64C___7_ServerStandard_RS5 +8c1c5410-9f39-4805-8c9d-63a07706358f_WC2BQ-8NRM3-FDDYY-2BFGV-KH%f%KQY___7_ServerStandard_RS1 +c052f164-cdf6-409a-a0cb-853ba0f0f55a_D764K-2NDRG-47T6Q-P8T8W-YP%f%6DF___8_ServerDatacenter_Ge +ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae03_WX4NM-KYWYW-QJJR4-XV3QB-6V%f%M33___8_ServerDatacenter_FE +34e1ae55-27f8-4950-8877-7a03be5fb181_WMDGN-G9PQG-XVVXX-R3X43-63%f%DFG___8_ServerDatacenter_RS5 +21c56779-b449-4d20-adfc-eece0e1ad74b_CB7KF-BWN84-R7R2Y-793K2-8X%f%DDG___8_ServerDatacenter_RS1 +034d3cbb-5d4b-4245-b3f8-f84571314078_WVDHN-86M7X-466P6-VHXV7-YY%f%726__50_ServerSolution_RS5 +2b5a1b0f-a5ab-4c54-ac2f-a6d94824a283_JCKRF-N37P4-C2D82-9YXRT-4M%f%63B__50_ServerSolution_RS1 +7b4433f4-b1e7-4788-895a-c45378d38253_QN4C6-GBJD2-FB422-GHWJK-GJ%f%G2R_110_ServerCloudStorage +8de8eb62-bbe0-40ac-ac17-f75595071ea3_GRFBW-QNDC4-6QBHG-CCK3B-2P%f%R88_120_ServerARM64_RS5 +43d9af6e-5e86-4be8-a797-d072a046896c_K9FYF-G6NCK-73M32-XMVPY-F9%f%DRR_120_ServerARM64_RS4 +39e69c41-42b4-4a0a-abad-8e3c10a797cc_QFND9-D3Y9C-J3KKY-6RPVP-2D%f%PYV_145_ServerDatacenterACor_FE +90c362e5-0da1-4bfd-b53b-b87d309ade43_6NMRW-2C8FM-D24W7-TQWMY-CW%f%H2D_145_ServerDatacenterACor_RS5 +e49c08e7-da82-42f8-bde2-b570fbcae76c_2HXDN-KRXHB-GPYC7-YCKFJ-7F%f%VDG_145_ServerDatacenterACor_RS3 +f5e9429c-f50b-4b98-b15c-ef92eb5cff39_67KN8-4FYJW-2487Q-MQ2J7-4C%f%4RG_146_ServerStandardACor_FE +73e3957c-fc0c-400d-9184-5f7b6f2eb409_N2KJX-J94YW-TQVFB-DG9YT-72%f%4CC_146_ServerStandardACor_RS5 +61c5ef22-f14f-4553-a824-c4b31e84b100_PTXN8-JFHJM-4WC78-MPCBR-9W%f%4KR_146_ServerStandardACor_RS3 +45b5aff2-60a0-42f2-bc4b-ec6e5f7b527e_FCNV3-279Q9-BQB46-FTKXX-9H%f%PRH_168_ServerAzureCor_Ge +8c8f0ad3-9a43-4e05-b840-93b8d1475cbc_6N379-GGTMK-23C6M-XVVTC-CK%f%FRQ_168_ServerAzureCor_FE +a99cc1f0-7719-4306-9645-294102fbff95_FDNH6-VW9RW-BXPJ7-4XTYG-23%f%9TB_168_ServerAzureCor_RS5 +3dbf341b-5f6c-4fa7-b936-699dce9e263f_VP34G-4NPPG-79JTQ-864T4-R3%f%MQX_168_ServerAzureCor_RS1 +c2e946d1-cfa2-4523-8c87-30bc696ee584_XGN3F-F394H-FD2MY-PP6FD-8M%f%CRC_407_ServerTurbine_Ge +19b5e0fb-4431-46bc-bac1-2f1873e4ae73_NTBV8-9K7Q8-V27C6-M2BTV-KH%f%MXV_407_ServerTurbine_RS5 +) do ( +for /f "tokens=1-5 delims=_" %%A in ("%%#") do if %osSKU%==%%C ( +if %1==key if not defined key echo "!allapps!" | find /i "%%A" %nul1% && set key=%%B +) +) +exit /b + +::======================================================================================================================================== + +:: Below code is used to get alternate edition name and key if current edition doesn't support KMS38 activation + +:: 1st column = Current SKU ID +:: 2nd column = Current Edition Name +:: 3rd column = Current Edition Activation ID +:: 4th column = Alternate Edition Activation ID +:: 5th column = Alternate Edition GVLK +:: 6th column = Alternate Edition Name +:: Separator = _ + + +:kms38fallback + +set notfoundaltactID= +if %_NoEditionChange%==1 exit /b + +for %%# in ( +188_IoTEnterprise__________________8ab9bdd1-1f67-4997-82d9-8878520837d9_73111121-5638-40f6-bc11-f1d7b0d64300_NPPR9-FWDCX-D2C8J-H872K-2Y%f%T43_Enterprise +206_IoTEnterpriseK_________________80083eae-7031-4394-9e88-4901973d56fe_73111121-5638-40f6-bc11-f1d7b0d64300_NPPR9-FWDCX-D2C8J-H872K-2Y%f%T43_Enterprise +191_IoTEnterpriseS-2021____________ed655016-a9e8-4434-95d9-4345352c2552_32d2fab3-e4a8-42c2-923b-4bf4fd13e6ee_M7XTQ-FN8P6-TTKYV-9D4CC-J4%f%62D_EnterpriseS-2021 +205_IoTEnterpriseSK________________d4f9b41f-205c-405e-8e08-3d16e88e02be_59eb965c-9150-42b7-a0ec-22151b9897c5_KBN8V-HFGQ4-MGXVD-347P6-PD%f%QGT_IoTEnterpriseS +138_ProfessionalSingleLanguage_____a48938aa-62fa-4966-9d44-9f04da3f72f2_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional +139_ProfessionalCountrySpecific____f7af7d09-40e4-419c-a49b-eae366689ebd_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional +139_ProfessionalCountrySpecific-Zn_01eb852c-424d-4060-94b8-c10d799d7364_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional +) do ( +for /f "tokens=1-6 delims=_" %%A in ("%%#") do if %osSKU%==%%A ( +echo "!allapps!" | find /i "%%C" %nul1% && ( +echo "!allapps!" | find /i "%%D" %nul1% && ( +set altkey=%%E +set altedition=%%F +) || ( +set altedition=%%F +set notfoundaltactID=1 +) +) +) +) +exit /b + +::======================================================================================================================================== +:: Leave empty line below diff --git a/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd b/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd index 7389471..d9dbe1f 100644 --- a/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd +++ b/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd @@ -1,11 +1,12 @@ -@set masver=3.9 +@set masver=3.2 @echo off ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -49,7 +50,6 @@ set "_cmdf=%~f0" for %%# in (%*) do ( if /i "%%#"=="re1" set re1=1 if /i "%%#"=="re2" set re2=1 -if /i "%%#"=="-qedit" (set re1=1&set re2=1) ) :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows @@ -100,8 +100,6 @@ set "nul=" set "blank=" set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" -set "github=ht%blank%tps%blank%://github.com/massgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" -set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/massg%blank%rave/Micr%blank%osoft-Act%blank%ivation-Scripts" :: Check if Null service is working, it's important for the batch script @@ -173,16 +171,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto dk_done ) -if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( -sc query gcs | find /i "RUNNING" %nul% && ( -%eline% -echo Windows Sandbox detected; activation is not supported. -echo The script cannot run due to missing licensing components. Aborting... -echo: -goto dk_done -) -) - if %winbuild% LSS 6001 ( %nceline% echo Unsupported OS version detected [%winbuild%]. @@ -255,18 +243,16 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) +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% -for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) -echo Test 1 - %tstresult% -echo Test 2 - !tstresult2! -echo: +echo: %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" REM check LanguageMode -echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +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: @@ -279,9 +265,6 @@ 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... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" goto dk_done ) @@ -296,33 +279,10 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_ goto dk_done ) -REM check if .NET is working properly - -if /i "!tstresult2!"=="FullLanguage" ( -cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% -if !errorlevel!==3 ( -echo Windows Powershell failed to load .NET command. Aborting... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -goto dk_done -) -) - REM check antivirus and other errors echo PowerShell is not working properly. Aborting... - -if /i "!tstresult2!"=="FullLanguage" ( -echo: -echo Your antivirus software might be blocking the script. -echo: -sc query sense | find /i "RUNNING" %nul% && ( -echo Installed Antivirus - Microsoft Defender for Endpoint -) -cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" -) - +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" @@ -343,9 +303,7 @@ set terminal= if defined terminal ( set lines=0 -for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( -for %%B in (%%A) do set lines=%%B -) +for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A if !lines! GEQ 100 set terminal= ) @@ -406,7 +364,7 @@ echo: call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" choice /C:10 /N if !errorlevel!==2 rem -if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) +if !errorlevel!==1 (start %mas% & exit /b) ) ) cls @@ -473,8 +431,8 @@ 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%in-place_repair_upgrade -call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) goto dk_done ) @@ -571,7 +529,7 @@ call :dk_color %Red% "Checking Installed Office [Not Found]" if defined ohub ( echo: -echo You only have the Office Dashboard app installed. You need to install the full version of Office. +echo You only have the Office dashboard app installed, you need to install the full version of Office. ) echo: call :dk_color %Blue% "Download and install Office from the below URL and then try again." @@ -646,7 +604,6 @@ set error=1 goto :starto16c2r ) -call :oh_expiredpreview 2013 call :oh_fixprids call :oh_process if defined isOspp ( @@ -704,7 +661,6 @@ set error=1 goto :startmsi ) -call :oh_expiredpreview 2016 2019 2021 2024 call :oh_fixprids call :oh_process if defined isOspp ( @@ -715,19 +671,19 @@ call :oh_hookinstall ::======================================================================================================================================== -:: Old version of Office with subscription license key may show a banner to sign in to fix license issue. +:: Old version (16.0.9xxxx and below) of Office with subscription license key may show a banner to sign in to fix license issue. :: Although script applies a Resiliency registry entry to fix that but it doesn't work on old office versions. :: Below code checks that condition and informs the user to update the Office. if defined _sublic ( -if not exist "%_oLPath%\Word2021VL_KMS_Client_AE*.xrm-ms" ( +if not exist "%_oLPath%\Word2019VL_KMS_Client_AE*.xrm-ms" ( call :dk_color %Gray% "Checking Old Office With Sub License [Found. Update Office, otherwise, it may show a licensing issue-related banner.]" ) ) ::======================================================================================================================================== -:: mass{}grave{dot}dev/office-license-is-not-genuine +:: mass grave[.]dev/office-license-is-not-genuine :: Add registry keys for volume products so that 'non-genuine' banner won't appear :: Script already is using MAK instead of GVLK so it won't appear anyway, but registry keys are added incase Office installs default GVLK grace key for volume products @@ -769,7 +725,7 @@ if defined ohub call :dk_color %Gray% "Office apps such as Word, Excel are activ echo Help: %mas%troubleshoot ) else ( call :dk_color %Red% "Some errors were detected." -if not defined ierror if not defined showfix call :dk_color %Blue% "%_fixmsg%" +if not defined ierror if not defined showfix if not defined serv_cor if not defined serv_cste call :dk_color %Blue% "%_fixmsg%" echo: set fixes=%fixes% %mas%troubleshoot call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" @@ -964,28 +920,6 @@ exit /b ::======================================================================================================================================== -:oh_expiredpreview - -echo %_oIds% | find /i "Volume" %nul% || exit /b - -for %%# in (%*) do ( -if %%#==2013 set _offver= -if %%#==2016 set _offver= -if %%#==2019 set _offver=2019 -if %%#==2021 set _offver=2021 -if %%#==2024 set _offver=2024 -if exist "!_oLPath!\ProPlus!_offver!PreviewVL_*.xrm-ms" if not exist "!_oLPath!\ProPlus!_offver!VL_*.xrm-ms" ( -set error=1 -set showfix=1 -call :dk_color %Red% "Checking Expired Preview Products [Office %%# Preview Found]" -call :dk_color %Blue% "Please run the Office updates first, and then attempt to activate it again." -) -) - -exit /b - -::======================================================================================================================================== - :oh_ppcpath if not defined isOspp ( @@ -1100,7 +1034,7 @@ for %%# in ("!_oLPath!\%_License%*.xrm-ms") do ( if defined _arr (set "_arr=!_arr!;"!_oLPath!\%%~nx#"") else (set "_arr="!_oLPath!\%%~nx#"") ) -%psc% "$sls = Get-WmiObject %sps%; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_oLPath!\pkeyconfig-office.xrm-ms"'" %nul% +%psc% "$sls = Get-WmiObject %sps%; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_oLPath!\pkeyconfig-office.xrm-ms"'" %nul% call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 echo "!allapps!" | find /i "!_actid!" %nul1% || ( @@ -1422,7 +1356,7 @@ exit /b :oh_clearblock :: Find remnants of Office vNext/shared/device license block and remove it because it stops other licenses from appearing -:: https://learn.microsoft.com/en-us/office/troubleshoot/activation/reset-office-365-proplus-activation-state +:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state set _sidlist= for /f "tokens=* delims=" %%a in ('%psc% "$p = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'; Get-ChildItem $p | ForEach-Object { $pi = (Get-ItemProperty """"$p\$($_.PSChildName)"""").ProfileImagePath; if ($pi -like '*\Users\*' -and (Test-Path """"$pi\NTUSER.DAT"""") -and -not ($_.PSChildName -match '\.bak$')) { Split-Path $_.PSPath -Leaf } }" %nul6%') do (if defined _sidlist (set _sidlist=!_sidlist! %%a) else (set _sidlist=%%a)) @@ -1474,12 +1408,10 @@ call :dk_color %Gray% "Checking Total User Accounts [%counter%]" :: Clear the vNext/shared/device license blocks which may prevent ohook activation -set vnextexist= rmdir /s /q "%ProgramData%\Microsoft\Office\Licenses\" %nul% for %%x in (15 16) do ( for %%# in (%_sidlist%) do ( -reg query HKU\%%#\Software\Microsoft\Office\%%x.0\Common\Licensing /s %nul2% | findstr /i "CIDToLicenseIdsMapping LicenseIdToEmailMapping @" %nul% && set vnextexist=1 reg delete HKU\%%#\Software\Microsoft\Office\%%x.0\Common\Licensing /f %nul% for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do ( @@ -1502,7 +1434,6 @@ rmdir /s /q "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\L if exist "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\SystemAppData\Helium\User.dat" ( set defname=DEFTEMP-%%# reg load HKU\!defname! "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\SystemAppData\Helium\User.dat" %nul% -reg query HKU\!defname!\Software\Microsoft\Office\16.0\Common\Licensing /s %nul2% | findstr /i "CIDToLicenseIdsMapping LicenseIdToEmailMapping @" %nul% && set vnextexist=1 reg delete HKU\!defname!\Software\Microsoft\Office\16.0\Common\Licensing /f %nul% reg unload HKU\!defname! %nul% ) @@ -1510,15 +1441,6 @@ reg unload HKU\!defname! %nul% ) ) -if defined vnextexist ( -echo: -call :dk_color %Gray% "The logged-in Office account has a subscription license." -call :dk_color %Blue% "If the subscription is active, it overrides other activation methods." -call :dk_color %Blue% "If it is expiring soon, rerun the activation script after it expires." -call :dk_color2 %Blue% "If it has already expired and activation fails, get help here - " %_Yellow% " %mas%troubleshoot" -echo: -) - :: Clear SharedComputerLicensing for office :: https://learn.microsoft.com/en-us/deployoffice/overview-shared-computer-activation @@ -1530,12 +1452,12 @@ reg delete HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration /v Share ) :: Clear device-based-licensing -:: https://learn.microsoft.com/en-us/deployoffice/device-based-licensing +:: https://learn.microsoft.com/deployoffice/device-based-licensing for /f %%# in ('reg query "%o16c2r_reg%\Configuration" /f *.DeviceBasedLicensing %nul6% ^| findstr REG_') do reg delete "%o16c2r_reg%\Configuration" /v %%# /f %nul% :: Remove OEM registry key -:: https://support.microsoft.com/en-us/office/office-repeatedly-prompts-you-to-activate-on-a-new-pc-a9a6b05f-f6ce-4d1f-8d49-eb5007b64ba1 +:: https://support.microsoft.com/office/office-repeatedly-prompts-you-to-activate-on-a-new-pc-a9a6b05f-f6ce-4d1f-8d49-eb5007b64ba1 for %%# in (15 16) do ( reg delete "HKLM\SOFTWARE\Microsoft\Office\%%#.0\Common\OEM" /f %nul% @@ -1613,15 +1535,7 @@ set upk_result=2 if defined ohookact if not %upk_result%==0 echo: if %upk_result%==1 echo Uninstalling Other/Grace Keys [Successful] -if %upk_result%==2 ( -call :dk_color %Red% "Uninstalling Other/Grace Keys [Failed]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -set showfix=1 -) -) +if %upk_result%==2 call :dk_color %Red% "Uninstalling Other/Grace Keys [Failed]" exit /b ::======================================================================================================================================== @@ -1632,8 +1546,8 @@ exit /b :oh_licrefresh if exist "%SysPath%\spp\store_test\2.0\tokens.dat" ( -%psc% "Stop-Service sppsvc -force; $sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if !errorlevel! NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($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% ) exit /b @@ -1674,7 +1588,7 @@ exit /b set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=%ps% -nop -c set winbuild=1 -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +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) @@ -1763,11 +1677,9 @@ if %sps%==SoftwareLicensingService call :dk_refresh echo %keyecho% %~1 [Successful] ) else ( call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" -if not defined showfix ( +if not defined error ( if defined altapplist call :dk_color %Red% "Activation ID not found for this key." -echo: call :dk_color %Blue% "%_fixmsg%" -echo: set showfix=1 ) set error=1 @@ -1789,9 +1701,9 @@ if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISE if defined allapps if %1==0ff1ce15-a989-479d-af46-f275c6370663 ( set len=0 -echo:!allapps!> "!_ttemp!\chklen" -for %%A in ("!_ttemp!\chklen") do (set len=%%~zA) -del "!_ttemp!\chklen" %nul% +echo:!allapps!> %SystemRoot%\Temp\chklen +for %%A in (%SystemRoot%\Temp\chklen) do (set len=%%~zA) +del %SystemRoot%\Temp\chklen %nul% if !len! GTR 6000 ( %eline% @@ -1858,11 +1770,6 @@ set spperror=%errorlevel% if %spperror% NEQ 1056 if %spperror% NEQ 0 ( %eline% echo sc start %_slser% [Error Code: %spperror%] -if %spperror% EQU 1053 ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and try again." -call :dk_color %Blue% "If it still does not work, go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -) ) echo: @@ -1925,8 +1832,7 @@ if not exist %SysPath%\%_slexe% if not exist %SysPath%\alg.exe (set "results=%re if not "%results%%pupfound%"=="" ( if defined pupfound call :dk_color %Gray% "Checking PUP Activators [Found%pupfound%]" if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..." -if defined results (call :dk_color %Red% "%results%"&set showfix=1) -echo: +if defined results call :dk_color %Red% "%results%" set fixes=%fixes% %mas%remove_mal%w%ware call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" echo: @@ -1947,118 +1853,40 @@ exit /b set showfix= call :dk_chkmal -::============================== - :: Check Sandboxing sc query Null %nul% || ( -call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly]" -if not defined showfix ( -echo: +set error=1 +set showfix=1 +call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly.]" call :dk_color %Blue% "If you are using any third-party antivirus, check if it is blocking the script." echo: ) -set error=1 -set showfix=1 -) -::============================== - -:: Check WinPE mode - -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( - -call :dk_color %Red% "Checking WinPE [Found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "WinPE mode found. Reboot the system and run in normal mode." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check Safe mode - -if defined safeboot_option ( -call :dk_color %Red% "Checking Boot Mode [%safeboot_option%]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Safe mode found. Reboot the system and run in normal mode." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check ImageState -:: https://learn.microsoft.com/en-us/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) - -if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" ( -call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]" -echo "%imagestate%" | find /i "RESEAL" %nul% && ( -if not defined showfix ( -echo: -call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode." -echo: -) -set error=1 -set showfix=1 -) -echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && ( -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -) -) - -::============================== +::======================================================================================================================================== :: Check corrupt services set serv_cor= for %%# in (%_serv%) do ( -set _regcorr= set _corrupt= sc start %%# %nul% if !errorlevel! EQU 1060 set _corrupt=1 sc query %%# %nul% || set _corrupt=1 -for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type) do if not defined _regcorr ( -reg query HKLM\SYSTEM\CurrentControlSet\Services\%%# /v %%G %nul% || (set _corrupt=1&set _regcorr=-RegistryError) +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 ) -if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#!_regcorr!") else (set "serv_cor=%%#!_regcorr!")) +if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#") else (set "serv_cor=%%#")) ) if defined serv_cor ( -call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" - -if not defined showfix ( -echo: -if /i "%serv_cor%"=="sppsvc-RegistryError" ( -set fixes=%fixes% %mas%fix_service -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_service" -) else ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) -echo: -) - set error=1 set showfix=1 +call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" ) -::============================== +::======================================================================================================================================== :: Check disabled services @@ -2093,26 +1921,11 @@ if defined serv_cste (set "serv_cste=!serv_cste! %%#") else (set "serv_cste=%%#" if defined serv_csts call :dk_color %Gray% "Enabling Disabled Services [Successful] [%serv_csts%]" if defined serv_cste ( -call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" - -if not defined showfix ( -echo: -echo %serv_cste% | findstr /i "ClipSVC sppsvc" %nul% && ( -echo A registry fix has been applied to enable the disabled service. -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -) || ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) -echo: -) - set error=1 -set showfix=1 +call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" ) -::============================== +::======================================================================================================================================== :: Check if the services are able to run or not :: Workarounds are added to get correct status and error code because sc query doesn't output correct results in some conditions @@ -2134,322 +1947,75 @@ if defined checkerror if defined serv_e (set "serv_e=!serv_e!, %%#-!errorcode!") ) if defined serv_e ( +set error=1 call :dk_color %Red% "Starting Services [Failed] [%serv_e%]" - -if not defined showfix ( -set listwospp=%_serv:sppsvc=% -echo %serv_e% | findstr /i "!listwospp!" %nul% && ( +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." set showfix=1 -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and run the script again." +) +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 +) +) + +::======================================================================================================================================== + +:: Various error checks + +if defined safeboot_option ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option%] " %Blue% "[Safe mode found. Run in normal mode.]" +) + + +:: 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) + +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 showfix=1 +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 service error is still not fixed, do this - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: +call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade" ) ) -set error=1 -) -::============================== -:: Check WMI - -set wmifailed= -if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 %_wmic% EQU 1 wmic path %sps% get Version %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% -cmd /c exit /b %error_code% -if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" - -echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants - -if defined wmifailed ( -call :dk_color %Red% "Checking WMI [Not Working]" - -if not defined showfix ( -echo: -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." -echo: -) +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( set error=1 set showfix=1 +call :dk_color2 %Red% "Checking WinPE " %Blue% "[WinPE mode found. Run in normal mode.]" ) -::============================== -:: Check SPP Registry Key - -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% || ( -call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found] [Most likely caused by gaming spoofers]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%issues_due_to_gaming_spoofers -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check TokenStore registry key - -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" -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" ( -call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set toerr=1 -set error=1 -set showfix=1 -) -) - -::============================== - -:: 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%\" ( - -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% 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)';" -set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" -set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" -set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" -%psc% "!d!" %nul% - -if exist "%tokenstore%\" ( -call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" -) else ( -call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set error=1 -set showfix=1 -) -) - -::============================== - -:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. - -set permerror= -if %winbuild% GEQ 9200 if not defined toerr if not defined ps32onArm if exist "%tokenstore%\" ( -for %%# in ( -"%tokenstore%+FullControl" -"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" -"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" -) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( -%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% -if !errorlevel!==2 ( -if "%%A"=="%tokenstore%" ( -set "permerror=Error Found In Token Folder" -) else ( -set "permerror=Error Found In SPP Registries" -) -) -) - -REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application - -if not defined permerror ( -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( -set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" -reg query "!pol!" %nul% || reg add "!pol!" %nul% -%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% -if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" -) -) - -if defined permerror ( -call :dk_color %Red% "Checking SPP Permissions [!permerror!]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -) -set error=1 -set showfix=1 -) -) - -::============================== - -:: Check WPA Registry Errors - -set chkalp= -set wpainfo=NotFound -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wpatest\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do (set wpainfo=%%a) -for /f "delims=0123456789" %%i in ("%wpainfo%") do set chkalp=%%i - -if defined chkalp ( -call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" -if not defined showfix ( +set wpainfo= +set wpaerror= +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1])" %nul6%') do (set wpainfo=%%a) echo "%wpainfo%" | find /i "Error Found" %nul% && ( -echo: -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -echo: set error=1 -set showfix=1 -) -) -set wpainfo=a -) - -if not defined chkalp ( -if %wpainfo% GEQ 5000 ( -call :dk_color %Gray% "Checking WPA Registry Count [%wpainfo%]" -echo: -call :dk_color %Blue% "A large number of WPA registries have been found, which may cause high CPU usage." -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -echo: -) else ( +set wpaerror=1 +call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" +) || ( echo Checking WPA Registry Count [%wpainfo%] ) -) -::============================== - -:: Check Rearm - -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( -call :dk_color %Red% "Checking Rearm [System is Rearmed]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -echo: -) -set error=1 -set showfix=1 -) - - -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( -call :dk_color %Red% "Checking ClipSVC PersistedSystemState [Found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check SoftwareLicensingService - -if %error_code% NEQ 0 ( -call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] [%error_code%]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check Activation IDs - -call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f - -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=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if not defined _vis if !errorlevel! NEQ 0 set rlicfailed=1 -call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f -) - -if not defined apps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -if not defined apps if defined allapps if not defined notwinact ( -call :dk_color %Gray% "Checking Activation IDs [Key Not Installed or Act ID Not Found]" -) - -if not defined apps if not defined allapps ( -call :dk_color %Red% "Checking Activation IDs [Not found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) -set error=1 -set showfix=1 -) - -if not defined showfix if defined rlicfailed ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) - -if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( -call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]" -) - -::============================== - -:: Check Eval Windows if not defined notwinact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || ( -call :dk_color %Red% "Checking Eval Packages [License swapping found. Non-Eval licenses are installed in Eval Windows]" -if not defined showfix ( -echo: -call :dk_color %Blue% "License swapping is not the right way to upgrade to the full version. Learn the correct method at the link below." +call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]" set fixes=%fixes% %mas%evaluation_editions call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" -echo: -) -set error=1 -set showfix=1 ) ) -::============================== - -:: Check HKU\S-1-5-20\Software registry, in some systems it's missing and that causes Windows activation problems - -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( -call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check license and package files for the current edition 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%')" @@ -2469,10 +2035,12 @@ if not defined notwinact ( if %osedition%==0 ( call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" ) 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" ( set skunotfound=1 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%Edition*.mum" ( call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" @@ -2481,9 +2049,31 @@ call :dk_color %Red% "Checking Package Files [Not Found] [%osed ) ) -::============================== -:: Check SKU value to find if there is any difference +if %_wmic% EQU 1 wmic path %sps% get Version %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% +cmd /c exit /b %error_code% +if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" +if %error_code% NEQ 0 ( +set error=1 +call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] %error_code%" +) + + +set wmifailed= +if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 +echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants +if defined wmifailed ( +set error=1 +call :dk_color %Red% "Checking WMI [Not Working]" +if not defined showfix call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." +set showfix=1 +) + if not defined notwinact ( if %winbuild% GEQ 10240 ( @@ -2501,19 +2091,35 @@ call :dk_color %Gray% "Checking SLC/WMI SKU [Difference Found ) ) -::============================== +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Rearm " %Blue% "[System Restart Is Required]" +) + + +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System Restart Is Required]" +) + :: 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. -sc query wlms %nul% - -if %errorlevel% NEQ 1060 ( +if exist "%SysPath%\wlms\wlms.exe" ( echo Checking Eval WLMS Service [Found] ) -::============================== -:: Check SPP interference in IFEO +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( +set error=1 +set showfix=1 +call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" +set fixes=%fixes% %mas%in-place_repair_upgrade +call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +) + for %%# in (SppEx%w%tComObj.exe SLsvc.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=%%#")) @@ -2521,56 +2127,156 @@ reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu if defined _sppint ( echo %_sppint% | find /i "PerfOptions" %nul% && ( call :dk_color %Red% "Checking SPP Interference In IFEO [%_sppint% - System might deactivate later]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -) +if not defined showfix call :dk_color %Blue% "%_fixmsg%" set showfix=1 ) || ( echo Checking SPP In IFEO [%_sppint%] ) ) -::============================== - -:: Check and fix SkipRearm registry value 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 ( reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul% -call :dk_color %Gray% "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" ) -::============================== -:: Check SvcRestartTask status, this task helps in making sure system remains activated +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% || ( +call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]" +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" +set error=1 +set showfix=1 +) + + +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" +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" ( +set toerr=1 +set error=1 +set showfix=1 +call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +) +) + +:: 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%\" ( +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% 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)';" +set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" +set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" +set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" +%psc% "!d!" %nul% +if exist "%tokenstore%\" ( +call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" +) else ( +call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" +set error=1 +set showfix=1 +) +) + + +if not defined notwinact ( +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +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% +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined apps ( +set "_notfoundids=Key Not Installed / Act ID Not Found" +call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined allapps ( +set error=1 +set "_notfoundids=Not found" +) +call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]" +) +) +) + + +if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( +set error=1 +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" ( %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% "$s=New-Object -ComObject 'Schedule.Service'; $s.Connect(); $state=$s.GetFolder('\Microsoft\Windows\SoftwareProtectionPlatform').GetTask('SvcRestartTask').State; @{0='Unknown';1='Disabled';2='Queued';3='Ready';4='Running'}[$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% || ( 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 if "!taskinfo!"=="" set "taskinfo=Not Found" +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." +) +) +) -call :dk_color %Gray% "Checking SvcRestartTask Status [!taskinfo!. System might deactivate later.]" + +:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. + +set permerror= +if %winbuild% GEQ 9200 if not defined ps32onArm ( +for %%# in ( +"%tokenstore%+FullControl" +"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" +"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" +) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( +%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% +if !errorlevel!==2 ( +if "%%A"=="%tokenstore%" ( +set "permerror=Error Found In Token Folder" +) else ( +set "permerror=Error Found In SPP Registries" +) +) +) + +REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application + +if not defined permerror ( +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( +set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" +reg query "!pol!" %nul% || reg add "!pol!" %nul% +%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% +if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" +) +) + +if defined permerror ( +set error=1 +call :dk_color %Red% "Checking SPP Permissions [!permerror!]" +if not defined showfix call :dk_color %Blue% "%_fixmsg%" +set showfix=1 +) +) + + +:: If required services are not disabled or corrupted + if there is any error + SoftwareLicensingService errorlevel is not Zero + no fix was shown before + +if not defined serv_cor if not defined serv_cste if defined error if /i not %error_code%==0 if not defined showfix ( +if not defined permerror if defined wpaerror (call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." & set showfix=1) if not defined showfix ( -echo: -echo "!taskinfo!" | findstr /i "Removed Not Found" %nul1% && ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) || ( -call :dk_color %Blue% "Reboot your machine using the restart option and run the script again." -) -echo: -) -) +set showfix=1 +call :dk_color %Blue% "%_fixmsg%" +if not defined permerror call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." ) ) -::============================== +if not defined showfix if defined wpaerror ( +set showfix=1 +call :dk_color %Blue% "If activation fails then go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." +) exit /b @@ -2662,7 +2368,7 @@ call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" choice /C:10 /N if !errorlevel!==2 exit /b -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -2693,6 +2399,7 @@ exit /b 14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_Retail________ExcelR_[HSExcelR] 14_7004b7f0-6407-4f45-8eac-966e5f868bde_Retail________GrooveR +14_fbf4ac36-31c8-4340-8666-79873129cf40_Retail________OutlookR 14_133c8359-4e93-4241-8118-30bb18737ea0_Retail________PowerPointR_[HSPowerPointR] 14_db3bbc9c-ce52-41d1-a46f-1a1d68059119_Retail________WordR_[HSWordR] 14_dbe3aee0-5183-4ff7-8142-66050173cb01_Retail________SmallBusBasicsR_[SmallBusBasicsMSDNR] @@ -2721,7 +2428,6 @@ for %%# in ( 14_85e22450-b741-430c-a172-a37962c938af_6GKT2-KMJPK-4RRBF-8VQKB-JB%f%6G6_MAK___________InfoPathVL 14_3f7aa693-9a7e-44fc-9309-bb3d8e604925_2TG3P-9DB76-4YT99-8RXGD-CW%f%XBP_Retail________OneNoteR_[HSOneNoteR] 14_6860b31f-6a67-48b8-84b9-e312b3485c4b_CV64P-F4VRH-BJ33D-PH6MR-X6%f%9RY_MAK___________OneNoteVL -14_fbf4ac36-31c8-4340-8666-79873129cf40_9D8FR-7GYBW-4YG8M-V36JK-VD%f%7CM_Retail________OutlookR 14_a9aeabd8-63b8-4079-a28e-f531807fd6b8_J8C9M-YXMH2-9CX44-2C3YG-V7%f%692_MAK___________OutlookVL 14_acb51361-c0db-4895-9497-1831c41f31a6_GMBWM-WVX26-7WHV4-DB43D-WV%f%DY2_Retail________PersonalR_[PersonalDemoR,PersonalPrepaidR] 14_38252940-718c-4aa6-81a4-135398e53851_HPBQP-RJHDR-Q3472-PT9Q6-PB%f%B72_MAK___________PowerPointVL @@ -3157,7 +2863,7 @@ exit /b :oh_extractdll set b= -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':%_hook%\:.*';$encoded = ($f[1]) -replace '-', 'A' -replace '_', 'a';$bytes = [Con%b%vert]::FromBas%b%e64String($encoded); $PePath='%1'; $offset='%2'; $m=[System.IO.File]::ReadAllText('!_batp!') -split ':hexedit\:.*';. ([scriptblock]::Create($m[1]))" %nul2% | find /i "Error found" %nul1% && set hasherror=1 +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':%_hook%\:.*';$encoded = ($f[1]) -replace '-', 'A' -replace '_', 'a';$bytes = [Con%b%vert]::FromBas%b%e64String($encoded); $PePath='%1'; $offset='%2'; $m=[io.file]::ReadAllText('!_batp!') -split ':hexedit\:.*';iex ($m[1])" %nul2% | find /i "Error found" %nul1% && set hasherror=1 exit /b :hexedit: @@ -3240,13 +2946,13 @@ $MemoryStream.Close() :: :: The files are encoded in base64 to make AIO version. :: -:: mass{}grave{dot}dev/ohook +:: mass grave[.]dev/ohook :: Here you can find the files source code and info on how to rebuild the identical sppc.dll files :: :: stackoverflow.com/a/35335273 :: Here you can check how to extract sppc.dll files from base64 :: -:: For any further question, feel free to contact us on mass{}grave{dot}dev/contactus +:: For any further question, feel free to contact us on mass grave[.]dev/contactus :: ::======================================================================================================================================== :: diff --git a/MAS/Separate-Files-Version/Activators/Online_KMS_Activation.cmd b/MAS/Separate-Files-Version/Activators/Online_KMS_Activation.cmd index 33c2c50..0d0bdf8 100644 --- a/MAS/Separate-Files-Version/Activators/Online_KMS_Activation.cmd +++ b/MAS/Separate-Files-Version/Activators/Online_KMS_Activation.cmd @@ -1,11 +1,12 @@ -@set masver=3.9 +@set masver=3.2 @echo off ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -74,7 +75,6 @@ set "_cmdf=%~f0" for %%# in (%*) do ( if /i "%%#"=="re1" set re1=1 if /i "%%#"=="re2" set re2=1 -if /i "%%#"=="-qedit" (set re1=1&set re2=1) ) :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows @@ -125,8 +125,6 @@ set "nul=" set "blank=" set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" -set "github=ht%blank%tps%blank%://github.com/massgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" -set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/massg%blank%rave/Micr%blank%osoft-Act%blank%ivation-Scripts" :: Check if Null service is working, it's important for the batch script @@ -204,16 +202,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto dk_done ) -if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( -sc query gcs | find /i "RUNNING" %nul% && ( -%eline% -echo Windows Sandbox detected; activation is not supported. -echo The script cannot run due to missing licensing components. Aborting... -echo: -goto dk_done -) -) - if %winbuild% LSS 6001 ( %nceline% echo Unsupported OS version detected [%winbuild%]. @@ -286,18 +274,16 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) +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% -for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) -echo Test 1 - %tstresult% -echo Test 2 - !tstresult2! -echo: +echo: %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" REM check LanguageMode -echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +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: @@ -310,9 +296,6 @@ 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... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" goto dk_done ) @@ -327,33 +310,10 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_ goto dk_done ) -REM check if .NET is working properly - -if /i "!tstresult2!"=="FullLanguage" ( -cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% -if !errorlevel!==3 ( -echo Windows Powershell failed to load .NET command. Aborting... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -goto dk_done -) -) - REM check antivirus and other errors echo PowerShell is not working properly. Aborting... - -if /i "!tstresult2!"=="FullLanguage" ( -echo: -echo Your antivirus software might be blocking the script. -echo: -sc query sense | find /i "RUNNING" %nul% && ( -echo Installed Antivirus - Microsoft Defender for Endpoint -) -cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" -) - +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" @@ -374,9 +334,7 @@ set terminal= if defined terminal ( set lines=0 -for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( -for %%B in (%%A) do set lines=%%B -) +for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A if !lines! GEQ 100 set terminal= ) @@ -437,7 +395,7 @@ echo: call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" choice /C:10 /N if !errorlevel!==2 rem -if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) +if !errorlevel!==1 (start %mas% & exit /b) ) ) @@ -535,8 +493,8 @@ 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%in-place_repair_upgrade -call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) goto dk_done ) @@ -654,7 +612,7 @@ set altedition= call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f if defined allapps call :ksdata winkey if not defined key call :k_gvlk %nul% -if defined allapps if not defined key call :kmsfallback +if defined allapps if not defined key call :kms38fallback if defined altkey (set key=%altkey%&set changekey=1) @@ -816,7 +774,7 @@ call :dk_color %Red% "Checking Installed Office [Not Found]" if defined ohub ( echo: -echo You only have the Office Dashboard app installed. You need to install the full version of Office. +echo You have only Office dashboard app installed, you need to install full Office version. ) call :dk_color %Blue% "Download and install Office from below URL and try again." set fixes=%fixes% %mas%genuine-installation-media @@ -908,7 +866,6 @@ set error=1 goto :ks_starto16c2r ) -call :oh_expiredpreview 2013 if "%_actprojvis%"=="0" call :oh_fixprids call :ks_process @@ -949,7 +906,6 @@ set error=1 goto :ks_startmsi ) -call :oh_expiredpreview 2016 2019 2021 2024 if "%_actprojvis%"=="0" call :oh_fixprids call :ks_process @@ -975,7 +931,7 @@ call :oh_licrefresh :ks_activate :: Opt out of sending KMSclient activation data to Microsoft -:: https://learn.microsoft.com/en-us/windows/privacy/manage-connections-from-windows-operating-system-components-to-microsoft-services#19-software-protection-platform +:: https://learn.microsoft.com/windows/privacy/manage-connections-from-windows-operating-system-components-to-microsoft-services#19-software-protection-platform if %winbuild% GEQ 9600 ( reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform" /v NoGenTicket /t REG_DWORD /d 1 /f %nul% @@ -1030,7 +986,7 @@ if %winbuild% GEQ 9200 ( for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" set "_C16R=1" for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\Office\ClickToRun /v InstallPath /reg:32" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" set "_C16R=1" if defined _C16R ( -REM mass{}grave{dot}dev/office-license-is-not-genuine +REM mass grave[.]dev/office-license-is-not-genuine set _server=10.0.0.10 call :_taskregserv echo Keeping the non-existent IP address 10.0.0.10 as %KS% Server. @@ -1043,7 +999,7 @@ echo Cleared %KS% Server from the registry. ) ) -:: https://learn.microsoft.com/en-us/azure/virtual-desktop/windows-10-multisession-faq +:: https://learn.microsoft.com/azure/virtual-desktop/windows-10-multisession-faq if %_actwin%==1 for %%# in (407) do if %osSKU%==%%# ( call :dk_color %Red% "%winos% does not support activation on non-azure platforms." @@ -1130,28 +1086,6 @@ exit /b ::======================================================================================================================================== -:oh_expiredpreview - -echo %_oIds% | find /i "Volume" %nul% || exit /b - -for %%# in (%*) do ( -if %%#==2013 set _offver= -if %%#==2016 set _offver= -if %%#==2019 set _offver=2019 -if %%#==2021 set _offver=2021 -if %%#==2024 set _offver=2024 -if exist "!_oLPath!\ProPlus!_offver!PreviewVL_*.xrm-ms" if not exist "!_oLPath!\ProPlus!_offver!VL_*.xrm-ms" ( -set error=1 -set showfix=1 -call :dk_color %Red% "Checking Expired Preview Products [Office %%# Preview Found]" -call :dk_color %Blue% "Please run the Office updates first, and then attempt to activate it again." -) -) - -exit /b - -::======================================================================================================================================== - :: Some Office Retail to Volume converter tools may edit the ProductReleaseIds to add VL products. This code restores it because it may affect features. :oh_fixprids @@ -1278,10 +1212,6 @@ call :ksdata getinfo !_prod! if defined _altoffid ( set _License=!_altoffid! echo Converting Retail To Volume [!_prod! To !_altoffid!] -echo %%# | find /i "O365" %nul% && ( -if "%oVer%"=="15" (call :dk_color %Gray% "Mondo 2013 is equivalent to O365 [15.0 version] in terms of the latest features.") -if "%oVer%"=="16" (call :dk_color %Gray% "Mondo 2016 is equivalent to O365 in terms of the latest features.") -) set _prod=!_altoffid! call :ks_osppready ) @@ -1385,7 +1315,7 @@ for %%# in ("!_oLPath!\%_License%*.xrm-ms") do ( if defined _arr (set "_arr=!_arr!;"!_oLPath!\%%~nx#"") else (set "_arr="!_oLPath!\%%~nx#"") ) -%psc% "$sls = Get-WmiObject %sps%; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_oLPath!\pkeyconfig-office.xrm-ms"'" %nul% +%psc% "$sls = Get-WmiObject %sps%; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_oLPath!\pkeyconfig-office.xrm-ms"'" %nul% call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 echo "!allapps!" | find /i "!_actid!" %nul1% || ( @@ -1400,7 +1330,7 @@ exit /b :oh_clearblock :: Find remnants of Office vNext/shared/device license block and remove it because it stops other licenses from appearing -:: https://learn.microsoft.com/en-us/office/troubleshoot/activation/reset-office-365-proplus-activation-state +:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state set _sidlist= for /f "tokens=* delims=" %%a in ('%psc% "$p = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'; Get-ChildItem $p | ForEach-Object { $pi = (Get-ItemProperty """"$p\$($_.PSChildName)"""").ProfileImagePath; if ($pi -like '*\Users\*' -and (Test-Path """"$pi\NTUSER.DAT"""") -and -not ($_.PSChildName -match '\.bak$')) { Split-Path $_.PSPath -Leaf } }" %nul6%') do (if defined _sidlist (set _sidlist=!_sidlist! %%a) else (set _sidlist=%%a)) @@ -1452,12 +1382,10 @@ call :dk_color %Gray% "Checking Total User Accounts [%counter%]" :: Clear the vNext/shared/device license blocks which may prevent ohook activation -set vnextexist= rmdir /s /q "%ProgramData%\Microsoft\Office\Licenses\" %nul% for %%x in (15 16) do ( for %%# in (%_sidlist%) do ( -reg query HKU\%%#\Software\Microsoft\Office\%%x.0\Common\Licensing /s %nul2% | findstr /i "CIDToLicenseIdsMapping LicenseIdToEmailMapping @" %nul% && set vnextexist=1 reg delete HKU\%%#\Software\Microsoft\Office\%%x.0\Common\Licensing /f %nul% for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do ( @@ -1480,7 +1408,6 @@ rmdir /s /q "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\L if exist "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\SystemAppData\Helium\User.dat" ( set defname=DEFTEMP-%%# reg load HKU\!defname! "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\SystemAppData\Helium\User.dat" %nul% -reg query HKU\!defname!\Software\Microsoft\Office\16.0\Common\Licensing /s %nul2% | findstr /i "CIDToLicenseIdsMapping LicenseIdToEmailMapping @" %nul% && set vnextexist=1 reg delete HKU\!defname!\Software\Microsoft\Office\16.0\Common\Licensing /f %nul% reg unload HKU\!defname! %nul% ) @@ -1488,15 +1415,6 @@ reg unload HKU\!defname! %nul% ) ) -if defined vnextexist ( -echo: -call :dk_color %Gray% "The logged-in Office account has a subscription license." -call :dk_color %Blue% "If the subscription is active, it overrides other activation methods." -call :dk_color %Blue% "If it is expiring soon, rerun the activation script after it expires." -call :dk_color2 %Blue% "If it has already expired and activation fails, get help here - " %_Yellow% " %mas%troubleshoot" -echo: -) - :: Clear SharedComputerLicensing for office :: https://learn.microsoft.com/en-us/deployoffice/overview-shared-computer-activation @@ -1508,12 +1426,12 @@ reg delete HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration /v Share ) :: Clear device-based-licensing -:: https://learn.microsoft.com/en-us/deployoffice/device-based-licensing +:: https://learn.microsoft.com/deployoffice/device-based-licensing for /f %%# in ('reg query "%o16c2r_reg%\Configuration" /f *.DeviceBasedLicensing %nul6% ^| findstr REG_') do reg delete "%o16c2r_reg%\Configuration" /v %%# /f %nul% :: Remove OEM registry key -:: https://support.microsoft.com/en-us/office/office-repeatedly-prompts-you-to-activate-on-a-new-pc-a9a6b05f-f6ce-4d1f-8d49-eb5007b64ba1 +:: https://support.microsoft.com/office/office-repeatedly-prompts-you-to-activate-on-a-new-pc-a9a6b05f-f6ce-4d1f-8d49-eb5007b64ba1 for %%# in (15 16) do ( reg delete "HKLM\SOFTWARE\Microsoft\Office\%%#.0\Common\OEM" /f %nul% @@ -1591,15 +1509,7 @@ set upk_result=2 if defined ohookact if not %upk_result%==0 echo: if %upk_result%==1 echo Uninstalling Other/Grace Keys [Successful] -if %upk_result%==2 ( -call :dk_color %Red% "Uninstalling Other/Grace Keys [Failed]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -set showfix=1 -) -) +if %upk_result%==2 call :dk_color %Red% "Uninstalling Other/Grace Keys [Failed]" exit /b ::======================================================================================================================================== @@ -1610,8 +1520,8 @@ exit /b :oh_licrefresh if exist "%SysPath%\spp\store_test\2.0\tokens.dat" ( -%psc% "Stop-Service sppsvc -force; $sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if !errorlevel! NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($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% ) exit /b @@ -1648,9 +1558,6 @@ call :ks_clearstuff set error_=9 echo Failed to completely clear %KS% Cache. reg query "HKLM\%SPPk%\%_wApp%" /s %nul2% | findstr /i "127.0.0.2" %nul1% && echo KMS38 activation is locked. -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: ) || ( echo Cleared %KS% Cache successfully. ) @@ -1666,10 +1573,6 @@ echo %uline% echo %uline% echo: call :dk_color %Green% "Online %KS% has been successfully uninstalled." -echo: -call :dk_color %Gray% "If you want to reset the activation status," -call :dk_color %Blue% "%_fixmsg%" -echo: echo %uline% ) @@ -1726,7 +1629,8 @@ exit /b ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -1766,7 +1670,7 @@ set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowe set _tserror= set winbuild=1 set "nul=>nul 2>&1" -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set psc=powershell.exe -nop -c set _slexe=sppsvc.exe& set _slser=sppsvc @@ -2219,8 +2123,8 @@ set srvlist= set -= set "srvlist=kms.03%-%k.org kms-default.cangs%-%hui.net kms.six%-%yin.com kms.moe%-%club.org kms.cgt%-%soft.com" -set "srvlist=%srvlist% kms.id%-%ina.cn kms.moe%-%yuuko.com xinch%-%eng213618.cn kms.lol%-%i.best kms.mc%-%06.net" -set "srvlist=%srvlist% kms.0%-%t.net.cn win.k%-%ms.pub kms.wx%-%lost.com kms.moe%-%yuuko.top kms.gh%-%xi.com" +set "srvlist=%srvlist% kms.id%-%ina.cn kms.moe%-%yuuko.com xinch%-%eng213618.cn kms.lol%-%i.best kms.my%-%ds.cloud" +set "srvlist=%srvlist% kms.0%-%t.net.cn win.k%-%ms.pub kms.wx%-%lost.com kms.moe%-%yuuko.top kms.gh%-%pym.com" set n=1 for %%a in (%srvlist%) do (set %%a=&set server!n!=%%a&set /a n+=1) @@ -2279,7 +2183,7 @@ if not defined _int (s%nil%cht%nil%asks /cre%nil%ate /tn "Activation-Run_Once" / if exist "%_temp%\.*" rmdir /s /q "%_temp%\" %nul% call :ks_createInfo.txt -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split \":_extracttask\:.*`r`n\"; [io.file]::WriteAllText('%_dest%\Activation_task.cmd', '@::%randguid%' + [Environment]::NewLine + $f[1].Trim(), [System.Text.Encoding]::ASCII)" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split \":_extracttask\:.*`r`n\"; [io.file]::WriteAllText('%_dest%\Activation_task.cmd', '@::%randguid%' + [Environment]::NewLine + $f[1].Trim(), [System.Text.Encoding]::ASCII)" ::======================================================================================================================================== @@ -2309,7 +2213,7 @@ exit /b :ks_RenExport -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('%~2',$f[1].Trim(),[System.Text.Encoding]::%~3);" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('%~2',$f[1].Trim(),[System.Text.Encoding]::%~3);" exit /b ::======================================================================================================================================== @@ -2334,7 +2238,8 @@ echo ___________________________________________________________________________ echo: echo This Script is a part of MAS project. echo: -echo Homepage: mass%w%grave%w%.dev +echo Homepage: mass grave[.]dev +echo Email: mas.help@outlook.com )>"%_dest%\Info.txt" exit /b @@ -2585,7 +2490,7 @@ exit /b set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=%ps% -nop -c set winbuild=1 -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +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) @@ -2674,7 +2579,7 @@ for /f "tokens=3 delims=." %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Con if %_wmic% EQU 1 for /f "tokens=2 delims==" %%a in ('"wmic Path Win32_OperatingSystem Get OperatingSystemSKU /format:LIST" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" if %_wmic% EQU 0 for /f "tokens=1" %%a in ('%psc% "([WMI]'Win32_OperatingSystem=@').OperatingSystemSKU" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" -if %winbuild% GEQ 15063 %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';. ([scriptblock]::Create($f[1]))" %nul2% | find /i "Subscription_is_activated" %nul% && ( +if %winbuild% GEQ 15063 %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';iex ($f[1])" %nul2% | find /i "Subscription_is_activated" %nul% && ( if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" ( set winsub=1 set osSKU=%regSKU% @@ -2737,11 +2642,9 @@ if %sps%==SoftwareLicensingService call :dk_refresh echo %keyecho% %~1 [Successful] ) else ( call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" -if not defined showfix ( +if not defined error ( if defined altapplist call :dk_color %Red% "Activation ID not found for this key." -echo: call :dk_color %Blue% "%_fixmsg%" -echo: set showfix=1 ) set error=1 @@ -2772,9 +2675,9 @@ if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISE if defined allapps if %1==0ff1ce15-a989-479d-af46-f275c6370663 ( set len=0 -echo:!allapps!> "!_ttemp!\chklen" -for %%A in ("!_ttemp!\chklen") do (set len=%%~zA) -del "!_ttemp!\chklen" %nul% +echo:!allapps!> %SystemRoot%\Temp\chklen +for %%A in (%SystemRoot%\Temp\chklen) do (set len=%%~zA) +del %SystemRoot%\Temp\chklen %nul% if !len! GTR 6000 ( %eline% @@ -2859,11 +2762,6 @@ set spperror=%errorlevel% if %spperror% NEQ 1056 if %spperror% NEQ 0 ( %eline% echo sc start %_slser% [Error Code: %spperror%] -if %spperror% EQU 1053 ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and try again." -call :dk_color %Blue% "If it still does not work, go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -) ) echo: @@ -2986,8 +2884,7 @@ if not exist %SysPath%\%_slexe% if not exist %SysPath%\alg.exe (set "results=%re if not "%results%%pupfound%"=="" ( if defined pupfound call :dk_color %Gray% "Checking PUP Activators [Found%pupfound%]" if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..." -if defined results (call :dk_color %Red% "%results%"&set showfix=1) -echo: +if defined results call :dk_color %Red% "%results%" set fixes=%fixes% %mas%remove_mal%w%ware call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" echo: @@ -3008,118 +2905,40 @@ exit /b set showfix= call :dk_chkmal -::============================== - :: Check Sandboxing sc query Null %nul% || ( -call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly]" -if not defined showfix ( -echo: +set error=1 +set showfix=1 +call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly.]" call :dk_color %Blue% "If you are using any third-party antivirus, check if it is blocking the script." echo: ) -set error=1 -set showfix=1 -) -::============================== - -:: Check WinPE mode - -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( - -call :dk_color %Red% "Checking WinPE [Found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "WinPE mode found. Reboot the system and run in normal mode." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check Safe mode - -if defined safeboot_option ( -call :dk_color %Red% "Checking Boot Mode [%safeboot_option%]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Safe mode found. Reboot the system and run in normal mode." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check ImageState -:: https://learn.microsoft.com/en-us/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) - -if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" ( -call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]" -echo "%imagestate%" | find /i "RESEAL" %nul% && ( -if not defined showfix ( -echo: -call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode." -echo: -) -set error=1 -set showfix=1 -) -echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && ( -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -) -) - -::============================== +::======================================================================================================================================== :: Check corrupt services set serv_cor= for %%# in (%_serv%) do ( -set _regcorr= set _corrupt= sc start %%# %nul% if !errorlevel! EQU 1060 set _corrupt=1 sc query %%# %nul% || set _corrupt=1 -for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type) do if not defined _regcorr ( -reg query HKLM\SYSTEM\CurrentControlSet\Services\%%# /v %%G %nul% || (set _corrupt=1&set _regcorr=-RegistryError) +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 ) -if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#!_regcorr!") else (set "serv_cor=%%#!_regcorr!")) +if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#") else (set "serv_cor=%%#")) ) if defined serv_cor ( -call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" - -if not defined showfix ( -echo: -if /i "%serv_cor%"=="sppsvc-RegistryError" ( -set fixes=%fixes% %mas%fix_service -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_service" -) else ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) -echo: -) - set error=1 set showfix=1 +call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" ) -::============================== +::======================================================================================================================================== :: Check disabled services @@ -3154,26 +2973,11 @@ if defined serv_cste (set "serv_cste=!serv_cste! %%#") else (set "serv_cste=%%#" if defined serv_csts call :dk_color %Gray% "Enabling Disabled Services [Successful] [%serv_csts%]" if defined serv_cste ( -call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" - -if not defined showfix ( -echo: -echo %serv_cste% | findstr /i "ClipSVC sppsvc" %nul% && ( -echo A registry fix has been applied to enable the disabled service. -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -) || ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) -echo: -) - set error=1 -set showfix=1 +call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" ) -::============================== +::======================================================================================================================================== :: Check if the services are able to run or not :: Workarounds are added to get correct status and error code because sc query doesn't output correct results in some conditions @@ -3195,322 +2999,75 @@ if defined checkerror if defined serv_e (set "serv_e=!serv_e!, %%#-!errorcode!") ) if defined serv_e ( +set error=1 call :dk_color %Red% "Starting Services [Failed] [%serv_e%]" - -if not defined showfix ( -set listwospp=%_serv:sppsvc=% -echo %serv_e% | findstr /i "!listwospp!" %nul% && ( +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." set showfix=1 -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and run the script again." +) +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 +) +) + +::======================================================================================================================================== + +:: Various error checks + +if defined safeboot_option ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option%] " %Blue% "[Safe mode found. Run in normal mode.]" +) + + +:: 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) + +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 showfix=1 +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 service error is still not fixed, do this - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: +call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade" ) ) -set error=1 -) -::============================== -:: Check WMI - -set wmifailed= -if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 %_wmic% EQU 1 wmic path %sps% get Version %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% -cmd /c exit /b %error_code% -if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" - -echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants - -if defined wmifailed ( -call :dk_color %Red% "Checking WMI [Not Working]" - -if not defined showfix ( -echo: -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." -echo: -) +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( set error=1 set showfix=1 +call :dk_color2 %Red% "Checking WinPE " %Blue% "[WinPE mode found. Run in normal mode.]" ) -::============================== -:: Check SPP Registry Key - -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% || ( -call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found] [Most likely caused by gaming spoofers]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%issues_due_to_gaming_spoofers -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check TokenStore registry key - -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" -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" ( -call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set toerr=1 -set error=1 -set showfix=1 -) -) - -::============================== - -:: 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%\" ( - -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% 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)';" -set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" -set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" -set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" -%psc% "!d!" %nul% - -if exist "%tokenstore%\" ( -call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" -) else ( -call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set error=1 -set showfix=1 -) -) - -::============================== - -:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. - -set permerror= -if %winbuild% GEQ 9200 if not defined toerr if not defined ps32onArm if exist "%tokenstore%\" ( -for %%# in ( -"%tokenstore%+FullControl" -"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" -"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" -) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( -%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% -if !errorlevel!==2 ( -if "%%A"=="%tokenstore%" ( -set "permerror=Error Found In Token Folder" -) else ( -set "permerror=Error Found In SPP Registries" -) -) -) - -REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application - -if not defined permerror ( -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( -set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" -reg query "!pol!" %nul% || reg add "!pol!" %nul% -%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% -if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" -) -) - -if defined permerror ( -call :dk_color %Red% "Checking SPP Permissions [!permerror!]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -) -set error=1 -set showfix=1 -) -) - -::============================== - -:: Check WPA Registry Errors - -set chkalp= -set wpainfo=NotFound -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wpatest\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do (set wpainfo=%%a) -for /f "delims=0123456789" %%i in ("%wpainfo%") do set chkalp=%%i - -if defined chkalp ( -call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" -if not defined showfix ( +set wpainfo= +set wpaerror= +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1])" %nul6%') do (set wpainfo=%%a) echo "%wpainfo%" | find /i "Error Found" %nul% && ( -echo: -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -echo: set error=1 -set showfix=1 -) -) -set wpainfo=a -) - -if not defined chkalp ( -if %wpainfo% GEQ 5000 ( -call :dk_color %Gray% "Checking WPA Registry Count [%wpainfo%]" -echo: -call :dk_color %Blue% "A large number of WPA registries have been found, which may cause high CPU usage." -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -echo: -) else ( +set wpaerror=1 +call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" +) || ( echo Checking WPA Registry Count [%wpainfo%] ) -) -::============================== - -:: Check Rearm - -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( -call :dk_color %Red% "Checking Rearm [System is Rearmed]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -echo: -) -set error=1 -set showfix=1 -) - - -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( -call :dk_color %Red% "Checking ClipSVC PersistedSystemState [Found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check SoftwareLicensingService - -if %error_code% NEQ 0 ( -call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] [%error_code%]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check Activation IDs - -call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f - -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=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if not defined _vis if !errorlevel! NEQ 0 set rlicfailed=1 -call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f -) - -if not defined apps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -if not defined apps if defined allapps if not defined notwinact ( -call :dk_color %Gray% "Checking Activation IDs [Key Not Installed or Act ID Not Found]" -) - -if not defined apps if not defined allapps ( -call :dk_color %Red% "Checking Activation IDs [Not found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) -set error=1 -set showfix=1 -) - -if not defined showfix if defined rlicfailed ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) - -if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( -call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]" -) - -::============================== - -:: Check Eval Windows if not defined notwinact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || ( -call :dk_color %Red% "Checking Eval Packages [License swapping found. Non-Eval licenses are installed in Eval Windows]" -if not defined showfix ( -echo: -call :dk_color %Blue% "License swapping is not the right way to upgrade to the full version. Learn the correct method at the link below." +call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]" set fixes=%fixes% %mas%evaluation_editions call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" -echo: -) -set error=1 -set showfix=1 ) ) -::============================== - -:: Check HKU\S-1-5-20\Software registry, in some systems it's missing and that causes Windows activation problems - -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( -call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check license and package files for the current edition 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%')" @@ -3530,10 +3087,12 @@ if not defined notwinact ( if %osedition%==0 ( call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" ) 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" ( set skunotfound=1 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%Edition*.mum" ( call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" @@ -3542,9 +3101,31 @@ call :dk_color %Red% "Checking Package Files [Not Found] [%osed ) ) -::============================== -:: Check SKU value to find if there is any difference +if %_wmic% EQU 1 wmic path %sps% get Version %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% +cmd /c exit /b %error_code% +if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" +if %error_code% NEQ 0 ( +set error=1 +call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] %error_code%" +) + + +set wmifailed= +if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 +echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants +if defined wmifailed ( +set error=1 +call :dk_color %Red% "Checking WMI [Not Working]" +if not defined showfix call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." +set showfix=1 +) + if not defined notwinact ( if %winbuild% GEQ 10240 ( @@ -3562,19 +3143,35 @@ call :dk_color %Gray% "Checking SLC/WMI SKU [Difference Found ) ) -::============================== +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Rearm " %Blue% "[System Restart Is Required]" +) + + +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System Restart Is Required]" +) + :: 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. -sc query wlms %nul% - -if %errorlevel% NEQ 1060 ( +if exist "%SysPath%\wlms\wlms.exe" ( echo Checking Eval WLMS Service [Found] ) -::============================== -:: Check SPP interference in IFEO +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( +set error=1 +set showfix=1 +call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" +set fixes=%fixes% %mas%in-place_repair_upgrade +call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +) + for %%# in (SppEx%w%tComObj.exe SLsvc.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=%%#")) @@ -3582,56 +3179,156 @@ reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu if defined _sppint ( echo %_sppint% | find /i "PerfOptions" %nul% && ( call :dk_color %Red% "Checking SPP Interference In IFEO [%_sppint% - System might deactivate later]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -) +if not defined showfix call :dk_color %Blue% "%_fixmsg%" set showfix=1 ) || ( echo Checking SPP In IFEO [%_sppint%] ) ) -::============================== - -:: Check and fix SkipRearm registry value 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 ( reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul% -call :dk_color %Gray% "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" ) -::============================== -:: Check SvcRestartTask status, this task helps in making sure system remains activated +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% || ( +call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]" +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" +set error=1 +set showfix=1 +) + + +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" +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" ( +set toerr=1 +set error=1 +set showfix=1 +call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +) +) + +:: 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%\" ( +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% 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)';" +set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" +set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" +set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" +%psc% "!d!" %nul% +if exist "%tokenstore%\" ( +call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" +) else ( +call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" +set error=1 +set showfix=1 +) +) + + +if not defined notwinact ( +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +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% +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined apps ( +set "_notfoundids=Key Not Installed / Act ID Not Found" +call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined allapps ( +set error=1 +set "_notfoundids=Not found" +) +call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]" +) +) +) + + +if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( +set error=1 +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" ( %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% "$s=New-Object -ComObject 'Schedule.Service'; $s.Connect(); $state=$s.GetFolder('\Microsoft\Windows\SoftwareProtectionPlatform').GetTask('SvcRestartTask').State; @{0='Unknown';1='Disabled';2='Queued';3='Ready';4='Running'}[$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% || ( 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 if "!taskinfo!"=="" set "taskinfo=Not Found" +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." +) +) +) -call :dk_color %Gray% "Checking SvcRestartTask Status [!taskinfo!. System might deactivate later.]" + +:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. + +set permerror= +if %winbuild% GEQ 9200 if not defined ps32onArm ( +for %%# in ( +"%tokenstore%+FullControl" +"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" +"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" +) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( +%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% +if !errorlevel!==2 ( +if "%%A"=="%tokenstore%" ( +set "permerror=Error Found In Token Folder" +) else ( +set "permerror=Error Found In SPP Registries" +) +) +) + +REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application + +if not defined permerror ( +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( +set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" +reg query "!pol!" %nul% || reg add "!pol!" %nul% +%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% +if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" +) +) + +if defined permerror ( +set error=1 +call :dk_color %Red% "Checking SPP Permissions [!permerror!]" +if not defined showfix call :dk_color %Blue% "%_fixmsg%" +set showfix=1 +) +) + + +:: If required services are not disabled or corrupted + if there is any error + SoftwareLicensingService errorlevel is not Zero + no fix was shown before + +if not defined serv_cor if not defined serv_cste if defined error if /i not %error_code%==0 if not defined showfix ( +if not defined permerror if defined wpaerror (call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." & set showfix=1) if not defined showfix ( -echo: -echo "!taskinfo!" | findstr /i "Removed Not Found" %nul1% && ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) || ( -call :dk_color %Blue% "Reboot your machine using the restart option and run the script again." -) -echo: -) -) +set showfix=1 +call :dk_color %Blue% "%_fixmsg%" +if not defined permerror call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." ) ) -::============================== +if not defined showfix if defined wpaerror ( +set showfix=1 +call :dk_color %Blue% "If activation fails then go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." +) exit /b @@ -3723,7 +3420,7 @@ call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" choice /C:10 /N if !errorlevel!==2 exit /b -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -4225,12 +3922,15 @@ exit /b :: Separator = _ -:kmsfallback +:kms38fallback set notfoundaltactID= if %_NoEditionChange%==1 exit /b for %%# in ( +188_IoTEnterprise__________________8ab9bdd1-1f67-4997-82d9-8878520837d9_73111121-5638-40f6-bc11-f1d7b0d64300_NPPR9-FWDCX-D2C8J-H872K-2Y%f%T43_Enterprise +206_IoTEnterpriseK_________________80083eae-7031-4394-9e88-4901973d56fe_73111121-5638-40f6-bc11-f1d7b0d64300_NPPR9-FWDCX-D2C8J-H872K-2Y%f%T43_Enterprise +191_IoTEnterpriseS-2021____________ed655016-a9e8-4434-95d9-4345352c2552_32d2fab3-e4a8-42c2-923b-4bf4fd13e6ee_M7XTQ-FN8P6-TTKYV-9D4CC-J4%f%62D_EnterpriseS-2021 205_IoTEnterpriseSK________________d4f9b41f-205c-405e-8e08-3d16e88e02be_59eb965c-9150-42b7-a0ec-22151b9897c5_KBN8V-HFGQ4-MGXVD-347P6-PD%f%QGT_IoTEnterpriseS 138_ProfessionalSingleLanguage_____a48938aa-62fa-4966-9d44-9f04da3f72f2_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional 139_ProfessionalCountrySpecific____f7af7d09-40e4-419c-a49b-eae366689ebd_2de67392-b7a7-462a-b1ca-108dd189f588_W269N-WFGWX-YVC9B-4J6C9-T8%f%3GX_Professional diff --git a/MAS/Separate-Files-Version/Activators/TSforge_Activation.cmd b/MAS/Separate-Files-Version/Activators/TSforge_Activation.cmd index d966498..b5bf9f5 100644 --- a/MAS/Separate-Files-Version/Activators/TSforge_Activation.cmd +++ b/MAS/Separate-Files-Version/Activators/TSforge_Activation.cmd @@ -1,11 +1,12 @@ -@set masver=3.9 +@set masver=3.2 @echo off ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -44,11 +45,6 @@ set tsids= :: To reset rearm counter, evaluation period and clear the tamper state, key lock, run the script with "/Z-Reset" parameter or change 0 to 1 in below line set _resall=0 -:: Choose activation method: -:: In builds 26100 and later, the script will auto select StaticCID (requires internet). If no internet is detected, it will then auto select the KMS4k method. For builds lower than 26100, the script will auto select ZeroCID. -:: To change the activation method, run the script with the parameters "/Z-SCID", "/Z-ZCID", or "/Z-KMS4k", or modify the option from Auto to SCID, ZCID, or KMS4k in the line below. -set _actmethod=Auto - :: Debug Mode: :: To run the script in debug mode, change 0 to any parameter above that you want to run, in below line set "_debug=0" @@ -83,7 +79,6 @@ set "_cmdf=%~f0" for %%# in (%*) do ( if /i "%%#"=="re1" set re1=1 if /i "%%#"=="re2" set re2=1 -if /i "%%#"=="-qedit" (set re1=1&set re2=1) ) :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows @@ -134,8 +129,6 @@ set "nul=" set "blank=" set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" -set "github=ht%blank%tps%blank%://github.com/massgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" -set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/massg%blank%rave/Micr%blank%osoft-Act%blank%ivation-Scripts" :: Check if Null service is working, it's important for the batch script @@ -196,14 +189,10 @@ if /i "%%A"=="/Z-OffHost" (set _actoffhost=1) if /i "%%A"=="/Z-APPX" (set _actappx=1) echo "%%A" | find /i "/Z-ID-" >nul && (set _actman=1& set "filtsids=%%A" & call set "filtsids=%%filtsids:~6%%" & if defined filtsids call set tsids=%%filtsids%% %%tsids%%) if /i "%%A"=="/Z-Reset" (set _resall=1) -if /i "%%A"=="/Z-SCID" (set _actmethod=SCID) -if /i "%%A"=="/Z-ZCID" (set _actmethod=ZCID) -if /i "%%A"=="/Z-KMS4k" (set _actmethod=KMS4k) ) if not defined tsids set _actman=0 for %%A in (%_actwin% %_actesu% %_actoff% %_actprojvis% %_actwinesuoff% %_actwinhost% %_actoffhost% %_actappx% %_actman% %_resall%) do (if "%%A"=="1" set _unattended=1) -if /i not %_actmethod%==Auto set _unattended=1 ::======================================================================================================================================== @@ -219,16 +208,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto dk_done ) -if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( -sc query gcs | find /i "RUNNING" %nul% && ( -%eline% -echo Windows Sandbox detected; activation is not supported. -echo The script cannot run due to missing licensing components. Aborting... -echo: -goto dk_done -) -) - if %winbuild% LSS 6001 ( %nceline% echo Unsupported OS version detected [%winbuild%]. @@ -259,8 +238,8 @@ reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" /v Install %nul echo .NET 3.5 Framework is not installed in your system. echo Install it using the following URL. echo: -echo https://www.microsoft.com/en-us/download/details.aspx?id=25150 -if %_unattended%==0 start https://www.microsoft.com/en-us/download/details.aspx?id=25150 +echo https://www.microsoft.com/download/details.aspx?id=25150 +if %_unattended%==0 start https://www.microsoft.com/download/details.aspx?id=25150 goto dk_done ) ) @@ -313,18 +292,16 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) +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% -for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) -echo Test 1 - %tstresult% -echo Test 2 - !tstresult2! -echo: +echo: %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" REM check LanguageMode -echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +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: @@ -337,9 +314,6 @@ 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... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" goto dk_done ) @@ -354,33 +328,10 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_ goto dk_done ) -REM check if .NET is working properly - -if /i "!tstresult2!"=="FullLanguage" ( -cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% -if !errorlevel!==3 ( -echo Windows Powershell failed to load .NET command. Aborting... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -goto dk_done -) -) - REM check antivirus and other errors echo PowerShell is not working properly. Aborting... - -if /i "!tstresult2!"=="FullLanguage" ( -echo: -echo Your antivirus software might be blocking the script. -echo: -sc query sense | find /i "RUNNING" %nul% && ( -echo Installed Antivirus - Microsoft Defender for Endpoint -) -cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" -) - +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" @@ -401,9 +352,7 @@ set terminal= if defined terminal ( set lines=0 -for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( -for %%B in (%%A) do set lines=%%B -) +for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A if !lines! GEQ 100 set terminal= ) @@ -464,7 +413,7 @@ echo: call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" choice /C:10 /N if !errorlevel!==2 rem -if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) +if !errorlevel!==1 (start %mas% & exit /b) ) ) @@ -500,7 +449,6 @@ echo [E] Reset - Rearm/Timers ) else ( echo [E] Reset - Rearm/Timers/Tamper/Lock ) -echo [F] Change - Activation Method [%_actmethod%] echo _______________________________________________ echo: echo [6] Remove TSforge Activation @@ -509,13 +457,12 @@ echo [0] %_exitmsg% echo ______________________________________________________________ echo: call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard..." -choice /C:12345ABCDEF670 /N +choice /C:12345ABCDE670 /N set _el=!errorlevel! -if !_el!==14 exit /b -if !_el!==13 start %mas%genuine-installation-media & goto :ts_menu -if !_el!==12 call :ts_remove & cls & goto :ts_menu -if !_el!==11 goto :ts_changemethod +if !_el!==13 exit /b +if !_el!==12 start %mas%genuine-installation-media & goto :ts_menu +if !_el!==11 call :ts_remove & cls & goto :ts_menu if !_el!==10 cls & setlocal & set "_resall=1" & call :ts_start & endlocal & cls & goto :ts_menu if !_el!==9 cls & setlocal & set "_actman=1" & call :ts_start & endlocal & cls & goto :ts_menu if !_el!==8 cls & setlocal & set "_actappx=1" & call :ts_start & endlocal & cls & goto :ts_menu @@ -529,56 +476,6 @@ if !_el!==1 cls & setlocal & set "_actwin=1" & call :ts_start & endlocal goto :ts_menu ) -goto :ts_start - -::======================================================================================================================================== - -:ts_changemethod - -cls -if not defined terminal mode 76, 36 - -echo: -echo: -echo: -echo ______________________________________________________________ -echo: -call :dk_color2 %_White% " [1] " %_Green% "Auto" -echo Builds ^>= 26100 - StaticCID (KMS4k if offline) -echo Builds ^< 26100 - ZeroCID -echo __________________________________________________ -echo: -echo [2] StaticCID -echo Needs Internet -echo Not for Windows 7 or older -echo __________________________________________________ -echo: -echo [3] ZeroCID -echo Works reliably on builds below 26100 -echo Does not work on builds above 26100.4188 -echo __________________________________________________ -echo: -echo [4] KMS4k -echo Volume licenses only -echo Activates for 4000+ years -echo __________________________________________________ -echo: -echo [5] Learn More -echo [0] %_exitmsg% -echo ______________________________________________________________ -echo: -call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard..." -choice /C:123450 /N -set _el=!errorlevel! - -if !_el!==6 goto :ts_menu -if !_el!==5 cls & start %mas%tsforge &goto :ts_menu -if !_el!==4 cls & set "_actmethod=KMS4k" & goto :ts_menu -if !_el!==3 cls & set "_actmethod=ZCID" & goto :ts_menu -if !_el!==2 cls & set "_actmethod=SCID" & goto :ts_menu -if !_el!==1 cls & set "_actmethod=Auto" & goto :ts_menu -goto :ts_changemethod - ::======================================================================================================================================== :ts_start @@ -605,8 +502,8 @@ 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%in-place_repair_upgrade -call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) goto dk_done ) @@ -661,57 +558,6 @@ cls echo: call :dk_showosinfo -if /i %_actmethod%==SCID set tsmethod=StaticCID -if /i %_actmethod%==ZCID set tsmethod=ZeroCID -if /i %_actmethod%==KMS4k set tsmethod=KMS4k - -if /i %_actmethod%==Auto ( -if %winbuild% GEQ 26100 ( -set tsmethod=StaticCID -) else ( -set tsmethod=ZeroCID -) -) - -if %winbuild% LSS 9200 if /i %tsmethod%==StaticCID ( -%eline% -echo StaticCID method is supported only on Windows 8 and later. -goto dk_done -) - -::======================================================================================================================================== - -:: Check Internet connection - -if /i %tsmethod%==StaticCID ( -set _int= -for %%a in (l.root-servers.net resolver1.opendns.com download.windowsupdate.com google.com) do if not defined _int ( -for /f "delims=[] tokens=2" %%# in ('ping -n 1 %%a') do (if not "%%#"=="" set _int=1) -) - -if not defined _int ( -%psc% "If([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet){Exit 0}Else{Exit 1}" -if !errorlevel!==0 (set _int=1&set ping_f= But Ping Failed) -) - -if defined _int ( -echo Checking Internet Connection [Connected!ping_f!] -) else ( -if /i %_actmethod%==Auto if not %_actman%==1 set tsmethod=KMS4k -if /i !tsmethod!==KMS4k ( -call :dk_color %Red% "Checking Internet Connection [Not Connected]" -call :dk_color %Blue% "Switching To KMS4k activation because Internet is needed for StaticCID method." -) else ( -set error=1 -call :dk_color %Red% "Checking Internet Connection [Not Connected]" -call :dk_color %Blue% "Internet is required for TSforge StaticCID option." -) -echo: -) -) - -::======================================================================================================================================== - echo Initiating Diagnostic Tests... set "_serv=%_slser% Winmgmt" @@ -729,11 +575,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto :dk_done ) -if /i !tsmethod!==KMS4k ( -call :_taskclear-cache -echo Clearing %KS% Cache [Successful] -) - ::======================================================================================================================================== if %_resall%==1 goto :ts_resetall @@ -755,24 +596,17 @@ echo %tsedition% | find /i "Eval" %nul1% && ( goto :ts_wineval ) -set /a UBR=0 -if %winbuild% EQU 26100 ( -for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR %nul6%') do if not errorlevel 1 set /a UBR=%%b -if !UBR! LSS 4188 (set dontcheckact=1) -) - -if not defined dontcheckact call :ts_checkwinperm +call :ts_checkwinperm if defined _perm ( call :dk_color %Gray% "Checking OS Activation [Windows is already permanently activated]" goto :ts_esu ) -if %winbuild% LSS 9200 if /i %tsmethod%==KMS4k goto :ts_oldks if defined _vis goto :ts_winvista set tempid= -if /i %tsmethod%==KMS4k (set keytype=ks) else (set keytype=zero) -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wintsid\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do ( +set keytype=zero +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wintsid\:.*';iex ($f[1])" %nul6%') do ( echo "%%a" | findstr /r ".*-.*-.*-.*-.*" %nul1% && (set tsids=!tsids! %%a& set tempid=%%a) ) @@ -781,13 +615,6 @@ echo Checking Activation ID [%tempid%] [%tsedition%] ) else ( call :dk_color %Red% "Checking Activation ID [Not Found] [%tsedition%] [%osSKU%]" set error=1 -if /i %tsmethod%==KMS4k ( -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -) goto :ts_esu ) @@ -795,83 +622,6 @@ if defined winsub ( call :dk_color %Blue% "Windows Subscription [SKU ID-%slcSKU%] found. Script will activate base edition [SKU ID-%regSKU%]." echo: ) - -goto :ts_esu - -::======================================================================================================================================== - -:ts_oldks - -:: KMS keys for KMS4k method because TSforge cannot install KMS key on Windows Vista and 7 - -:: 1st column = Activation ID -:: 2nd column = Generic key -:: 3rd column = Edition ID -:: Separator = _ - -set f= -set key= -set tempid= -if not defined allapps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -for %%# in ( -:: Windows 7 -ae2ee509-1b34-41c0-acb7-6d4650168915_33PXH-7Y6KF-2VJC9-XBBR8-HV%f%THH_Enterprise -1cb6d605-11b3-4e14-bb30-da91c8e3983a_YDRBP-3D83W-TY26F-D46B2-XC%f%KRJ_EnterpriseN -b92e9980-b9d5-4821-9c94-140f632f6312_FJ82H-XT6CR-J8D7P-XQJJ2-GP%f%DD4_Professional -54a09a0d-d57b-4c10-8b69-a842d6590ad5_MRPKT-YTG23-K7D7T-X2JMM-QY%f%7MG_ProfessionalN -db537896-376f-48ae-a492-53d0547773d0_YBYF6-BHCR3-JPKRB-CDW7B-F9%f%BK4_Embedded_POSReady -aa6dd3aa-c2b4-40e2-a544-a6bbb3f5c395_73KQT-CD9G6-K7TQG-66MRP-CQ%f%22C_Embedded_ThinPC -5a041529-fef8-4d07-b06f-b59b573b32d2_W82YF-2Q76Y-63HXB-FGJG9-GF%f%7QX_ProfessionalE -46bbed08-9c7b-48fc-a614-95250573f4ea_C29WB-22CC8-VJ326-GHFJW-H9%f%DH4_EnterpriseE -:: Windows Server 2008 R2 -68531fb9-5511-4989-97be-d11a0f55633f_YC6KT-GKW9T-YTKYR-T4X34-R7%f%VHC_ServerStandard -7482e61b-c589-4b7f-8ecc-46d455ac3b87_74YFP-3QFB3-KQT8W-PMXWJ-7M%f%648_ServerDatacenter -620e2b3d-09e7-42fd-802a-17a13652fe7a_489J6-VHDMP-X63PK-3K798-CP%f%X3Y_ServerEnterprise -7482e61b-c589-4b7f-8ecc-46d455ac3b87_74YFP-3QFB3-KQT8W-PMXWJ-7M%f%648_ServerDatacenterCore -68531fb9-5511-4989-97be-d11a0f55633f_YC6KT-GKW9T-YTKYR-T4X34-R7%f%VHC_ServerStandardCore -620e2b3d-09e7-42fd-802a-17a13652fe7a_489J6-VHDMP-X63PK-3K798-CP%f%X3Y_ServerEnterpriseCore -8a26851c-1c7e-48d3-a687-fbca9b9ac16b_GT63C-RJFQ3-4GMB6-BRFB9-CB%f%83V_ServerEnterpriseIA64 -a78b8bd9-8017-4df5-b86a-09f756affa7c_6TPJF-RBVHG-WBW2R-86QPH-6R%f%TM4_ServerWeb -cda18cf3-c196-46ad-b289-60c072869994_TT8MH-CG224-D3D7Q-498W2-9Q%f%CTX_ServerHPC -a78b8bd9-8017-4df5-b86a-09f756affa7c_6TPJF-RBVHG-WBW2R-86QPH-6R%f%TM4_ServerWebCore -f772515c-0e87-48d5-a676-e6962c3e1195_736RG-XDKJK-V34PF-BHK87-J6%f%X3K_ServerEmbeddedSolution -:: Windows Vista -cfd8ff08-c0d7-452b-9f60-ef5c70c32094_VKK3X-68KWM-X2YGT-QR4M6-4B%f%WMV_Enterprise -4f3d1606-3fea-4c01-be3c-8d671c401e3b_YFKBB-PQJJV-G996G-VWGXY-2V%f%3X8_Business -2c682dc2-8b68-4f63-a165-ae291d4cf138_HMBQG-8H2RH-C77VX-27R82-VM%f%QBT_BusinessN -d4f54950-26f2-4fb4-ba21-ffab16afcade_VTC42-BM838-43QHV-84HX6-XJ%f%XKV_EnterpriseN -:: Windows Server 2008 -ad2542d4-9154-4c6d-8a44-30f11ee96989_TM24T-X9RMF-VWXK6-X8JC9-BF%f%GM2_ServerStandard -68b6e220-cf09-466b-92d3-45cd964b9509_7M67G-PC374-GR742-YH8V4-TC%f%BY3_ServerDatacenter -c1af4d90-d1bc-44ca-85d4-003ba33db3b9_YQGMW-MPWTJ-34KDK-48M3W-X4%f%Q6V_ServerEnterprise -01ef176b-3e0d-422a-b4f8-4ea880035e8f_4DWFP-JF3DJ-B7DTH-78FJB-PD%f%RHK_ServerEnterpriseIA64 -ddfa9f7c-f09e-40b9-8c1a-be877a9a7f4b_WYR28-R7TFJ-3X2YQ-YCY4H-M2%f%49D_ServerWeb -7afb1156-2c1d-40fc-b260-aab7442b62fe_RCTX3-KWVHP-BR6TB-RB6DM-6X%f%7HP_ServerComputeCluster -2401e3d0-c50a-4b58-87b2-7e794b7d2607_W7VD6-7JFBR-RX26B-YKQ3Y-6F%f%FFJ_ServerStandardV -fd09ef77-5647-4eff-809c-af2b64659a45_22XQ2-VRXRG-P8D42-K34TD-G3%f%QQC_ServerDatacenterV -8198490a-add0-47b2-b3ba-316b12d647b4_39BXF-X8Q23-P2WWT-38T2F-G3%f%FPG_ServerEnterpriseV -) do ( -for /f "tokens=1-3 delims=_" %%A in ("%%#") do if %tsedition%==%%C if not defined key ( -echo "%allapps%" | find /i "%%A" %nul1% && ( -set key=%%B -set tempid=%%A -) -) -) - -if not defined key ( -call :dk_color %Red% "Checking Activation ID [%tsedition% SKU-%osSKU% %KS% key is not available]" -call :dk_color %Blue% "Use ZeroCID activation method from the previous menu." -goto :ts_esu -) - -echo Checking Activation ID [%tempid%] [%tsedition%] - -set oldks=1 -set generickey=1 -call :dk_inskey "[%key%]" -set tsids=%tsids% %tempid% goto :ts_esu ::======================================================================================================================================== @@ -952,7 +702,7 @@ echo Checking Activation ID [%tempid%] [%tsedition%] set generickey=1 call :dk_inskey "[%key%]" -set tsids=%tsids% %tempid% +if not defined error set tsids=%tsids% %tempid% goto :ts_esu ::======================================================================================================================================== @@ -1062,7 +812,7 @@ goto :ts_esu ) set resetstuff=1 -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':tsforge\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':tsforge\:.*';iex ($f[1])" set resetstuff= if !errorlevel!==3 ( set error=1 @@ -1081,15 +831,6 @@ call :dk_inskey "[%key%]" :ts_esu if not %_actesu%==1 goto :ts_off -if /i %tsmethod%==KMS4k ( -call :dk_color %Red% "Skipping Windows ESU [KMS4k method is not supported with Windows ESU]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -goto :ts_off -) :: Process Windows ESU @@ -1111,19 +852,6 @@ if exist "%SystemRoot%\Servicing\Packages\WinEmb-Branding-Embedded-Standard-Pack ) if not defined allapps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f -set w10EsuEditions=Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN - -set minbuild=0 -if /i %tsedition%==ServerRdsh set minbuild=5552 -for %%# in (Core CoreN CoreCountrySpecific CoreSingleLanguage IoTEnterprise) do (if /i %tsedition%==%%# set minbuild=6156) -if /i %tsedition%==PPIPro set minbuild=6388 - -set /a UBR=0 -for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR %nul6%') do if not errorlevel 1 set /a UBR=%%b -if %winbuild% EQU 19045 if %minbuild% GTR 0 if %UBR% GEQ %minbuild% ( -set w10EsuEditionsLaterAdded=%tsedition%- -) - if not defined isThinpc if not defined isltsc for %%# in ( REM Windows7 4220f546-f522-46df-8202-4d07afd26454_Client-ESU-Year3[1-3y]_-Enterprise-EnterpriseE-EnterpriseN-Professional-ProfessionalE-ProfessionalN-Ultimate-UltimateE-UltimateN- @@ -1140,10 +868,14 @@ REM Windows8.1 REM WindowsServer2012/2012R2 55b1dd2d-2209-4ea0-a805-06298bad25b3_Server-ESU-Year3[1-3y]_-ServerDatacenter-ServerDatacenterCore-ServerDatacenterV-ServerDatacenterVCore-ServerStandard-ServerStandardCore-ServerStandardV-ServerStandardVCore- REM Windows10 -f520e45e-7413-4a34-a497-d2765967d094_Client-ESU-Year1_-%w10EsuEditions%-%w10EsuEditionsLaterAdded% -1043add5-23b1-4afb-9a0f-64343c8f3f8d_Client-ESU-Year2_-%w10EsuEditions%-%w10EsuEditionsLaterAdded% -83d49986-add3-41d7-ba33-87c7bfb5c0fb_Client-ESU-Year3_-%w10EsuEditions%-%w10EsuEditionsLaterAdded% -0b533b5e-08b6-44f9-b885-c2de291ba456_Client-ESU-Year6[4-6y]_-%w10EsuEditions%-%w10EsuEditionsLaterAdded% +f520e45e-7413-4a34-a497-d2765967d094_Client-ESU-Year1_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN-ServerRdsh- +1043add5-23b1-4afb-9a0f-64343c8f3f8d_Client-ESU-Year2_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN-ServerRdsh- +83d49986-add3-41d7-ba33-87c7bfb5c0fb_Client-ESU-Year3_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN-ServerRdsh- +0b533b5e-08b6-44f9-b885-c2de291ba456_Client-ESU-Year6[4-6y]_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN-ServerRdsh- +b8527af1-5389-447c-9a88-2d1691ea33d3_Client-IoT-ESU-Year1_-IoTEnterprise- +7b76ee02-0a75-4f08-85d5-bd0feadad0c0_Client-IoT-ESU-Year2_-IoTEnterprise- +4dac5a0c-5709-4595-a32c-14a56a4a6b31_Client-IoT-ESU-Year3_-IoTEnterprise- +f69e2d51-3bbd-4ddf-8da7-a145e9dca597_Client-IoT-ESU-Year6[4-6y]_-IoTEnterprise- ) do ( for /f "tokens=1-3 delims=_" %%A in ("%%#") do ( echo "%allapps%" | find /i "%%A" %nul1% && ( @@ -1185,12 +917,7 @@ goto :ts_off ) if defined esuexistbutnosup ( -call :dk_color %Red% "Checking Activation ID [Currently installed ESU License is not supported for %tsedition%]" -echo: -if %winbuild% EQU 19045 if not defined w10EsuEditionsLaterAdded ( -call :dk_color %Blue% "To get latest version, go to Windows settings and run Windows Update. After that, try the script again." -goto :ts_off -) +call :dk_color %Red% "Checking Activation ID [Commercial ESU is not supported for %tsedition%]" call :dk_color %Blue% "Go back to Main Menu, select Change Windows Edition option and change to any of the below listed editions." echo [%esueditionlist%] goto :ts_off @@ -1317,7 +1044,7 @@ call :dk_color %Gray% "Checking Installed Office [Not Found]" if defined ohub ( echo: -echo You only have the Office Dashboard app installed. You need to install the full version of Office. +echo You have only Office dashboard app installed, you need to install full Office version. ) call :dk_color %Blue% "Download and install Office from below URL and try again." if %_actwin%==0 set fixes=%fixes% %mas%genuine-installation-media @@ -1421,7 +1148,6 @@ set error=1 goto :ts_starto16c2r ) -call :oh_expiredpreview 2013 if "%_actprojvis%"=="0" call :oh_fixprids call :ts_process @@ -1463,30 +1189,11 @@ set error=1 goto :ts_startmsi ) -call :oh_expiredpreview 2016 2019 2021 2024 if "%_actprojvis%"=="0" call :oh_fixprids call :ts_process ::======================================================================================================================================== -:: mass{}grave{dot}dev/office-license-is-not-genuine -:: Add registry keys for volume products so that 'non-genuine' banner won't appear - -set "kmskey=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\0ff1ce15-a989-479d-af46-f275c6370663" -if /i %tsmethod%==KMS4k ( -if %winbuild% GEQ 9200 ( -if not "%osarch%"=="x86" ( -reg delete "%kmskey%" /f /reg:32 %nul% -reg add "%kmskey%" /f /v KeyManagementServiceName /t REG_SZ /d "10.0.0.10" /reg:32 %nul% -) -reg delete "%kmskey%" /f %nul% -reg add "%kmskey%" /f /v KeyManagementServiceName /t REG_SZ /d "10.0.0.10" %nul% -echo Adding a Registry to Prevent Banner [Successful] -) -) - -::======================================================================================================================================== - :ts_startmsi if defined o15msi call :ts_processmsi 15 %o15msi_reg% @@ -1510,17 +1217,6 @@ goto :ts_act echo: echo Processing Windows %KS% Host... -if /i %tsmethod%==KMS4k ( -echo: -call :dk_color %Red% "Skipping Windows %KS% Host [KMS4k method is not supported with Windows %KS% Host]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -goto :ts_act -) - echo: if %winbuild% GEQ 10586 ( call :dk_color %Gray% "With %KS% Host license, system may randomly change Windows Edition later. It is a Windows issue and can be safely ignored." @@ -1547,10 +1243,10 @@ if %winbuild% GEQ 10586 ( for %%# in ("%SysPath%\spp\tokens\skus\%tsedition%\*CSVLK*.xrm-ms") do ( if defined _arr (set "_arr=!_arr!;"%SysPath%\spp\tokens\skus\%tsedition%\%%~nx#"") else (set "_arr="%SysPath%\spp\tokens\skus\%tsedition%\%%~nx#"") ) -if defined _arr %psc% "$sls = Get-WmiObject %sps%; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); InstallLicenseArr '!_arr!'" %nul% +if defined _arr %psc% "$sls = Get-WmiObject %sps%; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); InstallLicenseArr '!_arr!'" %nul% ) -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wintsid\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do ( +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wintsid\:.*';iex ($f[1])" %nul6%') do ( echo "%%a" | findstr /r ".*-.*-.*-.*-.*" %nul1% && (set tsids=!tsids! %%a& set tempid=%%a) ) @@ -1614,7 +1310,7 @@ goto :ts_act ) call :dk_inskey "[%key%]" -set tsids=%tsids% %tempid% +if not defined error set tsids=%tsids% %tempid% goto :ts_act ::======================================================================================================================================== @@ -1632,17 +1328,6 @@ call :dk_color %Blue% "Windows Vista and Server 2008 do not support the installa goto :ts_act ) -if /i %tsmethod%==KMS4k ( -echo: -call :dk_color %Red% "Skipping Office %KS% Host [KMS4k method is not supported with Office %KS% Host]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -goto :ts_act -) - set ohostexist= call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 set ohostids=%allapps% @@ -1695,17 +1380,6 @@ call :dk_color %Gray% "Checking Activation ID [APPX Sideloading goto :dk_done ) -if /i %tsmethod%==KMS4k ( -echo: -call :dk_color %Red% "Skipping Windows 8/8.1 APPX [KMS4k method is not supported with Windows 8/8.1 APPX]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -goto :dk_done -) - set appxexist= if not defined allapps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f @@ -1744,7 +1418,7 @@ echo Processing Reset of Rearm / Timers / Tamper / Lock... echo: set resetstuff=1 -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':tsforge\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':tsforge\:.*';iex ($f[1])" if %errorlevel%==3 ( call :dk_color %Red% "Reset Failed." @@ -1764,17 +1438,6 @@ echo: echo Processing Manual Activation... echo: -if /i %tsmethod%==KMS4k ( -echo: -call :dk_color %Red% "Skipping Manual Activation [KMS4k method is not supported with it]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -goto :dk_done -) - call :dk_color %Gray% "This option is for advanced users, those who already know what they are doing." call :dk_color %Blue% "Some activation IDs may cause system crash [MUI mismatch], or irreversible changes [CloudEdition etc]." @@ -1792,7 +1455,7 @@ if %errorlevel%==1 exit /b echo: echo Fetching Supported Activation IDs list. Please wait... -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':listactids\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':listactids\:.*';iex ($f[1])" if %errorlevel%==3 ( call :dk_color %Gray% "No supported activation ID found, aborting..." goto :dk_done @@ -1867,14 +1530,14 @@ $filteredResults = $results | Where-Object { $true } else { - $_.Name -like "*ESU*" -or $_.Name -notlike "*CountrySpecific*" + $_.Name -notlike "*CountrySpecific*" } } | Where-Object { if ($env:tsedition -like "*CloudEdition*") { $true } else { - $_.Name -like "*ESU*" -or $_.Name -notlike "*CloudEdition*" + $_.Name -notlike "*CloudEdition*" } } | Where-Object { $_.Name -like "*CountrySpecific*" -or (IsMuiNotLocked $_.ID) @@ -1927,7 +1590,6 @@ call :dk_color %Gray% "To activate, check your internet connection and ensure th ) else ( call :dk_color %Blue% "This Windows version is known to not activate due to MS Windows/Server issues." ) -if not defined showfix call :dk_color %Blue% "%_fixmsg%" set fixes=%fixes% %mas%troubleshoot call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) @@ -1935,39 +1597,26 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble if defined tsids ( echo: -if not defined _vis if not defined oldks echo Installing Forged Product Key Data... -if /i %tsmethod%==KMS4k ( -echo Writing TrustedStore data... -) else ( -if /i %tsmethod%==StaticCID (echo Depositing Static Confirmation ID...) else (echo Depositing Zero Confirmation ID...) -) +if not defined _vis echo Installing Forged Product Key Data... +echo Depositing Zero Confirmation ID... echo: -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':tsforge\:.*';. ([scriptblock]::Create($f[1])) %tsids%" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':tsforge\:.*';& ([ScriptBlock]::Create($f[1])) %tsids%" if !errorlevel!==3 ( -if %_actman%==0 (if not defined showfix call :dk_color %Blue% "%_fixmsg%") +if %_actman%==0 call :dk_color %Blue% "%_fixmsg%" set fixes=%fixes% %mas%troubleshoot call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" ) else ( -if /i %tsmethod%==KMS4k if %winbuild% GEQ 26100 ( -echo: -call :dk_color %Gray% "In Windows settings, you may see a renewal notification for activation that can be ignored." -if /i %_actmethod%==Auto call :dk_color %Gray% "To avoid this notification, run the script with an internet connection to use the StaticCID method." -) echo "%tsids%" | find /i "7e94be23-b161-4956-a682-146ab291774c" %nul1% && ( -call :dk_color %Gray% "Windows Update gets 1-3 years of ESU; 4-6 are unofficial but let you install Server 2008 R2 updates manually." +call :dk_color %Gray% "Windows Update can receive 1-3 years of ESU. 4-6 years ESU is not officially supported, but you can manually install updates." ) echo "%tsids%" | findstr /i "4afc620f-12a4-48ad-8015-2aebfbd6e47c 11be7019-a309-4763-9a09-091d1722ffe3" %nul1% && ( -call :dk_color %Gray% "ESU is not officially supported on Windows 8.1, but updates can be installed manually until January 2024." +call :dk_color %Gray% "ESU is not officially supported on Windows 8.1, but you can manually install updates until Jan-2024." ) -echo "%tsids%" | findstr /i "83d49986-add3-41d7-ba33-87c7bfb5c0fb 0b533b5e-08b6-44f9-b885-c2de291ba456" %nul1% && ( -call :dk_color %Gray% "Windows Update gets 1-3 years of ESU; 4-6 are unofficial but may let you install LTSC updates manually." -if exist %SysPath%\ClipESUConsumer.exe (%SysPath%\ClipESUConsumer.exe -evaluateEligibility) -if exist %SysPath%\ClipESU.exe (%SysPath%\ClipESU.exe %nul%) +echo "%tsids%" | findstr /i "0b533b5e-08b6-44f9-b885-c2de291ba456 f69e2d51-3bbd-4ddf-8da7-a145e9dca597" %nul1% && ( +call :dk_color %Gray% "Windows Update can receive 1-3 years of ESU. 4-6 years ESU is not officially supported, but it might be useful." ) ) -if defined esuexistsup echo Help: %mas%tsforge#windows-esu - if %_actwin%==1 for %%# in (407) do if %osSKU%==%%# ( call :dk_color %Red% "%winos% does not support activation on non-azure platforms." ) @@ -2055,28 +1704,6 @@ exit /b ::======================================================================================================================================== -:oh_expiredpreview - -echo %_oIds% | find /i "Volume" %nul% || exit /b - -for %%# in (%*) do ( -if %%#==2013 set _offver= -if %%#==2016 set _offver= -if %%#==2019 set _offver=2019 -if %%#==2021 set _offver=2021 -if %%#==2024 set _offver=2024 -if exist "!_oLPath!\ProPlus!_offver!PreviewVL_*.xrm-ms" if not exist "!_oLPath!\ProPlus!_offver!VL_*.xrm-ms" ( -set error=1 -set showfix=1 -call :dk_color %Red% "Checking Expired Preview Products [Office %%# Preview Found]" -call :dk_color %Blue% "Please run the Office updates first, and then attempt to activate it again." -) -) - -exit /b - -::======================================================================================================================================== - :: Some Office Retail to Volume converter tools may edit the ProductReleaseIds to add VL products. This code restores it because it may affect features. :oh_fixprids @@ -2151,19 +1778,6 @@ set _preview= set _License=%%# set skipprocess= - -set foundprod= -call :tsksdata chkprod %%# -if defined _oMSI if not defined foundprod if /i %tsmethod%==KMS4k ( -set skipprocess=1 -call :dk_color %Red% "Checking Product In Script [%%# MSI Retail is not supported with KMS4k]" -if /i %_actmethod%==Auto ( -call :dk_color %Blue% "Connect to the Internet and try again. Script will use the StaticCID activation method." -) else ( -call :dk_color %Blue% "Use non-KMS4K activation options from the previous menu." -) -) - if "%_actprojvis%"=="1" ( echo %%# | findstr /i "Project Visio" %nul% || ( set skipprocess=1 @@ -2171,17 +1785,8 @@ call :dk_color %Gray% "Skipping Because Project/Visio Mode [%%#]" ) ) -if "%_actprojvis%"=="0" if /i %tsmethod%==KMS4k echo %_oIds% | findstr /i "O365" %nul% && ( -echo %%# | findstr /i "Project Visio" %nul% && ( -set skipprocess=1 -echo Skipping Because Mondo Is Available [%%#] -) -) - - if not defined skipprocess ( -if /i not %tsmethod%==KMS4k ( set no365= if "%oVer%"=="15" (echo %%# | findstr /i "O365HomePremRetail" %nul% && set no365=1) if "%oVer%"=="16" (echo %%# | findstr /i "O365" %nul% && set no365=1) @@ -2191,8 +1796,6 @@ set _License=MondoRetail set _altoffid=MondoRetail call :ks_osppready echo Converting Unsupported O365 Office [%%# To MondoRetail] -if "%oVer%"=="15" (call :dk_color %Gray% "Mondo 2013 is equivalent to O365 [15.0 version] in terms of the latest features.") -if "%oVer%"=="16" (call :dk_color %Gray% "Mondo 2016 is equivalent to O365 in terms of the latest features.") ) if not defined _oMSI ( @@ -2203,31 +1806,9 @@ call :ks_osppready echo Converting Unsupported OEM-ARM Office [%%# To MondoRetail] ) ) -) -if not defined _oMSI if /i %tsmethod%==KMS4k if not defined foundprod ( -call :tsksdata getinfo %%# -if defined _altoffid ( -echo Converting Retail To Volume [%%# To !_altoffid!] -) else ( -set _License=MondoVolume -set _altoffid=MondoVolume -echo Converting Retail To Volume [%%# To !_altoffid!] [Using Mondo because %%# is not found in the script] -) -echo %%# | find /i "O365" %nul% && ( -if "%oVer%"=="15" (call :dk_color %Gray% "Mondo 2013 is equivalent to O365 [15.0 version] in terms of the latest features.") -if "%oVer%"=="16" (call :dk_color %Gray% "Mondo 2016 is equivalent to O365 in terms of the latest features.") -) -call :ks_osppready -) - -if /i %tsmethod%==KMS4k ( -echo !_License! | find /i "Retail" %nul% && (set keytype=zero) || (set keytype=ks) -) else ( set keytype=zero -) - -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':offtsid\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do ( +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':offtsid\:.*';iex ($f[1])" %nul6%') do ( echo "%%a" | findstr /r ".*-.*-.*-.*-.*" %nul1% && (set tsids=!tsids! %%a& set _actid=%%a) ) set "_allactid=!tsids!" @@ -2255,7 +1836,7 @@ echo "!allapps!" | find /i "!_actid!" %nul1% || call :oh_installlic :: Add SharedComputerLicensing registry key if Retail Office C2R is installed on Windows Server :: https://learn.microsoft.com/en-us/office/troubleshoot/office-suite-issues/click-to-run-office-on-terminal-server -if /i not %tsmethod%==KMS4k if defined winserver if defined _config if exist "%_oLPath%\Word2019VL_KMS_Client_AE*.xrm-ms" ( +if defined winserver if defined _config if exist "%_oLPath%\Word2019VL_KMS_Client_AE*.xrm-ms" ( echo %_oIds% | find /i "Retail" %nul1% && ( set scaIsNeeded=1 reg add %_config% /v SharedComputerLicensing /t REG_SZ /d "1" /f %nul1% @@ -2348,7 +1929,7 @@ for %%# in ("!_oLPath!\%_License%*.xrm-ms") do ( if defined _arr (set "_arr=!_arr!;"!_oLPath!\%%~nx#"") else (set "_arr="!_oLPath!\%%~nx#"") ) -%psc% "$sls = Get-WmiObject %sps%; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_oLPath!\pkeyconfig-office.xrm-ms"'" %nul% +%psc% "$sls = Get-WmiObject %sps%; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_oLPath!\pkeyconfig-office.xrm-ms"'" %nul% call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 echo "!allapps!" | find /i "!_actid!" %nul1% || ( @@ -2363,7 +1944,7 @@ exit /b :oh_clearblock :: Find remnants of Office vNext/shared/device license block and remove it because it stops other licenses from appearing -:: https://learn.microsoft.com/en-us/office/troubleshoot/activation/reset-office-365-proplus-activation-state +:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state set _sidlist= for /f "tokens=* delims=" %%a in ('%psc% "$p = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'; Get-ChildItem $p | ForEach-Object { $pi = (Get-ItemProperty """"$p\$($_.PSChildName)"""").ProfileImagePath; if ($pi -like '*\Users\*' -and (Test-Path """"$pi\NTUSER.DAT"""") -and -not ($_.PSChildName -match '\.bak$')) { Split-Path $_.PSPath -Leaf } }" %nul6%') do (if defined _sidlist (set _sidlist=!_sidlist! %%a) else (set _sidlist=%%a)) @@ -2415,12 +1996,10 @@ call :dk_color %Gray% "Checking Total User Accounts [%counter%]" :: Clear the vNext/shared/device license blocks which may prevent ohook activation -set vnextexist= rmdir /s /q "%ProgramData%\Microsoft\Office\Licenses\" %nul% for %%x in (15 16) do ( for %%# in (%_sidlist%) do ( -reg query HKU\%%#\Software\Microsoft\Office\%%x.0\Common\Licensing /s %nul2% | findstr /i "CIDToLicenseIdsMapping LicenseIdToEmailMapping @" %nul% && set vnextexist=1 reg delete HKU\%%#\Software\Microsoft\Office\%%x.0\Common\Licensing /f %nul% for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do ( @@ -2443,7 +2022,6 @@ rmdir /s /q "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\L if exist "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\SystemAppData\Helium\User.dat" ( set defname=DEFTEMP-%%# reg load HKU\!defname! "%%b\AppData\Local\Packages\Microsoft.Office.Desktop_8wekyb3d8bbwe\SystemAppData\Helium\User.dat" %nul% -reg query HKU\!defname!\Software\Microsoft\Office\16.0\Common\Licensing /s %nul2% | findstr /i "CIDToLicenseIdsMapping LicenseIdToEmailMapping @" %nul% && set vnextexist=1 reg delete HKU\!defname!\Software\Microsoft\Office\16.0\Common\Licensing /f %nul% reg unload HKU\!defname! %nul% ) @@ -2451,15 +2029,6 @@ reg unload HKU\!defname! %nul% ) ) -if defined vnextexist ( -echo: -call :dk_color %Gray% "The logged-in Office account has a subscription license." -call :dk_color %Blue% "If the subscription is active, it overrides other activation methods." -call :dk_color %Blue% "If it is expiring soon, rerun the activation script after it expires." -call :dk_color2 %Blue% "If it has already expired and activation fails, get help here - " %_Yellow% " %mas%troubleshoot" -echo: -) - :: Clear SharedComputerLicensing for office :: https://learn.microsoft.com/en-us/deployoffice/overview-shared-computer-activation @@ -2471,12 +2040,12 @@ reg delete HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration /v Share ) :: Clear device-based-licensing -:: https://learn.microsoft.com/en-us/deployoffice/device-based-licensing +:: https://learn.microsoft.com/deployoffice/device-based-licensing for /f %%# in ('reg query "%o16c2r_reg%\Configuration" /f *.DeviceBasedLicensing %nul6% ^| findstr REG_') do reg delete "%o16c2r_reg%\Configuration" /v %%# /f %nul% :: Remove OEM registry key -:: https://support.microsoft.com/en-us/office/office-repeatedly-prompts-you-to-activate-on-a-new-pc-a9a6b05f-f6ce-4d1f-8d49-eb5007b64ba1 +:: https://support.microsoft.com/office/office-repeatedly-prompts-you-to-activate-on-a-new-pc-a9a6b05f-f6ce-4d1f-8d49-eb5007b64ba1 for %%# in (15 16) do ( reg delete "HKLM\SOFTWARE\Microsoft\Office\%%#.0\Common\OEM" /f %nul% @@ -2554,15 +2123,7 @@ set upk_result=2 if defined ohookact if not %upk_result%==0 echo: if %upk_result%==1 echo Uninstalling Other/Grace Keys [Successful] -if %upk_result%==2 ( -call :dk_color %Red% "Uninstalling Other/Grace Keys [Failed]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -set showfix=1 -) -) +if %upk_result%==2 call :dk_color %Red% "Uninstalling Other/Grace Keys [Failed]" exit /b ::======================================================================================================================================== @@ -2573,66 +2134,13 @@ exit /b :oh_licrefresh if exist "%SysPath%\spp\store_test\2.0\tokens.dat" ( -%psc% "Stop-Service sppsvc -force; $sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if !errorlevel! NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($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% ) exit /b ::======================================================================================================================================== -:: Clean existing K-M-S cache from the registry - -:_taskclear-cache - -set w= -for %%# in (SppE%w%xtComObj.exe sppsvc.exe SLsvc.exe) do ( -reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul% -) - -set "OPPk=SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" - -if %winbuild% LSS 7600 ( -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL" %nul% && ( -set "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL" -) -) -if not defined SPPk ( -set "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" -) - -set "slp=SoftwareLicensingProduct" -set "ospp=OfficeSoftwareProtectionProduct" - -set "_wApp=55c92734-d682-4d71-983e-d6ec3f16059f" -set "_oApp=0ff1ce15-a989-479d-af46-f275c6370663" -set "_oA14=59a52881-a989-479d-af46-f275c6370663" - -%nul% reg delete "HKLM\%SPPk%" /f /v KeyManagementServiceName -%nul% reg delete "HKLM\%SPPk%" /f /v KeyManagementServiceName /reg:32 -%nul% reg delete "HKLM\%SPPk%" /f /v KeyManagementServicePort -%nul% reg delete "HKLM\%SPPk%" /f /v KeyManagementServicePort /reg:32 -%nul% reg delete "HKLM\%SPPk%" /f /v DisableDnsPublishing -%nul% reg delete "HKLM\%SPPk%" /f /v DisableKeyManagementServiceHostCaching -%nul% reg delete "HKLM\%SPPk%\%_wApp%" /f -if %winbuild% GEQ 9200 ( -%nul% reg delete "HKLM\%SPPk%\%_oApp%" /f -%nul% reg delete "HKLM\%SPPk%\%_oApp%" /f /reg:32 -) -if %winbuild% GEQ 9600 ( -%nul% reg delete "HKU\S-1-5-20\%SPPk%\%_wApp%" /f -%nul% reg delete "HKU\S-1-5-20\%SPPk%\%_oApp%" /f -) -%nul% reg delete "HKLM\%OPPk%" /f /v KeyManagementServiceName -%nul% reg delete "HKLM\%OPPk%" /f /v KeyManagementServicePort -%nul% reg delete "HKLM\%OPPk%" /f /v DisableDnsPublishing -%nul% reg delete "HKLM\%OPPk%" /f /v DisableKeyManagementServiceHostCaching -%nul% reg delete "HKLM\%OPPk%\%_oA14%" /f -%nul% reg delete "HKLM\%OPPk%\%_oApp%" /f - -exit /b - -::======================================================================================================================================== - :: Set variables :dk_setvar @@ -2640,7 +2148,7 @@ exit /b set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=%ps% -nop -c set winbuild=1 -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +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) @@ -2729,7 +2237,7 @@ for /f "tokens=3 delims=." %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Con if %_wmic% EQU 1 for /f "tokens=2 delims==" %%a in ('"wmic Path Win32_OperatingSystem Get OperatingSystemSKU /format:LIST" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" if %_wmic% EQU 0 for /f "tokens=1" %%a in ('%psc% "([WMI]'Win32_OperatingSystem=@').OperatingSystemSKU" %nul6%') do if not errorlevel 1 set "wmiSKU=%%a" -if %winbuild% GEQ 15063 %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';. ([scriptblock]::Create($f[1]))" %nul2% | find /i "Subscription_is_activated" %nul% && ( +if %winbuild% GEQ 15063 %psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';iex ($f[1])" %nul2% | find /i "Subscription_is_activated" %nul% && ( if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" ( set winsub=1 set osSKU=%regSKU% @@ -2791,11 +2299,9 @@ if %sps%==SoftwareLicensingService call :dk_refresh echo %keyecho% %~1 [Successful] ) else ( call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" -if not defined showfix ( +if not defined error ( if defined altapplist call :dk_color %Red% "Activation ID not found for this key." -echo: call :dk_color %Blue% "%_fixmsg%" -echo: set showfix=1 ) set error=1 @@ -2829,9 +2335,9 @@ if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISE if defined allapps if %1==0ff1ce15-a989-479d-af46-f275c6370663 ( set len=0 -echo:!allapps!> "!_ttemp!\chklen" -for %%A in ("!_ttemp!\chklen") do (set len=%%~zA) -del "!_ttemp!\chklen" %nul% +echo:!allapps!> %SystemRoot%\Temp\chklen +for %%A in (%SystemRoot%\Temp\chklen) do (set len=%%~zA) +del %SystemRoot%\Temp\chklen %nul% if !len! GTR 6000 ( %eline% @@ -2916,11 +2422,6 @@ set spperror=%errorlevel% if %spperror% NEQ 1056 if %spperror% NEQ 0 ( %eline% echo sc start %_slser% [Error Code: %spperror%] -if %spperror% EQU 1053 ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and try again." -call :dk_color %Blue% "If it still does not work, go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -) ) echo: @@ -2998,8 +2499,7 @@ if not exist %SysPath%\%_slexe% if not exist %SysPath%\alg.exe (set "results=%re if not "%results%%pupfound%"=="" ( if defined pupfound call :dk_color %Gray% "Checking PUP Activators [Found%pupfound%]" if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..." -if defined results (call :dk_color %Red% "%results%"&set showfix=1) -echo: +if defined results call :dk_color %Red% "%results%" set fixes=%fixes% %mas%remove_mal%w%ware call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" echo: @@ -3020,118 +2520,40 @@ exit /b set showfix= call :dk_chkmal -::============================== - :: Check Sandboxing sc query Null %nul% || ( -call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly]" -if not defined showfix ( -echo: +set error=1 +set showfix=1 +call :dk_color %Red% "Checking Sandboxing [Found, script may not work properly.]" call :dk_color %Blue% "If you are using any third-party antivirus, check if it is blocking the script." echo: ) -set error=1 -set showfix=1 -) -::============================== - -:: Check WinPE mode - -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( - -call :dk_color %Red% "Checking WinPE [Found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "WinPE mode found. Reboot the system and run in normal mode." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check Safe mode - -if defined safeboot_option ( -call :dk_color %Red% "Checking Boot Mode [%safeboot_option%]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Safe mode found. Reboot the system and run in normal mode." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check ImageState -:: https://learn.microsoft.com/en-us/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) - -if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" ( -call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]" -echo "%imagestate%" | find /i "RESEAL" %nul% && ( -if not defined showfix ( -echo: -call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode." -echo: -) -set error=1 -set showfix=1 -) -echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && ( -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -) -) - -::============================== +::======================================================================================================================================== :: Check corrupt services set serv_cor= for %%# in (%_serv%) do ( -set _regcorr= set _corrupt= sc start %%# %nul% if !errorlevel! EQU 1060 set _corrupt=1 sc query %%# %nul% || set _corrupt=1 -for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type) do if not defined _regcorr ( -reg query HKLM\SYSTEM\CurrentControlSet\Services\%%# /v %%G %nul% || (set _corrupt=1&set _regcorr=-RegistryError) +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 ) -if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#!_regcorr!") else (set "serv_cor=%%#!_regcorr!")) +if defined _corrupt (if defined serv_cor (set "serv_cor=!serv_cor! %%#") else (set "serv_cor=%%#")) ) if defined serv_cor ( -call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" - -if not defined showfix ( -echo: -if /i "%serv_cor%"=="sppsvc-RegistryError" ( -set fixes=%fixes% %mas%fix_service -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_service" -) else ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) -echo: -) - set error=1 set showfix=1 +call :dk_color %Red% "Checking Corrupt Services [%serv_cor%]" ) -::============================== +::======================================================================================================================================== :: Check disabled services @@ -3166,26 +2588,11 @@ if defined serv_cste (set "serv_cste=!serv_cste! %%#") else (set "serv_cste=%%#" if defined serv_csts call :dk_color %Gray% "Enabling Disabled Services [Successful] [%serv_csts%]" if defined serv_cste ( -call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" - -if not defined showfix ( -echo: -echo %serv_cste% | findstr /i "ClipSVC sppsvc" %nul% && ( -echo A registry fix has been applied to enable the disabled service. -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -) || ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) -echo: -) - set error=1 -set showfix=1 +call :dk_color %Red% "Enabling Disabled Services [Failed] [%serv_cste%]" ) -::============================== +::======================================================================================================================================== :: Check if the services are able to run or not :: Workarounds are added to get correct status and error code because sc query doesn't output correct results in some conditions @@ -3207,322 +2614,75 @@ if defined checkerror if defined serv_e (set "serv_e=!serv_e!, %%#-!errorcode!") ) if defined serv_e ( +set error=1 call :dk_color %Red% "Starting Services [Failed] [%serv_e%]" - -if not defined showfix ( -set listwospp=%_serv:sppsvc=% -echo %serv_e% | findstr /i "!listwospp!" %nul% && ( +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." set showfix=1 -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and run the script again." +) +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 +) +) + +::======================================================================================================================================== + +:: Various error checks + +if defined safeboot_option ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option%] " %Blue% "[Safe mode found. Run in normal mode.]" +) + + +:: 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) + +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 showfix=1 +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 service error is still not fixed, do this - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: +call :dk_color2 %Blue% "If the activation fails, do this - " %_Yellow% " %mas%in-place_repair_upgrade" ) ) -set error=1 -) -::============================== -:: Check WMI - -set wmifailed= -if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 %_wmic% EQU 1 wmic path %sps% get Version %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% -cmd /c exit /b %error_code% -if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" - -echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants - -if defined wmifailed ( -call :dk_color %Red% "Checking WMI [Not Working]" - -if not defined showfix ( -echo: -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." -echo: -) +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE" /v InstRoot %nul% && ( set error=1 set showfix=1 +call :dk_color2 %Red% "Checking WinPE " %Blue% "[WinPE mode found. Run in normal mode.]" ) -::============================== -:: Check SPP Registry Key - -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% || ( -call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found] [Most likely caused by gaming spoofers]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%issues_due_to_gaming_spoofers -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check TokenStore registry key - -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" -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" ( -call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set toerr=1 -set error=1 -set showfix=1 -) -) - -::============================== - -:: 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%\" ( - -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% 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)';" -set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" -set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" -set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" -%psc% "!d!" %nul% - -if exist "%tokenstore%\" ( -call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" -) else ( -call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set error=1 -set showfix=1 -) -) - -::============================== - -:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. - -set permerror= -if %winbuild% GEQ 9200 if not defined toerr if not defined ps32onArm if exist "%tokenstore%\" ( -for %%# in ( -"%tokenstore%+FullControl" -"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" -"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" -) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( -%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% -if !errorlevel!==2 ( -if "%%A"=="%tokenstore%" ( -set "permerror=Error Found In Token Folder" -) else ( -set "permerror=Error Found In SPP Registries" -) -) -) - -REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application - -if not defined permerror ( -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( -set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" -reg query "!pol!" %nul% || reg add "!pol!" %nul% -%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% -if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" -) -) - -if defined permerror ( -call :dk_color %Red% "Checking SPP Permissions [!permerror!]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -) -set error=1 -set showfix=1 -) -) - -::============================== - -:: Check WPA Registry Errors - -set chkalp= -set wpainfo=NotFound -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wpatest\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do (set wpainfo=%%a) -for /f "delims=0123456789" %%i in ("%wpainfo%") do set chkalp=%%i - -if defined chkalp ( -call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" -if not defined showfix ( +set wpainfo= +set wpaerror= +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1])" %nul6%') do (set wpainfo=%%a) echo "%wpainfo%" | find /i "Error Found" %nul% && ( -echo: -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -echo: set error=1 -set showfix=1 -) -) -set wpainfo=a -) - -if not defined chkalp ( -if %wpainfo% GEQ 5000 ( -call :dk_color %Gray% "Checking WPA Registry Count [%wpainfo%]" -echo: -call :dk_color %Blue% "A large number of WPA registries have been found, which may cause high CPU usage." -call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -echo: -) else ( +set wpaerror=1 +call :dk_color %Red% "Checking WPA Registry Errors [%wpainfo%]" +) || ( echo Checking WPA Registry Count [%wpainfo%] ) -) -::============================== - -:: Check Rearm - -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( -call :dk_color %Red% "Checking Rearm [System is Rearmed]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -echo: -) -set error=1 -set showfix=1 -) - - -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( -call :dk_color %Red% "Checking ClipSVC PersistedSystemState [Found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option to fix this error." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check SoftwareLicensingService - -if %error_code% NEQ 0 ( -call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] [%error_code%]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check Activation IDs - -call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f - -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=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if not defined _vis if !errorlevel! NEQ 0 set rlicfailed=1 -call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f -) - -if not defined apps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -if not defined apps if defined allapps if not defined notwinact ( -call :dk_color %Gray% "Checking Activation IDs [Key Not Installed or Act ID Not Found]" -) - -if not defined apps if not defined allapps ( -call :dk_color %Red% "Checking Activation IDs [Not found]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) -set error=1 -set showfix=1 -) - -if not defined showfix if defined rlicfailed ( -echo: -call :dk_color %Blue% "%_fixmsg%" -call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." -echo: -) - -if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( -call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]" -) - -::============================== - -:: Check Eval Windows if not defined notwinact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || ( -call :dk_color %Red% "Checking Eval Packages [License swapping found. Non-Eval licenses are installed in Eval Windows]" -if not defined showfix ( -echo: -call :dk_color %Blue% "License swapping is not the right way to upgrade to the full version. Learn the correct method at the link below." +call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]" set fixes=%fixes% %mas%evaluation_editions call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" -echo: -) -set error=1 -set showfix=1 ) ) -::============================== - -:: Check HKU\S-1-5-20\Software registry, in some systems it's missing and that causes Windows activation problems - -reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( -call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" -if not defined showfix ( -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -echo: -) -set error=1 -set showfix=1 -) - -::============================== - -:: Check license and package files for the current edition 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%')" @@ -3542,10 +2702,12 @@ if not defined notwinact ( if %osedition%==0 ( call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" ) 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" ( set skunotfound=1 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%Edition*.mum" ( call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" @@ -3554,9 +2716,31 @@ call :dk_color %Red% "Checking Package Files [Not Found] [%osed ) ) -::============================== -:: Check SKU value to find if there is any difference +if %_wmic% EQU 1 wmic path %sps% get Version %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% +cmd /c exit /b %error_code% +if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" +if %error_code% NEQ 0 ( +set error=1 +call :dk_color %Red% "Checking SoftwareLicensingService [Not Working] %error_code%" +) + + +set wmifailed= +if %_wmic% EQU 1 wmic path Win32_ComputerSystem get CreationClassName /value %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 +echo "%error_code%" | findstr /i "0x800410 0x800440 0x80131501" %nul1% && set wmifailed=1& :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants +if defined wmifailed ( +set error=1 +call :dk_color %Red% "Checking WMI [Not Working]" +if not defined showfix call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WMI option." +set showfix=1 +) + if not defined notwinact ( if %winbuild% GEQ 10240 ( @@ -3574,19 +2758,35 @@ call :dk_color %Gray% "Checking SLC/WMI SKU [Difference Found ) ) -::============================== +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedTSReArmed" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking Rearm " %Blue% "[System Restart Is Required]" +) + + +reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState" %nul% && ( +set error=1 +set showfix=1 +call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System Restart Is Required]" +) + :: 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. -sc query wlms %nul% - -if %errorlevel% NEQ 1060 ( +if exist "%SysPath%\wlms\wlms.exe" ( echo Checking Eval WLMS Service [Found] ) -::============================== -:: Check SPP interference in IFEO +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% || ( +set error=1 +set showfix=1 +call :dk_color %Red% "Checking HKU\S-1-5-20 Registry [Not Found]" +set fixes=%fixes% %mas%in-place_repair_upgrade +call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +) + for %%# in (SppEx%w%tComObj.exe SLsvc.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=%%#")) @@ -3594,56 +2794,156 @@ reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu if defined _sppint ( echo %_sppint% | find /i "PerfOptions" %nul% && ( call :dk_color %Red% "Checking SPP Interference In IFEO [%_sppint% - System might deactivate later]" -if not defined showfix ( -echo: -call :dk_color %Blue% "%_fixmsg%" -echo: -) +if not defined showfix call :dk_color %Blue% "%_fixmsg%" set showfix=1 ) || ( echo Checking SPP In IFEO [%_sppint%] ) ) -::============================== - -:: Check and fix SkipRearm registry value 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 ( reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul% -call :dk_color %Gray% "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" ) -::============================== -:: Check SvcRestartTask status, this task helps in making sure system remains activated +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% || ( +call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]" +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" +set error=1 +set showfix=1 +) + + +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" +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" ( +set toerr=1 +set error=1 +set showfix=1 +call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +) +) + +:: 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%\" ( +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% 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)';" +set "d=!d! $AclObject = New-Object System.Security.AccessControl.DirectorySecurity;" +set "d=!d! $AclObject.SetSecurityDescriptorSddlForm($sddl);" +set "d=!d! Set-Acl -Path %tokenstore% -AclObject $AclObject;" +%psc% "!d!" %nul% +if exist "%tokenstore%\" ( +call :dk_color %Gray% "Checking SPP Token Folder [Not Found, Created Now] [%tokenstore%\]" +) else ( +call :dk_color %Red% "Checking SPP Token Folder [Not Found, Failed to Create] [%tokenstore%\]" +set error=1 +set showfix=1 +) +) + + +if not defined notwinact ( +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +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% +call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined apps ( +set "_notfoundids=Key Not Installed / Act ID Not Found" +call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f +if not defined allapps ( +set error=1 +set "_notfoundids=Not found" +) +call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]" +) +) +) + + +if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( +set error=1 +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" ( %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% "$s=New-Object -ComObject 'Schedule.Service'; $s.Connect(); $state=$s.GetFolder('\Microsoft\Windows\SoftwareProtectionPlatform').GetTask('SvcRestartTask').State; @{0='Unknown';1='Disabled';2='Queued';3='Ready';4='Running'}[$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% || ( 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 if "!taskinfo!"=="" set "taskinfo=Not Found" +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." +) +) +) -call :dk_color %Gray% "Checking SvcRestartTask Status [!taskinfo!. System might deactivate later.]" + +:: This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers. + +set permerror= +if %winbuild% GEQ 9200 if not defined ps32onArm ( +for %%# in ( +"%tokenstore%+FullControl" +"HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey" +"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue" +) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( +%psc% "$acl = (Get-Acl '%%A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow %%B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2}" %nul% +if !errorlevel!==2 ( +if "%%A"=="%tokenstore%" ( +set "permerror=Error Found In Token Folder" +) else ( +set "permerror=Error Found In SPP Registries" +) +) +) + +REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application + +if not defined permerror ( +reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( +set "pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies" +reg query "!pol!" %nul% || reg add "!pol!" %nul% +%psc% "$netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3}" %nul% +if !errorlevel!==3 set "permerror=Error Found In S-1-5-20 SPP" +) +) + +if defined permerror ( +set error=1 +call :dk_color %Red% "Checking SPP Permissions [!permerror!]" +if not defined showfix call :dk_color %Blue% "%_fixmsg%" +set showfix=1 +) +) + + +:: If required services are not disabled or corrupted + if there is any error + SoftwareLicensingService errorlevel is not Zero + no fix was shown before + +if not defined serv_cor if not defined serv_cste if defined error if /i not %error_code%==0 if not defined showfix ( +if not defined permerror if defined wpaerror (call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." & set showfix=1) if not defined showfix ( -echo: -echo "!taskinfo!" | findstr /i "Removed Not Found" %nul1% && ( -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -) || ( -call :dk_color %Blue% "Reboot your machine using the restart option and run the script again." -) -echo: -) -) +set showfix=1 +call :dk_color %Blue% "%_fixmsg%" +if not defined permerror call :dk_color %Blue% "If activation still fails then run Fix WPA Registry option." ) ) -::============================== +if not defined showfix if defined wpaerror ( +set showfix=1 +call :dk_color %Blue% "If activation fails then go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." +) exit /b @@ -3735,7 +3035,7 @@ call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" choice /C:10 /N if !errorlevel!==2 exit /b -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -3752,221 +3052,7 @@ exit /b :tsforge: $src = @' -#if !POWERSHELL2 -namespace ActivationWs -{ - -/* - -This code is adapted from ActivationWs. -Original Repository: https://github.com/dadorner-msft/activationws - -MIT License - -Copyright (c) Daniel Dorner - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ - -using System; -using System.IO; -using System.Linq; -using System.Net; -using System.Security.Cryptography; -using System.Text; -using System.Xml.Linq; - - public static class ActivationHelper { - // Key for HMAC/SHA256 signature. - private static readonly byte[] MacKey = new byte[64] { - 254, 49, 152, 117, 251, 72, 132, 134, - 156, 243, 241, 206, 153, 168, 144, 100, - 171, 87, 31, 202, 71, 4, 80, 88, - 48, 36, 226, 20, 98, 135, 121, 160, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 - }; - - private const string Action = "http://www.microsoft.com/BatchActivationService/BatchActivate"; - - private static readonly Uri Uri = new Uri("https://activation.sls.microsoft.com/BatchActivation/BatchActivation.asmx"); - - private static readonly XNamespace SoapSchemaNs = "http://schemas.xmlsoap.org/soap/envelope/"; - private static readonly XNamespace XmlSchemaInstanceNs = "http://www.w3.org/2001/XMLSchema-instance"; - private static readonly XNamespace XmlSchemaNs = "http://www.w3.org/2001/XMLSchema"; - private static readonly XNamespace BatchActivationServiceNs = "http://www.microsoft.com/BatchActivationService"; - private static readonly XNamespace BatchActivationRequestNs = "http://www.microsoft.com/DRM/SL/BatchActivationRequest/1.0"; - private static readonly XNamespace BatchActivationResponseNs = "http://www.microsoft.com/DRM/SL/BatchActivationResponse/1.0"; - - public static string CallWebService(int requestType, string installationId, string extendedProductId) { - XDocument soapRequest = CreateSoapRequest(requestType, installationId, extendedProductId); - HttpWebRequest webRequest = CreateWebRequest(soapRequest); - XDocument soapResponse = new XDocument(); - - try { - IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null); - asyncResult.AsyncWaitHandle.WaitOne(); - - // Read data from the response stream. - using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult)) - using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream())) { - soapResponse = XDocument.Parse(streamReader.ReadToEnd()); - } - - return ParseSoapResponse(soapResponse); - - } catch { - throw; - } - } - - private static XDocument CreateSoapRequest(int requestType, string installationId, string extendedProductId) { - // Create an activation request. - XElement activationRequest = new XElement(BatchActivationRequestNs + "ActivationRequest", - new XElement(BatchActivationRequestNs + "VersionNumber", "2.0"), - new XElement(BatchActivationRequestNs + "RequestType", requestType), - new XElement(BatchActivationRequestNs + "Requests", - new XElement(BatchActivationRequestNs + "Request", - new XElement(BatchActivationRequestNs + "PID", extendedProductId), - requestType == 1 ? new XElement(BatchActivationRequestNs + "IID", installationId) : null) - ) - ); - - // Get the unicode byte array of activationRequest and convert it to Base64. - byte[] bytes = Encoding.Unicode.GetBytes(activationRequest.ToString()); - string requestXml = Convert.ToBase64String(bytes); - - XDocument soapRequest = new XDocument(); - - using (HMACSHA256 hMACSHA = new HMACSHA256(MacKey)) { - // Convert the HMAC hashed data to Base64. - string digest = Convert.ToBase64String(hMACSHA.ComputeHash(bytes)); - - soapRequest = new XDocument( - new XDeclaration("1.0", "UTF-8", "no"), - new XElement(SoapSchemaNs + "Envelope", - new XAttribute(XNamespace.Xmlns + "soap", SoapSchemaNs), - new XAttribute(XNamespace.Xmlns + "xsi", XmlSchemaInstanceNs), - new XAttribute(XNamespace.Xmlns + "xsd", XmlSchemaNs), - new XElement(SoapSchemaNs + "Body", - new XElement(BatchActivationServiceNs + "BatchActivate", - new XElement(BatchActivationServiceNs + "request", - new XElement(BatchActivationServiceNs + "Digest", digest), - new XElement(BatchActivationServiceNs + "RequestXml", requestXml) - ) - ) - ) - )); - - } - - return soapRequest; - } - - private static HttpWebRequest CreateWebRequest(XDocument soapRequest) { - HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(Uri); - webRequest.Accept = "text/xml"; - webRequest.ContentType = "text/xml; charset=\"utf-8\""; - webRequest.Headers.Add("SOAPAction", Action); - webRequest.Host = "activation.sls.microsoft.com"; - webRequest.Method = "POST"; - - try { - // Insert SOAP envelope - using (Stream stream = webRequest.GetRequestStream()) { - soapRequest.Save(stream); - } - - return webRequest; - - } catch { - throw; - } - } - - private static string ParseSoapResponse(XDocument soapResponse) { - if (soapResponse == null) { - throw new ArgumentNullException("soapResponse", "The remote server returned an unexpected response."); - } - - if (!soapResponse.Descendants(BatchActivationServiceNs + "ResponseXml").Any()) { - throw new Exception("The remote server returned an unexpected response"); - } - - try { - XDocument responseXml = XDocument.Parse(soapResponse.Descendants(BatchActivationServiceNs + "ResponseXml").First().Value); - - if (responseXml.Descendants(BatchActivationResponseNs + "ErrorCode").Any()) { - string errorCode = responseXml.Descendants(BatchActivationResponseNs + "ErrorCode").First().Value; - - switch (errorCode) { - case "0x7F": - throw new Exception("The Multiple Activation Key has exceeded its limit"); - - case "0x67": - throw new Exception("The product key has been blocked"); - - case "0x68": - throw new Exception("Invalid product key"); - - case "0x86": - throw new Exception("Invalid key type"); - - case "0x90": - throw new Exception("Please check the Installation ID and try again"); - - default: - throw new Exception(string.Format("The remote server reported an error ({0})", errorCode)); - } - - } else if (responseXml.Descendants(BatchActivationResponseNs + "ResponseType").Any()) { - string responseType = responseXml.Descendants(BatchActivationResponseNs + "ResponseType").First().Value; - - switch (responseType) { - case "1": - string confirmationId = responseXml.Descendants(BatchActivationResponseNs + "CID").First().Value; - return confirmationId; - - case "2": - string activationsRemaining = responseXml.Descendants(BatchActivationResponseNs + "ActivationRemaining").First().Value; - return activationsRemaining; - - default: - throw new Exception("The remote server returned an unrecognized response"); - } - - } else { - throw new Exception("The remote server returned an unrecognized response"); - } - - } catch { - throw; - } - } - } -} -#endif - -// LibTSforge/Common.cs +// Common.cs namespace LibTSforge { using System; @@ -4208,7 +3294,7 @@ namespace LibTSforge } -// LibTSforge/SPP/PKeyConfig.cs +// SPP/PKeyConfig.cs namespace LibTSforge.SPP { using System; @@ -4234,7 +3320,7 @@ namespace LibTSforge.SPP public bool Contains(int n) { - return Start <= n && n <= End; + return Start <= n && End <= n; } } @@ -4364,19 +3450,10 @@ namespace LibTSforge.SPP string refActIdStr = configNode.SelectSingleNode("./p:ActConfigId", nsmgr).InnerText; Guid refActId = new Guid(refActIdStr); int group = int.Parse(configNode.SelectSingleNode("./p:RefGroupId", nsmgr).InnerText); - List keyRanges; - ranges.TryGetValue(refActIdStr, out keyRanges); - - if (keyRanges == null) - { - continue; - } + List keyRanges = ranges[refActIdStr]; if (keyRanges.Count > 0 && !Products.ContainsKey(refActId)) { - PKeyAlgorithm algorithm; - algorithms.TryGetValue(group, out algorithm); - ProductConfig productConfig = new ProductConfig { GroupId = group, @@ -4384,7 +3461,7 @@ namespace LibTSforge.SPP Description = configNode.SelectSingleNode("./p:ProductDescription", nsmgr).InnerText, Channel = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText, Randomized = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText.ToLower() == "true", - Algorithm = algorithm, + Algorithm = algorithms[group], Ranges = keyRanges, ActivationId = refActId }; @@ -4434,7 +3511,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/ProductKey.cs +// SPP/ProductKey.cs namespace LibTSforge.SPP { using System; @@ -4750,7 +3827,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/SLAPI.cs +// SPP/SLAPI.cs namespace LibTSforge.SPP { using System; @@ -5163,7 +4240,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/SPPUtils.cs +// SPP/SPPUtils.cs namespace LibTSforge.SPP { using Microsoft.Win32; @@ -5500,7 +4577,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/SPSys.cs +// SPP/SPSys.cs namespace LibTSforge.SPP { using Microsoft.Win32.SafeHandles; @@ -5547,7 +4624,7 @@ namespace LibTSforge.SPP } -// LibTSforge/Crypto/CryptoUtils.cs +// Crypto/CryptoUtils.cs namespace LibTSforge.Crypto { using System; @@ -5682,7 +4759,7 @@ namespace LibTSforge.Crypto } -// LibTSforge/Crypto/Keys.cs +// Crypto/Keys.cs namespace LibTSforge.Crypto { public static class Keys @@ -5772,7 +4849,7 @@ namespace LibTSforge.Crypto } -// LibTSforge/Crypto/PhysStoreCrypto.cs +// Crypto/PhysStoreCrypto.cs namespace LibTSforge.Crypto { using System; @@ -5857,7 +4934,7 @@ namespace LibTSforge.Crypto } -// LibTSforge/Modifiers/GenPKeyInstall.cs +// Modifiers/GenPKeyInstall.cs namespace LibTSforge.Modifiers { using System; @@ -6068,7 +5145,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/GracePeriodReset.cs +// Modifiers/GracePeriodReset.cs namespace LibTSforge.Modifiers { using System.Collections.Generic; @@ -6101,7 +5178,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/KeyChangeLockDelete.cs +// Modifiers/KeyChangeLockDelete.cs namespace LibTSforge.Modifiers { using System.Collections.Generic; @@ -6141,7 +5218,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/KMSHostCharge.cs +// Modifiers/KMSHostCharge.cs namespace LibTSforge.Modifiers { using System; @@ -6302,7 +5379,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/RearmReset.cs +// Modifiers/RearmReset.cs namespace LibTSforge.Modifiers { using System.Collections.Generic; @@ -6358,7 +5435,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/SetIIDParams.cs +// Modifiers/SetIIDParams.cs namespace LibTSforge.Modifiers { using PhysicalStore; @@ -6427,7 +5504,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/TamperedFlagsDelete.cs +// Modifiers/TamperedFlagsDelete.cs namespace LibTSforge.Modifiers { using System.Linq; @@ -6477,7 +5554,7 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/UniqueIdDelete.cs +// Modifiers/UniqueIdDelete.cs namespace LibTSforge.Modifiers { using System; @@ -6536,23 +5613,27 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Activators/KMS4K.cs +// Activators/AVMA4K.cs namespace LibTSforge.Activators { using System; - using System.IO; using PhysicalStore; using SPP; - public class KMS4k + public static class AVMA4k { public static void Activate(PSVersion version, bool production, Guid actId) { + if (version != PSVersion.WinModern && version != PSVersion.WinBlue) + { + throw new NotSupportedException("AVMA licenses are not available for this product."); + } + Guid appId; if (actId == Guid.Empty) { appId = SLApi.WINDOWS_APP_ID; - actId = SLApi.GetDefaultActivationID(appId, true); + actId = SLApi.GetDefaultActivationID(appId, false); if (actId == Guid.Empty) { @@ -6564,9 +5645,9 @@ namespace LibTSforge.Activators appId = SLApi.GetAppId(actId); } - if (SLApi.GetPKeyChannel(SLApi.GetInstalledPkeyID(actId)) != "Volume:GVLK") + if (SLApi.GetPKeyChannel(SLApi.GetInstalledPkeyID(actId)) != "VT:IA") { - throw new NotSupportedException("Non-Volume:GVLK product key installed."); + throw new NotSupportedException("Non-VT:IA product key installed."); } SPPUtils.KillSPP(version); @@ -6577,177 +5658,86 @@ namespace LibTSforge.Activators { string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId); - ulong unknown = 0; - ulong time1; - ulong time2 = (ulong)DateTime.UtcNow.ToFileTime(); - ulong expiry = Constants.TimerMax; + long creationTime = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-CREATION-TIME$$").Data, 0); + long tickCount = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-TICKCOUNT-UPTIME$$").Data, 0); + long deltaTime = BitConverter.ToInt64(store.GetBlock(key, "__##USERSEP-RESERVED##__$$UP-TIME-DELTA$$").Data, 0); - if (version == PSVersion.Vista || version == PSVersion.Win7) + const ulong unknown = 0; + ulong time1 = (ulong)(creationTime + tickCount + deltaTime); + ulong crcBindTime = (ulong)DateTime.UtcNow.ToFileTime(); + ulong timerTime = crcBindTime / 10000; + ulong expiry = Constants.TimerMax / 10000; + + VariableBag avmaBinding = new VariableBag(version); + + avmaBinding.Blocks.AddRange(new[] { - unknown = 0x800000000; - time1 = 0; - } - else - { - long creationTime = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-CREATION-TIME$$").Data, 0); - long tickCount = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-TICKCOUNT-UPTIME$$").Data, 0); - long deltaTime = BitConverter.ToInt64(store.GetBlock(key, "__##USERSEP-RESERVED##__$$UP-TIME-DELTA$$").Data, 0); - - time1 = (ulong)(creationTime + tickCount + deltaTime); - time2 /= 10000; - expiry /= 10000; - } - - if (version == PSVersion.Vista) - { - VistaTimer vistaTimer = new VistaTimer - { - Time = time2, - Expiry = Constants.TimerMax - }; - - string vistaTimerName = string.Format("msft:sl/timer/VLExpiration/VOLUME/{0}/{1}", appId, actId); - - store.DeleteBlock(key, vistaTimerName); - store.DeleteBlock(key, actId.ToString()); - - BinaryWriter writer = new BinaryWriter(new MemoryStream()); - writer.Write(Constants.KMSv4Response.Length); - writer.Write(Constants.KMSv4Response); - writer.Write(Constants.UniversalHWIDBlock); - byte[] kmsData = writer.GetBytes(); - - store.AddBlocks(new[] - { - new PSBlock - { - Type = BlockType.TIMER, - Flags = 0, - KeyAsStr = key, - ValueAsStr = vistaTimerName, - Data = vistaTimer.CastToArray() - }, - new PSBlock - { - Type = BlockType.NAMED, - Flags = 0, - KeyAsStr = key, - ValueAsStr = actId.ToString(), - Data = kmsData - } - }); - } - else - { - byte[] hwidBlock = Constants.UniversalHWIDBlock; - byte[] kmsResp; - - switch (version) - { - case PSVersion.Win7: - kmsResp = Constants.KMSv4Response; - break; - case PSVersion.Win8: - kmsResp = Constants.KMSv5Response; - break; - case PSVersion.WinBlue: - case PSVersion.WinModern: - kmsResp = Constants.KMSv6Response; - break; - default: - throw new NotSupportedException("Unsupported PSVersion."); - } - - VariableBag kmsBinding = new VariableBag(version); - - kmsBinding.Blocks.AddRange(new[] - { new CRCBlockModern { DataType = CRCBlockType.BINARY, Key = new byte[] { }, - Value = kmsResp + Value = BitConverter.GetBytes(crcBindTime), }, new CRCBlockModern { DataType = CRCBlockType.STRING, Key = new byte[] { }, - ValueAsStr = "msft:rm/algorithm/hwid/4.0" + ValueAsStr = "AVMA4K", }, new CRCBlockModern { - DataType = CRCBlockType.BINARY, - KeyAsStr = "SppBindingLicenseData", - Value = hwidBlock + DataType = CRCBlockType.STRING, + Key = new byte[] { }, + ValueAsStr = "00491-50000-00001-AA666", } - }); + }); - if (version == PSVersion.WinModern) - { - kmsBinding.Blocks.AddRange(new[] - { - new CRCBlockModern - { - DataType = CRCBlockType.STRING, - Key = new byte[] { }, - ValueAsStr = "massgrave.dev" - }, - new CRCBlockModern - { - DataType = CRCBlockType.STRING, - Key = new byte[] { }, - ValueAsStr = "6969" - } - }); - } + byte[] avmaBindingData = avmaBinding.Serialize(); - byte[] kmsBindingData = kmsBinding.Serialize(); + Timer avmaTimer = new Timer + { + Unknown = unknown, + Time1 = time1, + Time2 = timerTime, + Expiry = expiry + }; - Timer kmsTimer = new Timer - { - Unknown = unknown, - Time1 = time1, - Time2 = time2, - Expiry = expiry - }; + string storeVal = string.Format("msft:spp/ia/bind/1.0/store/{0}/{1}", appId, actId); + string timerVal = string.Format("msft:spp/ia/bind/1.0/timer/{0}/{1}", appId, actId); - string storeVal = string.Format("msft:spp/kms/bind/2.0/store/{0}/{1}", appId, actId); - string timerVal = string.Format("msft:spp/kms/bind/2.0/timer/{0}/{1}", appId, actId); + store.DeleteBlock(key, storeVal); + store.DeleteBlock(key, timerVal); - store.DeleteBlock(key, storeVal); - store.DeleteBlock(key, timerVal); - - store.AddBlocks(new[] - { + store.AddBlocks(new[] + { new PSBlock { Type = BlockType.NAMED, - Flags = (version == PSVersion.WinModern) ? (uint)0x400 : 0, + Flags = 0x400, KeyAsStr = key, ValueAsStr = storeVal, - Data = kmsBindingData + Data = avmaBindingData, }, new PSBlock { Type = BlockType.TIMER, - Flags = (version == PSVersion.Win7) ? (uint)0 : 0x4, + Flags = 0x4, KeyAsStr = key, ValueAsStr = timerVal, - Data = kmsTimer.CastToArray() + Data = avmaTimer.CastToArray() } - }); - } + }); } - SPPUtils.RestartSPP(version); + SLApi.RefreshLicenseStatus(); SLApi.FireStateChangedEvent(appId); - Logger.WriteLine("Activated using KMS4k successfully."); + Logger.WriteLine("Activated using AVMA4k successfully."); } } } -// LibTSforge/Activators/ZeroCID.cs +// Activators/ZeroCID.cs namespace LibTSforge.Activators { using System; @@ -6936,7 +5926,7 @@ namespace LibTSforge.Activators } -// LibTSforge/TokenStore/Common.cs +// TokenStore/Common.cs namespace LibTSforge.TokenStore { using System.Collections.Generic; @@ -7006,7 +5996,7 @@ namespace LibTSforge.TokenStore } -// LibTSforge/TokenStore/ITokenStore.cs +// TokenStore/ITokenStore.cs namespace LibTSforge.TokenStore { using System; @@ -7026,7 +6016,7 @@ namespace LibTSforge.TokenStore } -// LibTSforge/TokenStore/TokenStoreModern.cs +// TokenStore/TokenStoreModern.cs namespace LibTSforge.TokenStore { using System; @@ -7312,7 +6302,7 @@ namespace LibTSforge.TokenStore } -// LibTSforge/PhysicalStore/Common.cs +// PhysicalStore/Common.cs namespace LibTSforge.PhysicalStore { using System.Runtime.InteropServices; @@ -7343,7 +6333,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/IPhysicalStore.cs +// PhysicalStore/IPhysicalStore.cs namespace LibTSforge.PhysicalStore { using System; @@ -7438,7 +6428,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/PhysicalStoreModern.cs +// PhysicalStore/PhysicalStoreModern.cs namespace LibTSforge.PhysicalStore { using System; @@ -7856,7 +6846,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/PhysicalStoreVista.cs +// PhysicalStore/PhysicalStoreVista.cs namespace LibTSforge.PhysicalStore { using System; @@ -8215,7 +7205,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/PhysicalStoreWin7.cs +// PhysicalStore/PhysicalStoreWin7.cs namespace LibTSforge.PhysicalStore { using System; @@ -8592,7 +7582,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/VariableBag.cs +// PhysicalStore/VariableBag.cs namespace LibTSforge.PhysicalStore { using System; @@ -8848,17 +7838,15 @@ namespace LibTSforge.PhysicalStore '@ $ErrorActionPreference = 'Stop' $binPath = "$env:_work\BIN\LibTSforge.dll" -$psMajorVer = (Get-Host).Version.Major -$build = [System.Environment]::OSVersion.Version.Build if (Test-Path -LiteralPath $binPath) { Write-Host "LibTSforge.dll found in BIN folder. Loading the DLL..." Add-Type -Path $binPath } else { - $cp = [CodeDom.Compiler.CompilerParameters] [string[]]@("System.dll", "System.Core.dll", "System.ServiceProcess.dll", "System.Xml.dll", "System.Xml.Linq.dll") - if ($psMajorVer -le 2) { $cp.CompilerOptions = "/define:POWERSHELL2 /unsafe" } else { $cp.CompilerOptions = "/unsafe" } - $lang = if ($psMajorVer -gt 2) { "CSharp" } else { "CSharpVersion3" } + $cp = [CodeDom.Compiler.CompilerParameters] [string[]]@("System.dll", "System.Core.dll", "System.ServiceProcess.dll", "System.Xml.dll") + $cp.CompilerOptions = "/unsafe" + $lang = If ((Get-Host).Version.Major -gt 2) { "CSharp" } Else { "CSharpVersion3" } $ctemp = "$env:SystemRoot\Temp\" if (-Not (Test-Path -Path $ctemp)) { New-Item -Path $ctemp -ItemType Directory > $null } @@ -8872,7 +7860,6 @@ else { if ($env:_debug -eq '0') { [LibTSforge.Logger]::HideOutput = $true } -[void][LibTSforge.Utils]::Wow64EnableWow64FsRedirection($false) $ver = [LibTSforge.Utils]::DetectVersion() $prod = [LibTSforge.SPP.SPPUtils]::DetectCurrentKey() $tsactids = @($args) @@ -8908,76 +7895,32 @@ function slGetSkuInfo($SkuId) { if (-not $env:resetstuff) { foreach ($tsactid in $tsactids) { try { - $activated = $null $prodDes = Get-WmiInfo -tsactid $tsactid -property "Description" $prodName = Get-WmiInfo -tsactid $tsactid -property "Name" if ($prodName) { $nameParts = $prodName -split ',', 2 $prodName = if ($nameParts.Count -gt 1) { ($nameParts[1].Trim() -split '[ ,]')[0] } else { $null } } - if (-not $env:_vis -and -not $env:oldks) { - [LibTSforge.Modifiers.GenPKeyInstall]::InstallGenPKey($ver, $prod, $tsactid) - } - if ($prodName -match 'Office' -and $prodDes -notmatch 'KMS' -and -not (slGetSkuInfo($tsactid))) { + if (-not $env:_vis) { + [LibTSforge.Modifiers.GenPKeyInstall]::InstallGenPKey($ver, $prod, $tsactid) + } + if ($prodName -match 'Office' -and -not (slGetSkuInfo($tsactid))) { $licenseStatus = Get-WmiInfo -tsactid $tsactid -property "LicenseStatus" if ($licenseStatus -eq 1) { Write-Host "[$prodName] is already permanently activated." -ForegroundColor White -BackgroundColor DarkGreen continue } } - if ($env:tsmethod -eq "StaticCID") { - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - $attempts = @( - @(100055, 1000043, 1338662172562478), - @(1345, 1003020, 6311608238084405) - ) - foreach ($params in $attempts) { - [LibTSforge.Modifiers.SetIIDParams]::SetParams($ver, $prod, $tsactid, [LibTSforge.SPP.PKeyAlgorithm]::PKEY2009, $params[0], $params[1], $params[2]) - $instId = [LibTSforge.SPP.SLApi]::GetInstallationID($tsactid) - $confId = [ActivationWs.ActivationHelper]::CallWebService(1, $instId, "31337-42069-123-456789-04-1337-2600.0000-2542001") - $result = [LibTSforge.SPP.SLApi]::DepositConfirmationID($tsactid, $instId, $confId) - if ($result -eq 0) { break } - } - [LibTSforge.SPP.SPPUtils]::RestartSPP($ver) - } - elseif ($env:tsmethod -eq "KMS4k") { - [LibTSforge.Activators.KMS4k]::Activate($ver, $prod, $tsactid) - } - else { - [LibTSforge.Activators.ZeroCID]::Activate($ver, $prod, $tsactid) - } - if ($env:tsmethod -eq "KMS4k") { - $GracePeriodStatus = Get-WmiInfo -tsactid $tsactid -property "GracePeriodRemaining" - if ($GracePeriodStatus -eq 259200 -or ([datetime]::Now.AddMinutes($GracePeriodStatus)).Year -gt 2038) { - if ((($build -ge 26100 -and $GracePeriodStatus -ge 259200) -or - ($build -lt 26100 -and $GracePeriodStatus -gt 259200))) { - $activated = 1 - } - } - } - else { - $licenseStatus = Get-WmiInfo -tsactid $tsactid -property "LicenseStatus" - if ($licenseStatus -eq 1) { $activated = 1 } - } - if ($activated) { + [LibTSforge.Activators.ZeroCID]::Activate($ver, $prod, $tsactid) + $licenseStatus = Get-WmiInfo -tsactid $tsactid -property "LicenseStatus" + if ($licenseStatus -eq 1) { if ($prodDes -match 'KMS' -and $prodDes -notmatch 'CLIENT') { [LibTSforge.Modifiers.KMSHostCharge]::Charge($ver, $prod, $tsactid) - Write-Host "[$prodName] CSVLK is permanently activated with $env:tsmethod." -ForegroundColor White -BackgroundColor DarkGreen + Write-Host "[$prodName] CSVLK is permanently activated with ZeroCID." -ForegroundColor White -BackgroundColor DarkGreen Write-Host "[$prodName] CSVLK is charged with 25 clients for 30 days." -ForegroundColor White -BackgroundColor DarkGreen } else { - if ($env:tsmethod -eq "KMS4k") { - if ($build -ge 26100) { - Write-Host "[$prodName] is activated with KMS4k for over 4,000 years." -ForegroundColor White -BackgroundColor DarkGreen - Write-Host "From build 26100.7019, Windows will always display and stay at 180 days remaining if the actual period is longer." -ForegroundColor White -BackgroundColor Darkgray - } - else { - Write-Host "[$prodName] is activated till $([DateTime]::Now.AddMinutes($GracePeriodStatus).ToString('yyyy-MM-dd HH:mm:ss')) with $env:tsmethod." -ForegroundColor White -BackgroundColor DarkGreen - } - } - else { - Write-Host "[$prodName] is permanently activated with $env:tsmethod." -ForegroundColor White -BackgroundColor DarkGreen - } + Write-Host "[$prodName] is permanently activated with ZeroCID." -ForegroundColor White -BackgroundColor DarkGreen } } else { @@ -8995,11 +7938,11 @@ if (-not $env:resetstuff) { if ($env:resetstuff) { try { - if (-not $env:_vis) { [LibTSforge.Modifiers.TamperedFlagsDelete]::DeleteTamperFlags($ver, $prod) } + if (-not $env:_vis) {[LibTSforge.Modifiers.TamperedFlagsDelete]::DeleteTamperFlags($ver, $prod)} [LibTSforge.SPP.SLApi]::RefreshLicenseStatus() [LibTSforge.Modifiers.RearmReset]::Reset($ver, $prod) [LibTSforge.Modifiers.GracePeriodReset]::Reset($ver, $prod) - if (-not $env:_vis) { [LibTSforge.Modifiers.KeyChangeLockDelete]::Delete($ver, $prod) } + if (-not $env:_vis) {[LibTSforge.Modifiers.KeyChangeLockDelete]::Delete($ver, $prod)} } catch { $errcode = 3 @@ -9244,7 +8187,7 @@ function Office-ActID { } } - $filterPreview = $filteredConfigs | Where-Object { $_.ProductDescription -notmatch 'preview|c2r' } + $filterPreview = $filteredConfigs | Where-Object { $_.ProductDescription -notmatch 'preview' } if ($filterPreview.Count -ne 0) { $filteredConfigs = $filterPreview @@ -9439,130 +8382,6 @@ exit /b ::======================================================================================================================================== -:: 1st column = Office version -:: 2nd column = Volume or free retail product -:: 3rd column = Retail product names that needs to be converted to the Volume product mentioned in 2nd column -:: Separator = "_" - -:tsksdata - -set f= -for %%# in ( -:: Office 2013 -15_AccessVolume_-AccessRetail- -15_AccessRuntimeRetail -15_ExcelVolume_-ExcelRetail- -15_GrooveVolume_-GrooveRetail- -15_InfoPathVolume_-InfoPathRetail- -15_LyncAcademicRetail -15_LyncEntryRetail -15_LyncVolume_-LyncRetail- -15_MondoRetail -15_MondoVolume_-O365BusinessRetail-O365HomePremRetail-O365ProPlusRetail-O365SmallBusPremRetail- -15_OneNoteFreeRetail -15_OneNoteVolume_-OneNoteRetail- -15_OutlookVolume_-OutlookRetail- -15_PowerPointVolume_-PowerPointRetail- -15_ProjectProVolume_-ProjectProRetail- -15_ProjectStdVolume_-ProjectStdRetail- -15_ProPlusVolume_-ProPlusRetail-ProfessionalPipcRetail-ProfessionalRetail- -15_PublisherVolume_-PublisherRetail- -15_SPDRetail -15_StandardVolume_-StandardRetail-HomeBusinessPipcRetail-HomeBusinessRetail-HomeStudentARMRetail-HomeStudentPlusARMRetail-HomeStudentRetail-PersonalPipcRetail-PersonalRetail- -15_VisioProVolume_-VisioProRetail- -15_VisioStdVolume_-VisioStdRetail- -15_WordVolume_-WordRetail- -:: Office 2016 -16_AccessRuntimeRetail -16_AccessVolume_-AccessRetail- -16_ExcelVolume_-ExcelRetail- -16_MondoRetail -16_MondoVolume_-O365AppsBasicRetail-O365BusinessRetail-O365EduCloudRetail-O365HomePremRetail-O365ProPlusRetail-O365SmallBusPremRetail- -16_OneNoteFreeRetail -16_OneNoteVolume_-OneNoteRetail-OneNote2021Retail- -16_OutlookVolume_-OutlookRetail- -16_PowerPointVolume_-PowerPointRetail- -16_ProjectProVolume_-ProjectProRetail- -16_ProjectProXVolume -16_ProjectStdVolume_-ProjectStdRetail- -16_ProjectStdXVolume -16_ProPlusVolume_-ProPlusRetail-ProfessionalPipcRetail-ProfessionalRetail- -16_PublisherVolume_-PublisherRetail- -16_SkypeServiceBypassRetail -16_SkypeforBusinessEntryRetail -16_SkypeforBusinessVolume_-SkypeforBusinessRetail- -16_StandardVolume_-StandardRetail-HomeBusinessPipcRetail-HomeBusinessRetail-HomeStudentARMRetail-HomeStudentPlusARMRetail-HomeStudentRetail-HomeStudentVNextRetail-PersonalPipcRetail-PersonalRetail- -16_VisioProVolume_-VisioProRetail- -16_VisioProXVolume -16_VisioStdVolume_-VisioStdRetail- -16_VisioStdXVolume -16_WordVolume_-WordRetail- -:: Office 2019 -16_AccessRuntime2019Retail -16_Access2019Volume_-Access2019Retail- -16_Excel2019Volume_-Excel2019Retail- -16_Outlook2019Volume_-Outlook2019Retail- -16_PowerPoint2019Volume_-PowerPoint2019Retail- -16_ProjectPro2019Volume_-ProjectPro2019Retail- -16_ProjectStd2019Volume_-ProjectStd2019Retail- -16_ProPlus2019Volume_-ProPlus2019Retail-Professional2019Retail- -16_Publisher2019Volume_-Publisher2019Retail- -16_SkypeforBusiness2019Volume_-SkypeforBusiness2019Retail- -16_SkypeforBusinessEntry2019Retail -16_Standard2019Volume_-Standard2019Retail-HomeBusiness2019Retail-HomeStudentARM2019Retail-HomeStudentPlusARM2019Retail-HomeStudent2019Retail-Personal2019Retail- -16_VisioPro2019Volume_-VisioPro2019Retail- -16_VisioStd2019Volume_-VisioStd2019Retail- -16_Word2019Volume_-Word2019Retail- -:: Office 2021 -:: OneNote2021Volume KMS license is not available -16_AccessRuntime2021Retail -16_Access2021Volume_-Access2021Retail- -16_Excel2021Volume_-Excel2021Retail- -16_Outlook2021Volume_-Outlook2021Retail- -16_OneNoteFree2021Retail -16_PowerPoint2021Volume_-PowerPoint2021Retail- -16_ProjectPro2021Volume_-ProjectPro2021Retail- -16_ProjectStd2021Volume_-ProjectStd2021Retail- -16_ProPlus2021Volume_-ProPlus2021Retail-Professional2021Retail- -16_Publisher2021Volume_-Publisher2021Retail- -16_SkypeforBusiness2021Volume_-SkypeforBusiness2021Retail- -16_Standard2021Volume_-Standard2021Retail-HomeBusiness2021Retail-HomeStudent2021Retail-Personal2021Retail- -16_VisioPro2021Volume_-VisioPro2021Retail- -16_VisioStd2021Volume_-VisioStd2021Retail- -16_Word2021Volume_-Word2021Retail- -:: Office 2024 -16_Access2024Volume_-Access2024Retail- -16_Excel2024Volume_-Excel2024Retail- -16_Outlook2024Volume_-Outlook2024Retail- -16_PowerPoint2024Volume_-PowerPoint2024Retail- -16_ProjectPro2024Volume_-ProjectPro2024Retail- -16_ProjectStd2024Volume_-ProjectStd2024Retail- -16_ProPlus2024Volume_-ProPlus2024Retail- -16_SkypeforBusiness2024Volume -16_Standard2024Volume_-Home2024Retail-HomeBusiness2024Retail- -16_VisioPro2024Volume_-VisioPro2024Retail- -16_VisioStd2024Volume_-VisioStd2024Retail- -16_Word2024Volume_-Word2024Retail- -) do ( -for /f "tokens=1-3 delims=_" %%A in ("%%#") do ( - -if %1==chkprod if "%oVer%"=="%%A" if not defined foundprod ( -if /i "%%B"=="%2" set foundprod=1 -) - -if %1==getinfo if "%oVer%"=="%%A" ( -echo: %%C | find /i "-%2-" %nul% && ( -set _License=%%B -set _altoffid=%%B -) -) - -) -) -exit /b - -::======================================================================================================================================== - :ts_getedition set tsedition= diff --git a/MAS/Separate-Files-Version/Activators/_ReadMe.txt b/MAS/Separate-Files-Version/Activators/_ReadMe.txt index 9832bc8..058a628 100644 --- a/MAS/Separate-Files-Version/Activators/_ReadMe.txt +++ b/MAS/Separate-Files-Version/Activators/_ReadMe.txt @@ -5,6 +5,7 @@ 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 -------------------------------------------------------------------------------------- diff --git a/MAS/Separate-Files-Version/Change_Office_Edition.cmd b/MAS/Separate-Files-Version/Change_Office_Edition.cmd index 9220148..6fd6571 100644 --- a/MAS/Separate-Files-Version/Change_Office_Edition.cmd +++ b/MAS/Separate-Files-Version/Change_Office_Edition.cmd @@ -1,11 +1,12 @@ -@set masver=3.9 +@set masver=3.2 @echo off ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -36,7 +37,6 @@ set "_cmdf=%~f0" for %%# in (%*) do ( if /i "%%#"=="re1" set re1=1 if /i "%%#"=="re2" set re2=1 -if /i "%%#"=="-qedit" (set re1=1&set re2=1) ) :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows @@ -60,8 +60,6 @@ exit /b set "blank=" set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" -set "github=ht%blank%tps%blank%://github.com/massgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" -set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/massg%blank%rave/Micr%blank%osoft-Act%blank%ivation-Scripts" :: Check if Null service is working, it's important for the batch script @@ -135,16 +133,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto dk_done ) -if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( -sc query gcs | find /i "RUNNING" %nul% && ( -%eline% -echo Windows Sandbox detected. -echo The script cannot run due to missing licensing components. Aborting... -echo: -goto dk_done -) -) - if %winbuild% LSS 7600 ( %eline% echo Unsupported OS version detected [%winbuild%]. @@ -200,18 +188,16 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) +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% -for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) -echo Test 1 - %tstresult% -echo Test 2 - !tstresult2! -echo: +echo: %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" REM check LanguageMode -echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +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: @@ -224,9 +210,6 @@ 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... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" goto dk_done ) @@ -241,33 +224,10 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_ goto dk_done ) -REM check if .NET is working properly - -if /i "!tstresult2!"=="FullLanguage" ( -cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% -if !errorlevel!==3 ( -echo Windows Powershell failed to load .NET command. Aborting... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -goto dk_done -) -) - REM check antivirus and other errors echo PowerShell is not working properly. Aborting... - -if /i "!tstresult2!"=="FullLanguage" ( -echo: -echo Your antivirus software might be blocking the script. -echo: -sc query sense | find /i "RUNNING" %nul% && ( -echo Installed Antivirus - Microsoft Defender for Endpoint -) -cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" -) - +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" @@ -288,9 +248,7 @@ set terminal= if defined terminal ( set lines=0 -for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( -for %%B in (%%A) do set lines=%%B -) +for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A if !lines! GEQ 100 set terminal= ) @@ -351,7 +309,7 @@ echo: call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" choice /C:10 /N if !errorlevel!==2 rem -if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) +if !errorlevel!==1 (start %mas% & exit /b) ) ) @@ -365,6 +323,15 @@ echo: echo Initializing... echo: +if not exist %SysPath%\sppsvc.exe ( +%eline% +echo [%SysPath%\sppsvc.exe] file is missing. Aborting... +echo: +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +goto dk_done +) + ::======================================================================================================================================== set spp=SoftwareLicensingProduct @@ -398,7 +365,8 @@ if %osedition%==0 ( %eline% echo Failed to detect OS Edition. Aborting... echo: -call :dk_color %Blue% "To fix this issue, activate Windows from the main menu." +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -447,7 +415,6 @@ _updch _lang _clversion _version -_AudienceData _oIds _c2rXml _c2rExe @@ -575,10 +542,9 @@ goto :oe_edition :oe_editionchangepre cls -set editedition= call :ch_getinfo call :oe_tempcleanup -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getlist\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getlist\:.*';iex ($f[1])" :oe_editionchange @@ -652,7 +618,7 @@ cls set suites= echo %list% | find /i "Suites" %nul1% && ( set suites=1 -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getappnames\:.*';. ([scriptblock]::Create($f[1]))" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getappnames\:.*';iex ($f[1])" if not exist %SystemRoot%\Temp\getAppIds.txt ( %eline% echo Failed to generate available apps list. @@ -694,8 +660,7 @@ if not defined terminal mode 98, 32 %line% echo: call :dk_color %Gray% "Target edition: %targetedition%" -call :dk_color %Gray% "To exclude the apps listed below from installation, toggle them from On to Off." -if defined editedition call :dk_color %Gray% "Note: The On/Off status below does not reflect the current status of the installed apps." +call :dk_color %Gray% "You can exclude the below apps from installation." %line% if defined suites echo: if defined Access_st echo [A] Access : %Access_st% @@ -822,9 +787,7 @@ goto :oe_goback :: 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 -call :oe_getlangs - -set "c2rcommand="%_c2rExe%" platform=%_oArch% culture=%_lang% productstoadd=%targetedition%.16_%_allLangs% 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 ( set "c2rcommand=!c2rcommand! productstoremove=AllProducts" @@ -839,40 +802,8 @@ set errorcode=%errorlevel% timeout /t 10 %nul% echo: -set suggestchannel= - if %errorcode% EQU 0 ( -if %change%==1 ( -echo %targetedition% | find /i "2019Volume" %nul% && ( -if not defined ltsc19 set suggestchannel=Production::LTSC -if /i not %_AudienceData%==Production::LTSC set suggestchannel=Production::LTSC -if /i not %_updch%==F2E724C1-748F-4B47-8FB8-8E0D210E9208 set suggestchannel=Production::LTSC -) - -echo %targetedition% | find /i "2021Volume" %nul% && ( -if not defined ltsc21 set suggestchannel=Production::LTSC2021 -if /i not %_AudienceData%==Production::LTSC2021 set suggestchannel=Production::LTSC2021 -if /i not %_updch%==5030841D-C919-4594-8D2D-84AE4F96E58E set suggestchannel=Production::LTSC2021 -) - -echo %targetedition% | find /i "2024Volume" %nul% && ( -if not defined ltsc24 set suggestchannel=Production::LTSC2024 -if /i not %_AudienceData%==Production::LTSC2024 set suggestchannel=Production::LTSC2024 -if /i not %_updch%==7983BAC0-E531-40CF-BE00-FD24FE66619C set suggestchannel=Production::LTSC2024 -) - -echo %targetedition% | findstr /R "20.*Volume" %nul% || ( -if defined ltscfound set suggestchannel=Production::CC -echo %_AudienceData% | find /i "LTSC" %nul% && set suggestchannel=Production::CC -) - -if defined suggestchannel ( -call :dk_color %Gray% "Mismatch found in update channel and installed product." -call :dk_color %Blue% "It is recommended to change the update channel to [!suggestchannel!] from the previous menu." -) -echo: -) -call :dk_color %Gray% "To activate Office, run the activation option from the main menu." +call :dk_color %Gray% "Now run the Office activation option from the main menu." ) else ( set fixes=%fixes% %mas%troubleshoot call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" @@ -896,7 +827,6 @@ goto :oe_goback ) set change=0 -set editedition=1 call :ch_getinfo cls @@ -1002,8 +932,13 @@ if %verified%==0 goto :oe_removeedition cls if not defined terminal mode 105, 32 -call :oe_getlangs %targetedition% -set "c2rcommand="%_c2rExe%" platform=%_oArch% productstoremove=%targetedition%.16_%_allLangs%" +set _lang= +echo "%o16c2r_reg%" | find /i "Wow6432Node" %nul1% && (set _tok=10) || (set _tok=9) +for /f "tokens=%_tok% delims=\" %%a in ('reg query "%o16c2r_reg%\ProductReleaseIDs\%_actconfig%\%targetedition%.16" /f "-" /k ^| findstr /i ".*16\\.*-.*"') do ( +if defined _lang (set "_lang=!_lang!_%%a") else (set "_lang=_%%a") +) + +set "c2rcommand="%_c2rExe%" platform=%_oArch% productstoremove=%targetedition%.16%_lang%" echo: echo Running the below command, please wait... @@ -1045,12 +980,6 @@ echo Installed Office editions: %_oIds% echo Unsupported Office edition is installed on your Windows build version %winbuild%. goto :oe_goback ) -if defined ltscfound ( -%eline% -echo Installed Office update channel: %ltsc19%%ltsc21%%ltsc24% -echo Unsupported Office update channel is installed on your Windows build version %winbuild%. -goto :oe_goback -) ) ::=============== @@ -1059,51 +988,49 @@ set inpt= set counter=0 set verified=0 set targetFFN= -set bypassFFN= set targetchannel= %line% echo: call :dk_color %Gray% "Installed update channel: %_AudienceData%, %_version%, Client: %_clversion%" -call :dk_color %Gray% "Installed Office editions: %_oIds%" +call :dk_color %Gray% "Unsupported update channels are excluded from this list." %line% echo: for %%# in ( -"5440fd1f-7ecb-4221-8110-145efaa6372f_Beta / Insider Fast - Insiders::DevMain -" -"64256afe-f5d9-4f86-8936-8840a6a4f5be_Current / Monthly Preview - Insiders::CC -" -"492350f6-3a01-4f97-b9c0-c7c6ddf67d60_Current / Monthly - Production::CC -" -"55336b82-a18d-4dd6-b5f6-9e5095c314a6_Monthly Enterprise - Production::MEC -" -"7ffbc6bf-bc32-4f92-8982-f9dd17fd3114_Semi Annual Enterprise - Production::DC -" -"ea4a4090-de26-49d7-93c1-91bff9e53fc3_DevMain Channel - Dogfood::DevMain -" -"b61285dd-d9f7-41f2-9757-8f61cba4e9c8_Microsoft Elite - Microsoft::DevMain -" -"f2e724c1-748f-4b47-8fb8-8e0d210e9208_Perpetual2019 VL - Production::LTSC -" -"1d2d2ea6-1680-4c56-ac58-a441c8c24ff9_Microsoft2019 VL - Microsoft::LTSC -" -"5030841d-c919-4594-8d2d-84ae4f96e58e_Perpetual2021 VL - Production::LTSC2021 -" -"86752282-5841-4120-ac80-db03ae6b5fdb_Microsoft2021 VL - Microsoft::LTSC2021 -" -"7983bac0-e531-40cf-be00-fd24fe66619c_Perpetual2024 VL - Production::LTSC2024 -" -"c02d8fe6-5242-4da8-972f-82ee55e00671_Microsoft2024 VL - Microsoft::LTSC2024 -" +"5440FD1F-7ECB-4221-8110-145EFAA6372F_Insider Fast [Beta] - Insiders::DevMain" +"64256AFE-F5D9-4F86-8936-8840A6A4F5BE_Monthly Preview - Insiders::CC" +"492350F6-3A01-4F97-B9C0-C7C6DDF67D60_Monthly [Current] - Production::CC" +"55336B82-A18D-4DD6-B5F6-9E5095C314A6_Monthly Enterprise - Production::MEC" +"B8F9B850-328D-4355-9145-C59439A0C4CF_Semi Annual Preview - Insiders::FRDC" +"7FFBC6BF-BC32-4F92-8982-F9DD17FD3114_Semi Annual - Production::DC" +"EA4A4090-DE26-49D7-93C1-91BFF9E53FC3_DevMain Channel - Dogfood::DevMain" +"B61285DD-D9F7-41F2-9757-8F61CBA4E9C8_Microsoft Elite - Microsoft::DevMain" +"F2E724C1-748F-4B47-8FB8-8E0D210E9208_Perpetual2019 VL - Production::LTSC" +"1D2D2EA6-1680-4C56-AC58-A441C8C24FF9_Microsoft2019 VL - Microsoft::LTSC" +"5030841D-C919-4594-8D2D-84AE4F96E58E_Perpetual2021 VL - Production::LTSC2021" +"86752282-5841-4120-AC80-DB03AE6B5FDB_Microsoft2021 VL - Microsoft::LTSC2021" +"7983BAC0-E531-40CF-BE00-FD24FE66619C_Perpetual2024 VL - Production::LTSC2024" +"C02D8FE6-5242-4DA8-972F-82EE55E00671_Microsoft2024 VL - Microsoft::LTSC2024" ) do ( for /f "tokens=1-2 delims=_" %%A in ("%%~#") do ( -set bypass= set supported= if %winbuild% LSS 10240 (echo %%B | findstr /i "LTSC DevMain" %nul% || set supported=1) else (set supported=1) if %winbuild% GEQ 10240 ( -if defined ltsc19 echo %%B | find /i "2019 VL" %nul% || set bypass=1 -if defined ltsc21 echo %%B | find /i "2021 VL" %nul% || set bypass=1 -if defined ltsc24 echo %%B | find /i "2024 VL" %nul% || set bypass=1 -if not defined ltscfound echo %%B | find /i "LTSC" %nul% && set bypass=1 +if defined ltsc19 echo %%B | find /i "2019 VL" %nul% || set supported= +if defined ltsc21 echo %%B | find /i "2021 VL" %nul% || set supported= +if defined ltsc24 echo %%B | find /i "2024 VL" %nul% || set supported= +if not defined ltscfound echo %%B | find /i "LTSC" %nul% && set supported= ) if defined supported ( set /a counter+=1 if !counter! LSS 10 ( -if defined bypass (echo [!counter!] %%B Unofficial change method will be used) else (echo [!counter!] %%B) +echo [!counter!] %%B ) else ( -if defined bypass (echo [!counter!] %%B Unofficial change method will be used) else (echo [!counter!] %%B) +echo [!counter!] %%B ) set targetFFN!counter!=%%A set targetchannel!counter!=%%B -if defined bypass set bypassFFN=!bypassFFN!%%A ) ) ) @@ -1117,7 +1044,7 @@ call :dk_color %_Green% "Enter an option number using your keyboard and press En set /p inpt= if "%inpt%"=="" goto :oe_changeupdchnl if "%inpt%"=="0" goto :oemenu -if /i "%inpt%"=="R" start https://learn.microsoft.com/en-us/microsoft-365-apps/updates/overview-update-channels & goto :oe_changeupdchnl +if /i "%inpt%"=="R" start https://learn.microsoft.com/microsoft-365-apps/updates/overview-update-channels & goto :oe_changeupdchnl for /l %%i in (1,1,%counter%) do (if "%inpt%"=="%%i" set verified=1) set targetFFN=!targetFFN%inpt%! set targetchannel=!targetchannel%inpt%! @@ -1131,148 +1058,18 @@ if not defined terminal mode 105, 32 :: Get build number for the target FFN, using build number with OfficeC2RClient.exe command to trigger updates provides accurate results set build= -for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getbuild\:.*';. ([scriptblock]::Create($f[1]))" %nul6%') do (set build=%%a) +for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getbuild\:.*';iex ($f[1])" %nul6%') do (set build=%%a) echo "%build%" | find /i "16." %nul% || set build= -echo: -for /f "tokens=1 delims=-" %%A in ("%targetchannel%") do (echo Target update channel: %%A) -echo Target build number: %build% -echo: %bypassFFN% | find /i "%targetFFN%" %nul% && goto :oe_changeunoff - -call :oe_cleanupreg - -if not defined build ( -if %winbuild% GEQ 9200 call :dk_color %Gray% "Failed to detect build number for the target FFN." -set "updcommand="%_c2rCexe%" /update user" -) else ( -set "updcommand="%_c2rCexe%" /update user updatetoversion=%build%" -) -echo Running the below command to trigger updates... -echo: -echo %updcommand% -%updcommand% -echo: -echo Check this webpage for help - %mas%troubleshoot -goto :oe_goback - -::======================= - -:: Unofficial method to change channel - -:oe_changeunoff - -set abortchange= -echo %targetchannel% | find /i "2019 VL" %nul% && (for %%A in (%_oIds%) do (echo %%A | find /i "2019Volume" %nul% || set abortchange=1)) -echo %targetchannel% | find /i "2021 VL" %nul% && (for %%A in (%_oIds%) do (echo %%A | find /i "2021Volume" %nul% || set abortchange=1)) -echo %targetchannel% | find /i "2024 VL" %nul% && (for %%A in (%_oIds%) do (echo %%A | find /i "2024Volume" %nul% || set abortchange=1)) - -if defined abortchange ( -%eline% -echo Mismatch found in installed Office products and target update channel. Aborting... -echo Non-perpetual Office products are not suppported with Perpetual VL update channels. -goto :oe_goback -) - -if not defined build ( -%eline% -call :dk_color %Red% "Failed to detect build number for the target FFN." -echo: -set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" -goto :oe_goback -) - -set buildchk=0 -for /f "tokens=3 delims=." %%a in ("%build%") do set "buildchk=%%a" - -call :oe_getlangs %_firstoId% - -echo %targetchannel% | find /i "2019 VL" %nul% && ( -for %%A in (en-gb es-mx fr-ca) do ( -echo %_allLangs% | find /i "%%A" %nul% && ( -%eline% -echo [%%A] language is not supported on the Office 2019 Perpetual VL update channel. Aborting... -goto :oe_goback -) -) -) - -set "c2rcommand="%_c2rExe%" platform=%_oArch% culture=%_lang% productstoadd=%_firstoId%.16_%_allLangs% cdnbaseurl.16=http://officecdn.microsoft.com/pr/%targetFFN% baseurl.16=http://officecdn.microsoft.com/pr/%targetFFN% version.16=%build% mediatype.16=CDN sourcetype.16=CDN deliverymechanism=%targetFFN% %_firstoId%.excludedapps.16=%_firstoIdExcludelist% flt.useteamsaddon=disabled flt.usebingaddononinstall=disabled flt.usebingaddononupdate=disabled" -set "c2rclientupdate=!c2rcommand! scenario=CLIENTUPDATE" - -if %clverchk% LSS %buildchk% ( -echo: -call :dk_color %Blue% "Do not terminate the operation before it completes..." -echo: -echo Updating Office C2R client with the command below, please wait... -echo: -echo %c2rclientupdate% -%c2rclientupdate% -for /l %%i in (1,1,30) do (if !clverchk! LSS %buildchk% (call :ch_getinfo&timeout /t 10 %nul%)) -) - -if %clverchk% LSS %buildchk% ( -echo: -call :dk_color %Red% "Failed to update Office C2R client. Aborting..." -echo: -set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" -goto :oe_goback -) - -call :oe_cleanupreg - -echo Running the below command to change update channel, please wait... -echo: -echo %c2rcommand% -%c2rcommand% -set errorcode=%errorlevel% -timeout /t 10 %nul% - -echo: -if %errorcode% EQU 0 ( -call :dk_color %Gray% "Now run the Office activation option from the main menu." -) else ( -set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" -) - -::======================================================================================================================================== - -:oe_goback - -call :oe_tempcleanup - -echo: -if defined fixes ( -call :dk_color %White% "Follow ALL the ABOVE blue lines. " -call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" -choice /C:10 /N -if !errorlevel!==2 goto :oemenu -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) -) - -if defined terminal ( -call :dk_color %_Yellow% "Press [0] key to go back..." -choice /c 0 /n -) else ( -call :dk_color %_Yellow% "Press any key to go back..." -pause %nul1% -) -goto :oemenu - -::======================================================================================================================================== - -:oe_cleanupreg - :: Cleanup Office update related registries, thanks to @abbodi1406 :: https://techcommunity.microsoft.com/t5/office-365-blog/how-to-manage-office-365-proplus-channels-for-it-pros/ba-p/795813 :: https://learn.microsoft.com/en-us/microsoft-365-apps/updates/change-update-channels#considerations-when-changing-channels +echo: +for /f "tokens=1 delims=-" %%A in ("%targetchannel%") do (echo Target update channel: %%A) echo: echo Cleaning Office update registry keys... echo Adding new update channel to registry keys... -echo: %nul% reg add %o16c2r_reg%\Configuration /v CDNBaseUrl /t REG_SZ /d "https://officecdn.microsoft.com/pr/%targetFFN%" /f %nul% reg add %o16c2r_reg%\Configuration /v UpdateChannel /t REG_SZ /d "https://officecdn.microsoft.com/pr/%targetFFN%" /f @@ -1289,7 +1086,43 @@ echo: %nul% reg delete HKLM\SOFTWARE\Policies\Microsoft\cloud\office\16.0\Common\officeupdate /f /reg:32 %nul% reg delete HKCU\Software\Policies\Microsoft\cloud\office\16.0\Common\officeupdate /f -exit /b +if not defined build ( +if %winbuild% GEQ 9200 call :dk_color %Gray% "Failed to detect build number for the target FFN." +set "updcommand="%_c2rCexe%" /update user" +) else ( +set "updcommand="%_c2rCexe%" /update user updatetoversion=%build%" +) +echo Running the below command to trigger updates... +echo: +echo %updcommand% +%updcommand% +echo: +echo Check this webpage for help - %mas%troubleshoot +goto :oe_goback + +::======================================================================================================================================== + +:oe_goback + +call :oe_tempcleanup + +echo: +if defined fixes ( +call :dk_color %White% "Follow ALL the ABOVE blue lines. " +call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" +choice /C:10 /N +if !errorlevel!==2 goto :oemenu +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) +) + +if defined terminal ( +call :dk_color %_Yellow% "Press [0] key to go back..." +choice /c 0 /n +) else ( +call :dk_color %_Yellow% "Press any key to go back..." +pause %nul1% +) +goto :oemenu ::======================================================================================================================================== @@ -1312,7 +1145,6 @@ set _oRoot= set _oArch= set _updch= set _oIds= -set _firstoId= set _lang= set _cfolder= set _version= @@ -1343,13 +1175,9 @@ for /f "tokens=%_tok% delims=\" %%a in ('reg query "%o16c2r_reg%\ProductReleaseI if defined _oIds (set "_oIds=!_oIds! %%a") else (set "_oIds=%%a") ) set _oIds=%_oIds:.16=% -for /f "tokens=1" %%A in ("%_oIds%") do set _firstoId=%%A -for /f "skip=2 tokens=2*" %%a in ('"reg query %o16c2r_reg%\Configuration /v %_firstoId%.ExcludedApps" %nul6%') do (set "_firstoIdExcludelist=%%b") set verchk=0 -set clverchk=0 for /f "tokens=3 delims=." %%a in ("%_version%") do set "verchk=%%a" -for /f "tokens=3 delims=." %%a in ("%_clversion%") do set "clverchk=%%a" if exist "%_oRoot%\Licenses16\c2rpridslicensefiles_auto.xml" set "_c2rXml=%_oRoot%\Licenses16\c2rpridslicensefiles_auto.xml" @@ -1365,13 +1193,16 @@ if exist "%_cfolder%\OfficeC2RClient.exe" ( set "_c2rCexe=%_cfolder%\OfficeC2RClient.exe" ) -:: Check LTSC version files +set "audidata4=%_AudienceData:~-4%" -for /f "skip=2 tokens=2*" %%a in ('"reg query %o16c2r_reg%\ProductReleaseIDs\%_actconfig%" /s %nul6%') do ( -echo "%%b" %nul2% | findstr "16.0.103 16.0.104 16.0.105" %nul% && set ltsc19=LTSC -echo "%%b" %nul2% | findstr "16.0.14332" %nul% && set ltsc21=LTSC2021 -echo "%%b" %nul2% | findstr "16.0.17932" %nul% && set ltsc24=LTSC2024 -) +if /i "%audidata4%"=="LTSC" 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 %_clversion% %_version% | findstr "16.0.14332" %nul% && set ltsc21=LTSC2021 + +if /i "%audidata4%"=="2024" set ltsc24=LTSC2024 +:: LTSC 2024 build is not fixed yet if not "%ltsc19%%ltsc21%%ltsc24%"=="" set ltscfound=1 @@ -1379,27 +1210,6 @@ exit /b ::======================================================================================================================================== -:: Check all the installed languages - -:oe_getlangs - -if "%1"=="" ( -set langreg=culture -) else ( -set langreg=%1.16 -) - -set _allLangs= -echo "%o16c2r_reg%" | find /i "Wow6432Node" %nul1% && (set _tok=10) || (set _tok=9) -for /f "tokens=%_tok% delims=\" %%a in ('reg query "%o16c2r_reg%\ProductReleaseIDs\%_actconfig%\%langreg%" /f "-" /k ^| findstr /i "%langreg%\\.*-.*"') do ( -if defined _allLangs (set "_allLangs=!_allLangs!_%%a") else (set "_allLangs=%%a") -) - -set _allLangs=%_allLangs:.16=% -exit /b - -::======================================================================================================================================== - :: Check Internet connection :oe_chkinternet @@ -1546,7 +1356,7 @@ if ($appIdsList.Count -gt 0) { set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=%ps% -nop -c set winbuild=1 -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +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) @@ -1616,11 +1426,6 @@ set spperror=%errorlevel% if %spperror% NEQ 1056 if %spperror% NEQ 0 ( %eline% echo sc start %_slser% [Error Code: %spperror%] -if %spperror% EQU 1053 ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and try again." -call :dk_color %Blue% "If it still does not work, go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -) ) echo: @@ -1672,7 +1477,7 @@ call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" choice /C:10 /N if !errorlevel!==2 exit /b -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( diff --git a/MAS/Separate-Files-Version/Change_Windows_Edition.cmd b/MAS/Separate-Files-Version/Change_Windows_Edition.cmd index 0844273..e0fa600 100644 --- a/MAS/Separate-Files-Version/Change_Windows_Edition.cmd +++ b/MAS/Separate-Files-Version/Change_Windows_Edition.cmd @@ -1,11 +1,12 @@ -@set masver=3.9 +@set masver=3.2 @echo off ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -41,7 +42,6 @@ set "_cmdf=%~f0" for %%# in (%*) do ( if /i "%%#"=="re1" set re1=1 if /i "%%#"=="re2" set re2=1 -if /i "%%#"=="-qedit" (set re1=1&set re2=1) ) :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows @@ -65,8 +65,6 @@ exit /b set "blank=" set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" -set "github=ht%blank%tps%blank%://github.com/massgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" -set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/massg%blank%rave/Micr%blank%osoft-Act%blank%ivation-Scripts" :: Check if Null service is working, it's important for the batch script @@ -140,16 +138,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto dk_done ) -if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( -sc query gcs | find /i "RUNNING" %nul% && ( -%eline% -echo Windows Sandbox detected. -echo The script cannot run due to missing licensing components. Aborting... -echo: -goto dk_done -) -) - if %winbuild% LSS 7600 ( %eline% echo Unsupported OS version detected [%winbuild%]. @@ -205,18 +193,16 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) +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% -for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) -echo Test 1 - %tstresult% -echo Test 2 - !tstresult2! -echo: +echo: %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" REM check LanguageMode -echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +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: @@ -229,9 +215,6 @@ 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... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" goto dk_done ) @@ -246,33 +229,10 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_ goto dk_done ) -REM check if .NET is working properly - -if /i "!tstresult2!"=="FullLanguage" ( -cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% -if !errorlevel!==3 ( -echo Windows Powershell failed to load .NET command. Aborting... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -goto dk_done -) -) - REM check antivirus and other errors echo PowerShell is not working properly. Aborting... - -if /i "!tstresult2!"=="FullLanguage" ( -echo: -echo Your antivirus software might be blocking the script. -echo: -sc query sense | find /i "RUNNING" %nul% && ( -echo Installed Antivirus - Microsoft Defender for Endpoint -) -cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" -) - +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" @@ -293,9 +253,7 @@ set terminal= if defined terminal ( set lines=0 -for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( -for %%B in (%%A) do set lines=%%B -) +for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A if !lines! GEQ 100 set terminal= ) @@ -356,7 +314,7 @@ echo: call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" choice /C:10 /N if !errorlevel!==2 rem -if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) +if !errorlevel!==1 (start %mas% & exit /b) ) ) @@ -399,8 +357,8 @@ 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%in-place_repair_upgrade -call :dk_color2 %Blue% "If it still shows the same error, do this - " %_Yellow% " %mas%in-place_repair_upgrade" +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) ) @@ -432,7 +390,8 @@ if not defined allapps ( %eline% echo Failed to find activation IDs. Aborting... echo: -call :dk_color %Blue% "To fix this issue, activate Windows from the main menu." +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -454,7 +413,8 @@ if not defined osedition ( %eline% echo Failed to detect OS edition, aborting... echo: -call :dk_color %Blue% "To fix this issue, activate Windows from the main menu." +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -477,7 +437,7 @@ set _ntarget= set _wtarget= if %winbuild% GEQ 10240 for /f "tokens=4" %%a in ('dism /online /english /Get-TargetEditions ^| findstr /i /c:"Target Edition : "') do (if defined _dtarget (set "_dtarget= !_dtarget! %%a ") else (set "_dtarget= %%a ")) -if %winbuild% LSS 10240 for /f "tokens=4" %%a in ('%psc% "$f=[System.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 17063 call :ced_edilist @@ -546,11 +506,7 @@ echo: for %%A in (%_ntarget%) do ( set /a counter+=1 -if /i %%A==IoTEnterprise ( -echo [!counter!] %%A [GAC, not LTSC] -) else ( echo [!counter!] %%A -) set targetedition!counter!=%%A ) @@ -603,7 +559,7 @@ set _dismapi=1 ) ) -set "keyflow=Retail OEM:NONSLP OEM:DM Volume:MAK Volume:GVLK PGS:TB Retail:TB:Eval" +set "keyflow=Retail Volume:GVLK Volume:MAK OEM:NONSLP OEM:DM PGS:TB Retail:TB:Eval" call :ced_targetSKU %targetedition% if defined targetSKU call :ced_windowskey @@ -687,7 +643,7 @@ echo: call :ced_prep if defined preperror goto dk_done -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':dismapi\:.*';. ([scriptblock]::Create($f[1])) %targetedition% %key%" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':dismapi\:.*';& ([ScriptBlock]::Create($f[1])) %targetedition% %key%" call :ced_postprep ) %line% @@ -725,7 +681,7 @@ call :ced_prep if defined preperror goto dk_done if %_stg%==0 (set stage=) else (set stage=-StageCurrent) -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':cbsxml\:.*';. ([scriptblock]::Create($f[1])) -SetEdition %targetedition% %stage%" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -SetEdition %targetedition% %stage%" call :ced_postprep %line% @@ -839,7 +795,7 @@ exit /b :: https://stackoverflow.com/a/46268232 -set "ddf="%SystemRoot%\Temp\%Random%%Random%%Random%%Random%"" +set "ddf="%SystemRoot%\Temp\ddf"" %nul% del /q /f %ddf% echo/.New Cabinet>%ddf% echo/.set Cabinet=ON>>%ddf% @@ -874,7 +830,7 @@ exit /b set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=%ps% -nop -c set winbuild=1 -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +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) @@ -971,11 +927,6 @@ set spperror=%errorlevel% if %spperror% NEQ 1056 if %spperror% NEQ 0 ( %eline% echo sc start %_slser% [Error Code: %spperror%] -if %spperror% EQU 1053 ( -echo: -call :dk_color %Blue% "Reboot your machine using the restart option and try again." -call :dk_color %Blue% "If it still does not work, go back to Main Menu, select Troubleshoot and run Fix WPA Registry option." -) ) echo: @@ -1107,7 +1058,7 @@ call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" choice /C:10 /N if !errorlevel!==2 exit /b -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -1396,55 +1347,55 @@ if %winbuild% GEQ 22000 exit /b ) if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*CorEdition~*.mum" (set Cor=Cor) else (set Cor=) -set w= +set h= for %%# in ( -XGVPP-NMH47-7TTHJ-W3FW7-8HV%w%2C__OEM:NONSLP_Enterprise -D6RD9-D4N8T-RT9QX-YW6YT-FCW%w%WJ______Retail_Starter -3V6Q6-NQXCX-V8YXR-9QCYV-QPF%w%CT__Volume:MAK_EnterpriseN -3NFXW-2T27M-2BDW6-4GHRV-68X%w%RX______Retail_StarterN -VK7JG-NPHTM-C97JM-9MPGT-3V6%w%6T______Retail_Professional -2B87N-8KFHP-DKV6R-Y2C8J-PKC%w%KT______Retail_ProfessionalN -4CPRK-NM3K3-X6XXQ-RXX86-WXC%w%HW______Retail_CoreN -N2434-X9D7W-8PF6X-8DV9T-8TY%w%MD______Retail_CoreCountrySpecific -BT79Q-G7N6G-PGBYW-4YWX6-6F4%w%BT______Retail_CoreSingleLanguage -YTMG3-N6DKC-DKB77-7M9GH-8HV%w%X7______Retail_Core -XKCNC-J26Q9-KFHD2-FKTHY-KD7%w%2Y__OEM:NONSLP_PPIPro -YNMGQ-8RYV3-4PGQ3-C8XTP-7CF%w%BY______Retail_Education -84NGF-MHBT6-FXBX8-QWJK7-DRR%w%8H______Retail_EducationN -KCNVH-YKWX8-GJJB9-H9FDT-6F7%w%W2__Volume:MAK_EnterpriseS_VB -43TBQ-NH92J-XKTM7-KT3KK-P39%w%PB__OEM:NONSLP_EnterpriseS_RS5 -NK96Y-D9CD8-W44CQ-R8YTK-DYJ%w%WX__OEM:NONSLP_EnterpriseS_RS1 -FWN7H-PF93Q-4GGP8-M8RF3-MDW%w%WW__OEM:NONSLP_EnterpriseS_TH -RQFNW-9TPM3-JQ73T-QV4VQ-DV9%w%PT__Volume:MAK_EnterpriseSN_VB -M33WV-NHY3C-R7FPM-BQGPT-239%w%PG__Volume:MAK_EnterpriseSN_RS5 -2DBW3-N2PJG-MVHW3-G7TDK-9HK%w%R4__Volume:MAK_EnterpriseSN_RS1 -NTX6B-BRYC2-K6786-F6MVQ-M7V%w%2X__Volume:MAK_EnterpriseSN_TH -G3KNM-CHG6T-R36X3-9QDG6-8M8%w%K9______Retail_ProfessionalSingleLanguage -HNGCC-Y38KG-QVK8D-WMWRK-X86%w%VK______Retail_ProfessionalCountrySpecific -DXG7C-N36C4-C4HTG-X4T3X-2YV%w%77______Retail_ProfessionalWorkstation -WYPNQ-8C467-V2W6J-TX4WX-WT2%w%RQ______Retail_ProfessionalWorkstationN -8PTT6-RNW4C-6V7J2-C2D3X-MHB%w%PB______Retail_ProfessionalEducation -GJTYN-HDMQY-FRR76-HVGC7-QPF%w%8P______Retail_ProfessionalEducationN -C4NTJ-CX6Q2-VXDMR-XVKGM-F9D%w%JC__Volume:MAK_EnterpriseG -46PN6-R9BK9-CVHKB-HWQ9V-MBJ%w%Y8__Volume:MAK_EnterpriseGN -NJCF7-PW8QT-3324D-688JX-2YV%w%66______Retail_ServerRdsh -XQQYW-NFFMW-XJPBH-K8732-CKF%w%FD______OEM:DM_IoTEnterprise -QPM6N-7J2WJ-P88HH-P3YRH-YY7%w%4H__OEM:NONSLP_IoTEnterpriseS -K9VKN-3BGWV-Y624W-MCRMQ-BHD%w%CD______Retail_CloudEditionN -KY7PN-VR6RX-83W6Y-6DDYQ-T6R%w%4W______Retail_CloudEdition -V3WVW-N2PV2-CGWC3-34QGF-VMJ%w%2C______Retail_Cloud -NH9J3-68WK7-6FB93-4K3DF-DJ4%w%F6______Retail_CloudN -2HN6V-HGTM8-6C97C-RK67V-JQP%w%FD______Retail_CloudE -WC2BQ-8NRM3-FDDYY-2BFGV-KHK%w%QY_Volume:GVLK_ServerStandard%Cor%_RS1 -CB7KF-BWN84-R7R2Y-793K2-8XD%w%DG_Volume:GVLK_ServerDatacenter%Cor%_RS1 -JCKRF-N37P4-C2D82-9YXRT-4M6%w%3B_Volume:GVLK_ServerSolution_RS1 -QN4C6-GBJD2-FB422-GHWJK-GJG%w%2R_Volume:GVLK_ServerCloudStorage_RS1 -VP34G-4NPPG-79JTQ-864T4-R3M%w%QX_Volume:GVLK_ServerAzureCor_RS1 -9JQNQ-V8HQ6-PKB8H-GGHRY-R62%w%H6______Retail_ServerAzureNano_RS1 -VN8D3-PR82H-DB6BJ-J9P4M-92F%w%6J______Retail_ServerStorageStandard_RS1 -48TQX-NVK3R-D8QR3-GTHHM-8FH%w%XC______Retail_ServerStorageWorkgroup_RS1 -2HXDN-KRXHB-GPYC7-YCKFJ-7FV%w%DG_Volume:GVLK_ServerDatacenterACor_RS3 -PTXN8-JFHJM-4WC78-MPCBR-9W4%w%KR_Volume:GVLK_ServerStandardACor_RS3 +XGVPP-NMH47-7TTHJ-W3FW7-8HV%h%2C__OEM:NONSLP_Enterprise +D6RD9-D4N8T-RT9QX-YW6YT-FCW%h%WJ______Retail_Starter +3V6Q6-NQXCX-V8YXR-9QCYV-QPF%h%CT__Volume:MAK_EnterpriseN +3NFXW-2T27M-2BDW6-4GHRV-68X%h%RX______Retail_StarterN +VK7JG-NPHTM-C97JM-9MPGT-3V6%h%6T______Retail_Professional +2B87N-8KFHP-DKV6R-Y2C8J-PKC%h%KT______Retail_ProfessionalN +4CPRK-NM3K3-X6XXQ-RXX86-WXC%h%HW______Retail_CoreN +N2434-X9D7W-8PF6X-8DV9T-8TY%h%MD______Retail_CoreCountrySpecific +BT79Q-G7N6G-PGBYW-4YWX6-6F4%h%BT______Retail_CoreSingleLanguage +YTMG3-N6DKC-DKB77-7M9GH-8HV%h%X7______Retail_Core +XKCNC-J26Q9-KFHD2-FKTHY-KD7%h%2Y__OEM:NONSLP_PPIPro +YNMGQ-8RYV3-4PGQ3-C8XTP-7CF%h%BY______Retail_Education +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 +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 +NTX6B-BRYC2-K6786-F6MVQ-M7V%h%2X__Volume:MAK_EnterpriseSN_TH +G3KNM-CHG6T-R36X3-9QDG6-8M8%h%K9______Retail_ProfessionalSingleLanguage +HNGCC-Y38KG-QVK8D-WMWRK-X86%h%VK______Retail_ProfessionalCountrySpecific +DXG7C-N36C4-C4HTG-X4T3X-2YV%h%77______Retail_ProfessionalWorkstation +WYPNQ-8C467-V2W6J-TX4WX-WT2%h%RQ______Retail_ProfessionalWorkstationN +8PTT6-RNW4C-6V7J2-C2D3X-MHB%h%PB______Retail_ProfessionalEducation +GJTYN-HDMQY-FRR76-HVGC7-QPF%h%8P______Retail_ProfessionalEducationN +C4NTJ-CX6Q2-VXDMR-XVKGM-F9D%h%JC__Volume:MAK_EnterpriseG +46PN6-R9BK9-CVHKB-HWQ9V-MBJ%h%Y8__Volume:MAK_EnterpriseGN +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 +NH9J3-68WK7-6FB93-4K3DF-DJ4%h%F6______Retail_CloudN +2HN6V-HGTM8-6C97C-RK67V-JQP%h%FD______Retail_CloudE +WC2BQ-8NRM3-FDDYY-2BFGV-KHK%h%QY_Volume:GVLK_ServerStandard%Cor%_RS1 +CB7KF-BWN84-R7R2Y-793K2-8XD%h%DG_Volume:GVLK_ServerDatacenter%Cor%_RS1 +JCKRF-N37P4-C2D82-9YXRT-4M6%h%3B_Volume:GVLK_ServerSolution_RS1 +QN4C6-GBJD2-FB422-GHWJK-GJG%h%2R_Volume:GVLK_ServerCloudStorage_RS1 +VP34G-4NPPG-79JTQ-864T4-R3M%h%QX_Volume:GVLK_ServerAzureCor_RS1 +9JQNQ-V8HQ6-PKB8H-GGHRY-R62%h%H6______Retail_ServerAzureNano_RS1 +VN8D3-PR82H-DB6BJ-J9P4M-92F%h%6J______Retail_ServerStorageStandard_RS1 +48TQX-NVK3R-D8QR3-GTHHM-8FH%h%XC______Retail_ServerStorageWorkgroup_RS1 +2HXDN-KRXHB-GPYC7-YCKFJ-7FV%h%DG_Volume:GVLK_ServerDatacenterACor_RS3 +PTXN8-JFHJM-4WC78-MPCBR-9W4%h%KR_Volume:GVLK_ServerStandardACor_RS3 ) do ( for /f "tokens=1-4 delims=_" %%A in ("%%#") do if /i %targetedition%==%%C ( diff --git a/MAS/Separate-Files-Version/Check_Activation_Status.cmd b/MAS/Separate-Files-Version/Check_Activation_Status.cmd index a7959ef..728b1a0 100644 --- a/MAS/Separate-Files-Version/Check_Activation_Status.cmd +++ b/MAS/Separate-Files-Version/Check_Activation_Status.cmd @@ -39,7 +39,7 @@ goto :E_Exit set "_batf=%~f0" set "_batp=%_batf:'=''%" setlocal EnableDelayedExpansion -%_psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':sppmgr\:.*';. ([scriptblock]::Create($f[1]))" +%_psc% "$f=[IO.File]::ReadAllText('!_batp!') -split ':sppmgr\:.*';iex ($f[1])" :E_Exit echo. @@ -518,7 +518,6 @@ function DetectSubscription { function DetectAdbaClient { $propADBA | foreach { set $_ (SlGetInfoSku $licID $_) } - DetectActType CONOUT "`nAD Activation client information:" CONOUT " Object Name: $ADActivationObjectName" CONOUT " Domain Name: $ADActivationObjectDN" @@ -609,18 +608,17 @@ function DetectKmsHost if ($null -NE $KeyManagementServiceNotificationRequests) {CONOUT " Notification: $KeyManagementServiceNotificationRequests"} } -function DetectActType -{ - $VLType = strGetRegistry ($SPKeyPath + '\' + $strApp + '\' + $licID) "VLActivationType" - if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp) "VLActivationType"} - if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath) "VLActivationType"} - if ($null -EQ $VLType -Or $VLType -GT 3) {$VLType = 0} - if ($null -NE $VLType) {CONOUT "Configured Activation Type: $($VLActTypes[$VLType])"} -} - function DetectKmsClient { - if ($win8) {DetectActType} + if ($win8) + { + $VLType = strGetRegistry ($SPKeyPath + '\' + $strApp + '\' + $licID) "VLActivationType" + if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp) "VLActivationType"} + if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath) "VLActivationType"} + if ($null -EQ $VLType -Or $VLType -GT 3) {$VLType = 0} + } + if ($null -NE $VLType) {CONOUT "Configured Activation Type: $($VLActTypes[$VLType])"} + CONOUT "`r" if ($LicenseStatus -NE 1) { CONOUT "Please activate the product in order to update KMS client information values." @@ -868,7 +866,6 @@ function GetResult($strSLP, $strApp, $entry) if ($win8 -And $VLActivationType -EQ 1) { DetectAdbaClient - $cKmsClient = $null } if ($winID -And $null -NE $cAvmClient) { diff --git a/MAS/Separate-Files-Version/Extract_OEM_Folder.cmd b/MAS/Separate-Files-Version/Extract_OEM_Folder.cmd index ddbe84e..a896e2b 100644 --- a/MAS/Separate-Files-Version/Extract_OEM_Folder.cmd +++ b/MAS/Separate-Files-Version/Extract_OEM_Folder.cmd @@ -1,11 +1,12 @@ -@set masver=3.9 +@set masver=3.2 @echo off ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -36,7 +37,6 @@ set "_cmdf=%~f0" for %%# in (%*) do ( if /i "%%#"=="re1" set re1=1 if /i "%%#"=="re2" set re2=1 -if /i "%%#"=="-qedit" (set re1=1&set re2=1) ) :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows @@ -60,8 +60,6 @@ exit /b set "blank=" set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" -set "github=ht%blank%tps%blank%://github.com/massgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" -set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/massg%blank%rave/Micr%blank%osoft-Act%blank%ivation-Scripts" :: Check if Null service is working, it's important for the batch script @@ -134,16 +132,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto done2 ) -if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( -sc query gcs | find /i "RUNNING" %nul% && ( -%eline% -echo Windows Sandbox detected. -echo The script cannot run due to missing licensing components. Aborting... -echo: -goto done2 -) -) - if %winbuild% LSS 6001 ( %nceline% echo Unsupported OS version detected [%winbuild%]. @@ -216,18 +204,16 @@ goto done2 ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) +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% -for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) -echo Test 1 - %tstresult% -echo Test 2 - !tstresult2! -echo: +echo: %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" REM check LanguageMode -echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +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: @@ -240,9 +226,6 @@ 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... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" goto done2 ) @@ -257,33 +240,10 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_ goto done2 ) -REM check if .NET is working properly - -if /i "!tstresult2!"=="FullLanguage" ( -cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% -if !errorlevel!==3 ( -echo Windows Powershell failed to load .NET command. Aborting... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -goto done2 -) -) - REM check antivirus and other errors echo PowerShell is not working properly. Aborting... - -if /i "!tstresult2!"=="FullLanguage" ( -echo: -echo Your antivirus software might be blocking the script. -echo: -sc query sense | find /i "RUNNING" %nul% && ( -echo Installed Antivirus - Microsoft Defender for Endpoint -) -cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" -) - +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" @@ -304,9 +264,7 @@ set terminal= if defined terminal ( set lines=0 -for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( -for %%B in (%%A) do set lines=%%B -) +for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A if !lines! GEQ 100 set terminal= ) @@ -367,7 +325,7 @@ echo: call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" choice /C:10 /N if !errorlevel!==2 rem -if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) +if !errorlevel!==1 (start %mas% & exit /b) ) ) @@ -405,6 +363,7 @@ goto done2 ) set HWID_Activation.cmd=Activators\HWID_Activation.cmd +set KMS38_Activation.cmd=Activators\KMS38_Activation.cmd set Online_KMS_Activation.cmd=Activators\Online_KMS_Activation.cmd set Ohook_Activation_AIO.cmd=Activators\Ohook_Activation_AIO.cmd set TSforge_Activation.cmd=Activators\TSforge_Activation.cmd @@ -413,6 +372,7 @@ pushd "!_work!" set _nofile= for %%# in ( %HWID_Activation.cmd% +%KMS38_Activation.cmd% %Online_KMS_Activation.cmd% %Ohook_Activation_AIO.cmd% %TSforge_Activation.cmd% @@ -443,29 +403,31 @@ echo: echo: Extract $OEM$ folder on the desktop echo: ____________________________________________________________ echo: -echo: [1] HWID [Windows] -echo: [2] Ohook [Office] -echo: [3] TSforge [Windows / ESU / Office] -echo: [4] Online KMS [Windows / Office] +echo: [1] HWID [Windows] +echo: [2] Ohook [Office] +echo: [3] TSforge [Windows / ESU / Office] +echo: [4] KMS38 [Windows] +echo: [5] Online KMS [Windows / Office] echo: -echo: [5] HWID [Windows] ^+ Ohook [Office] -echo: [6] HWID [Windows] ^+ Ohook [Office] ^+ TSforge [ESU] -echo: [7] TSforge [Windows / ESU] ^+ Ohook [Office] +echo: [6] HWID [Windows] ^+ Ohook [Office] +echo: [7] HWID [Windows] ^+ Ohook [Office] ^+ TSforge [ESU] +echo: [8] TSforge [Windows] ^+ Online KMS [Office] echo: call :dk_color2 %_White% " [R] " %_Green% "ReadMe" echo: [0] Exit echo: ____________________________________________________________ echo: call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard :" -choice /C:1234567R0 /N +choice /C:12345678R0 /N set _erl=%errorlevel% -if %_erl%==9 exit /b -if %_erl%==8 start %mas%oem-folder &goto :Menu -if %_erl%==7 goto:tsforge_ohook -if %_erl%==6 goto:hwid_ohook_tsforge -if %_erl%==5 goto:hwid_ohook -if %_erl%==4 goto:kms +if %_erl%==10 exit /b +if %_erl%==9 start %mas%oem-folder &goto :Menu +if %_erl%==8 goto:tsforge_kms +if %_erl%==7 goto:hwid_ohook_tsforge +if %_erl%==6 goto:hwid_ohook +if %_erl%==5 goto:kms +if %_erl%==4 goto:kms38 if %_erl%==3 goto:tsforge if %_erl%==2 goto:ohook if %_erl%==1 goto:hwid @@ -563,6 +525,36 @@ cd \ ::======================================================================================================================================== +:kms38 + +cls +md "!desktop!\$OEM$\$$\Setup\Scripts" +pushd "!_work!" +copy /y /b "%KMS38_Activation.cmd%" "!_dir!\KMS38_Activation.cmd" %nul% +popd +call :export kms38_setup + +set _error= +if not exist "!_dir!\KMS38_Activation.cmd" set _error=1 +if not exist "!_dir!\SetupComplete.cmd" set _error=1 +if defined _error goto errorfound + +set oem=KMS38 +goto done + +:kms38_setup: +@echo off + +fltmc >nul || exit /b + +call "%~dp0KMS38_Activation.cmd" /KMS38 + +cd \ +(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") +:kms38_setup: + +::======================================================================================================================================== + :kms cls @@ -675,41 +667,41 @@ cd \ ::======================================================================================================================================== -:tsforge_ohook +:tsforge_kms cls md "!desktop!\$OEM$\$$\Setup\Scripts" pushd "!_work!" copy /y /b "%TSforge_Activation.cmd%" "!_dir!\TSforge_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% popd -call :export tsforge_ohook_setup +call :export tsforge_kms_setup set _error= if not exist "!_dir!\TSforge_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!\SetupComplete.cmd" set _error=1 if defined _error goto errorfound -set oem=TSforge [Windows / ESU] + Ohook [Office] +set oem=TSforge [Windows] + Online KMS [Office] goto done -:tsforge_ohook_setup: +:tsforge_kms_setup: @echo off fltmc >nul || exit /b setlocal -call "%~dp0TSforge_Activation.cmd" /Z-Windows /Z-ESU +call "%~dp0TSforge_Activation.cmd" /Z-Windows endlocal setlocal -call "%~dp0Ohook_Activation_AIO.cmd" /Ohook +call "%~dp0Online_KMS_Activation.cmd" /K-Office endlocal cd \ (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") -:tsforge_ohook_setup: +:tsforge_kms_setup: ::======================================================================================================================================== @@ -725,6 +717,11 @@ echo ______________________________________________________________ echo: call :dk_color %Blue% "%oem%" call :dk_color %Green% "$OEM$ folder was successfully created on your Desktop." +echo "%oem%" | find /i "38" %nul% && ( +echo: +echo To KMS38 activate Server Cor/Acor editions [No GUI Versions], +echo Check this page %mas%oem-folder +) echo ______________________________________________________________ :done2 @@ -735,7 +732,7 @@ call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" choice /C:10 /N if !errorlevel!==2 exit /b -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -756,7 +753,7 @@ exit /b set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=%ps% -nop -c set winbuild=1 -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +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) @@ -809,7 +806,7 @@ exit /b :export -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('!_pdesk!\$OEM$\$$\Setup\Scripts\SetupComplete.cmd',$f[1].Trim(),[System.Text.Encoding]::ASCII);" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('!_pdesk!\$OEM$\$$\Setup\Scripts\SetupComplete.cmd',$f[1].Trim(),[System.Text.Encoding]::ASCII);" exit /b ::======================================================================================================================================== diff --git a/MAS/Separate-Files-Version/Troubleshoot.cmd b/MAS/Separate-Files-Version/Troubleshoot.cmd index 124220c..415ee1a 100644 --- a/MAS/Separate-Files-Version/Troubleshoot.cmd +++ b/MAS/Separate-Files-Version/Troubleshoot.cmd @@ -1,11 +1,12 @@ -@set masver=3.9 +@set masver=3.2 @echo off ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -36,7 +37,6 @@ set "_cmdf=%~f0" for %%# in (%*) do ( if /i "%%#"=="re1" set re1=1 if /i "%%#"=="re2" set re2=1 -if /i "%%#"=="-qedit" (set re1=1&set re2=1) ) :: Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows @@ -60,8 +60,6 @@ exit /b set "blank=" set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" -set "github=ht%blank%tps%blank%://github.com/massgra%blank%vel/Micro%blank%soft-Acti%blank%vation-Scripts" -set "selfgit=ht%blank%tps%blank%://git.acti%blank%vated.win/massg%blank%rave/Micr%blank%osoft-Act%blank%ivation-Scripts" :: Check if Null service is working, it's important for the batch script @@ -135,16 +133,6 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble goto dk_done ) -if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( -sc query gcs | find /i "RUNNING" %nul% && ( -%eline% -echo Windows Sandbox detected. -echo The script cannot run due to missing licensing components. Aborting... -echo: -goto dk_done -) -) - if %winbuild% LSS 6001 ( %nceline% echo Unsupported OS version detected [%winbuild%]. @@ -217,18 +205,16 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[System.IO.File]::ReadAllText('!_batp!') -split ':pstst';. ([scriptblock]::Create($f[1]))}" %nul6%') do (set tstresult=%%a) +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% -for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a) -echo Test 1 - %tstresult% -echo Test 2 - !tstresult2! -echo: +echo: %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" REM check LanguageMode -echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +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: @@ -241,9 +227,6 @@ 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... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" goto dk_done ) @@ -258,33 +241,10 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_ goto dk_done ) -REM check if .NET is working properly - -if /i "!tstresult2!"=="FullLanguage" ( -cmd /c "%psc% ""try {[System.AppDomain]::CurrentDomain.GetAssemblies(); [System.Math]::Sqrt(144)} catch {Exit 3}""" %nul% -if !errorlevel!==3 ( -echo Windows Powershell failed to load .NET command. Aborting... -echo: -set fixes=%fixes% %mas%in-place_repair_upgrade -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%in-place_repair_upgrade" -goto dk_done -) -) - REM check antivirus and other errors echo PowerShell is not working properly. Aborting... - -if /i "!tstresult2!"=="FullLanguage" ( -echo: -echo Your antivirus software might be blocking the script. -echo: -sc query sense | find /i "RUNNING" %nul% && ( -echo Installed Antivirus - Microsoft Defender for Endpoint -) -cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))}""" -) - +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" @@ -305,9 +265,7 @@ set terminal= if defined terminal ( set lines=0 -for /f "skip=3 tokens=* delims=" %%A in ('mode con') do if "!lines!"=="0" ( -for %%B in (%%A) do set lines=%%B -) +for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A if !lines! GEQ 100 set terminal= ) @@ -368,7 +326,7 @@ echo: call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" choice /C:10 /N if !errorlevel!==2 rem -if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b) +if !errorlevel!==1 (start %mas% & exit /b) ) ) @@ -429,7 +387,7 @@ if %_erl%==5 goto:retokens if %_erl%==4 goto:fixwmi if %_erl%==3 goto:sfcscan if %_erl%==2 goto:dism_rest -if %_erl%==1 (start %selfgit% & start %github% & start %mas%troubleshoot & goto at_menu) +if %_erl%==1 start %mas%troubleshoot.html &goto at_menu goto :at_menu ::======================================================================================================================================== @@ -618,7 +576,7 @@ call :dk_color %Blue% "Rebuilding ClipSVC Licenses..." echo: if %winbuild% LSS 10240 ( -echo ClipSVC license rebuilding is supported only on Windows 10/11. +echo ClipSVC license rebuilding is supported only on Windows 10/11 and their Server equivalents. echo Skipping... goto :rebuildspptok ) @@ -629,40 +587,6 @@ echo Skipping... goto :rebuildspptok ) -set _partial= -set _keymatch= -for /f "tokens=2 delims==" %%# in ('%psc% "(([WMISEARCHER]'SELECT PartialProductKey FROM SoftwareLicensingProduct WHERE ApplicationID=''55c92734-d682-4d71-983e-d6ec3f16059f'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).PartialProductKey | %% {echo ('PartialProductKey='+$_)}" %nul6%') do set "_partial=%%#" -for %%# in (8HV2C QPFCT 3V66T PKCKT WXCHW 8TYMD 6F4BT 8HVX7 KD72Y 7CFBY DRR8H P39PB DYJWX MDWWW 9HKR4 M7V2X 2YV77 WT2RQ MHBPB QPF8P 2YV66 VMJ2C DJ4F6 CKFFD YY74H J8JXD BHDCD T6R4W D32MH RRK69 3PJBP) do if /i "%_partial%"=="%%#" set _keymatch=1 - -if not defined _keymatch ( -echo HWID activation key is not installed. -echo Skipping... -goto :rebuildspptok -) - -%psc% "If([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet){Exit 0}Else{Exit 1}" -if errorlevel 1 ( -echo Internet is not connected. -echo Skipping... -goto :rebuildspptok -) - -set resfail= -for %%# in ( -licensing.mp.microsoft.com/v7.0/licenses/content -login.live.com/ppsecure/deviceaddcredential.srf -purchase.mp.microsoft.com/v7.0/users/me/orders -) do if not defined resfail ( -%psc% "try { [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; irm https://%%# -Method POST } catch { if ($_.Exception.Response -eq $null) { Write-Host """"[%%#] $($_.Exception.Message)"""" -ForegroundColor Red -BackgroundColor Black; exit 3 } }" -if !errorlevel!==3 set resfail=1 -) - -if defined resfail ( -echo Failed to connect to licensing servers. -echo Skipping... -goto :rebuildspptok -) - echo Stopping ClipSVC service... %psc% Stop-Service ClipSVC -force %nul% timeout /t 2 %nul% @@ -757,25 +681,6 @@ echo: call :dk_color %Blue% "Rebuilding SPP licensing tokens..." echo: -echo Clearing KMS Cache... -echo: -call :_taskclear-cache - -%nul% reg query "HKLM\%SPPk%\%_wApp%" && ( -echo Removing KMS38 protection... -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':regdel\:.*';. ([scriptblock]::Create($f[1]))" -%nul% reg delete "HKLM\%SPPk%\%_wApp%" /f -%nul% reg query "HKLM\%SPPk%\%_wApp%" && ( -call :dk_color %Red% "Failed to remove KMS38 protection." -) || ( -echo Successfully removed KMS38 protection. -echo Successfully cleared KMS Cache. -) -) || ( -echo Successfully cleared KMS Cache. -) -echo: - call :scandat check if not defined token ( @@ -801,7 +706,7 @@ echo Checking SPP permission related issues... call :checkperms if defined permerror ( call :dk_color %Red% "[!permerror!]" -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':fixsppperms\:.*';. ([scriptblock]::Create($f[1]))" %nul% +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':fixsppperms\:.*';iex ($f[1])" %nul% call :checkperms if defined permerror ( call :dk_color %Red% "[!permerror!] [Failed To Fix]" @@ -828,7 +733,7 @@ for %%# in (SppE%w%xtComObj.exe %_slexe%) do (reg delete "HKLM\SOFTWARE\Microsof if %winbuild% LSS 9200 if not defined _vis ( REM Fix issues caused by Update KB971033 in Windows 7 -REM https://support.microsoft.com/en-us/help/4487266 +REM https://support.microsoft.com/help/4487266 echo: echo Checking Update KB971033... %psc% "if (Get-Hotfix -Id KB971033 -ErrorAction SilentlyContinue) {Exit 3}" %nul% @@ -871,8 +776,8 @@ if defined _vis ( echo: echo Reinstalling system licenses... -%psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% -if %errorlevel% NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';. ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul% +%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 ( echo [Successful] ) else ( @@ -978,8 +883,8 @@ for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v P 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 %_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 %_86%\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (set "c2r16_86=Office 16.0 C2R x86" & call :getc2r16repair c2r16repair86 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 :getc2r16repair c2r16repair68 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" & call :getc2rrepair c2r16repair86 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) set uwp16= if %winbuild% GEQ 10240 ( @@ -1021,11 +926,13 @@ echo ________________________________________________________________ echo: ) -echo: if %counter% EQU 0 ( +echo: echo Office ^(2010 and later^) is not installed. goto :repairend -) else if not defined c2r16_68 if not defined c2r16_86 ( +echo: +) else ( +echo: call :dk_color %_Yellow% "A new window will appear, in that window you need to select [Quick Repair] option." if defined terminal ( call :dk_color %_Yellow% "Press [0] to continue..." @@ -1052,16 +959,16 @@ echo Skipping repair for Office 14.0 C2R... echo: ) -if defined msi14_68 if exist "%msi14repair68%" echo Running - "%msi14repair68%" & "%msi14repair68%" -if defined msi14_86 if exist "%msi14repair86%" echo Running - "%msi14repair86%" & "%msi14repair86%" -if defined msi15_68 if exist "%msi15repair68%" echo Running - "%msi15repair68%" & "%msi15repair68%" -if defined msi15_86 if exist "%msi15repair86%" echo Running - "%msi15repair86%" & "%msi15repair86%" -if defined msi16_68 if exist "%msi16repair68%" echo Running - "%msi16repair68%" & "%msi16repair68%" -if defined msi16_86 if exist "%msi16repair86%" echo Running - "%msi16repair86%" & "%msi16repair86%" -if defined c2r15_68 if exist "%c2r15repair68%" echo Running - "%c2r15repair68%" REPAIRUI RERUNMODE & "%c2r15repair68%" REPAIRUI RERUNMODE -if defined c2r15_86 if exist "%c2r15repair86%" echo Running - "%c2r15repair86%" REPAIRUI RERUNMODE & "%c2r15repair86%" REPAIRUI RERUNMODE -if defined c2r16_68 if exist "%c2r16repair68%" echo Running - "%c2r16repair68%" Scenario=Repair RepairType=QuickRepair & "%c2r16repair68%" Scenario=Repair RepairType=QuickRepair -if defined c2r16_86 if exist "%c2r16repair86%" echo Running - "%c2r16repair86%" Scenario=Repair RepairType=QuickRepair & "%c2r16repair86%" Scenario=Repair RepairType=QuickRepair +if defined msi14_68 if exist "%msi14repair68%" echo Running - "%msi14repair68%" & "%msi14repair68%" +if defined msi14_86 if exist "%msi14repair86%" echo Running - "%msi14repair86%" & "%msi14repair86%" +if defined msi15_68 if exist "%msi15repair68%" echo Running - "%msi15repair68%" & "%msi15repair68%" +if defined msi15_86 if exist "%msi15repair86%" echo Running - "%msi15repair86%" & "%msi15repair86%" +if defined msi16_68 if exist "%msi16repair68%" echo Running - "%msi16repair68%" & "%msi16repair68%" +if defined msi16_86 if exist "%msi16repair86%" echo Running - "%msi16repair86%" & "%msi16repair86%" +if defined c2r15_68 if exist "%c2r15repair68%" echo Running - "%c2r15repair68%" REPAIRUI RERUNMODE & "%c2r15repair68%" REPAIRUI RERUNMODE +if defined c2r15_86 if exist "%c2r15repair86%" echo Running - "%c2r15repair86%" REPAIRUI RERUNMODE & "%c2r15repair86%" REPAIRUI RERUNMODE +if defined c2r16_68 if exist "%c2r16repair68%" echo Running - "%c2r16repair68%" scenario=Repair & "%c2r16repair68%" scenario=Repair +if defined c2r16_86 if exist "%c2r16repair86%" echo Running - "%c2r16repair86%" scenario=Repair & "%c2r16repair86%" scenario=Repair :repairend @@ -1081,13 +988,6 @@ set "%1=%systemdrive%\Program Files\Microsoft Office 15\Client%%#\%2" ) exit /b -:getc2r16repair - -for %%# in (%_68% %_86%) do ( -for /f "skip=2 tokens=2*" %%a in ('"reg query %%#\ClickToRun\Configuration /v ClientFolder" %nul6%') do if exist "%%b\%2" (set "%1=%%b\%2") -) -exit /b - :getrepairsetup set "_common86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE%2\Office Setup Controller\setup.exe" @@ -1278,7 +1178,7 @@ goto :at_menu :: https://stackoverflow.com/a/46268232 -set "ddf="%SystemRoot%\Temp\%Random%%Random%%Random%%Random%"" +set "ddf="%SystemRoot%\Temp\ddf"" %nul% del /q /f %ddf% echo/.New Cabinet>%ddf% echo/.set Cabinet=ON>>%ddf% @@ -1330,7 +1230,7 @@ set "permerror=Error Found In SPP Registries" ) ) -REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application +REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application if not defined permerror ( reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( @@ -1344,59 +1244,6 @@ exit /b ::======================================================================================================================================== -:: Clean existing K-M-S cache from the registry - -:_taskclear-cache - -set w= -for %%# in (SppE%w%xtComObj.exe sppsvc.exe SLsvc.exe) do ( -reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul% -) - -set "OPPk=SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" - -if %winbuild% LSS 7600 ( -reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL" %nul% && ( -set "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL" -) -) -if not defined SPPk ( -set "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" -) - -set "slp=SoftwareLicensingProduct" -set "ospp=OfficeSoftwareProtectionProduct" - -set "_wApp=55c92734-d682-4d71-983e-d6ec3f16059f" -set "_oApp=0ff1ce15-a989-479d-af46-f275c6370663" -set "_oA14=59a52881-a989-479d-af46-f275c6370663" - -%nul% reg delete "HKLM\%SPPk%" /f /v KeyManagementServiceName -%nul% reg delete "HKLM\%SPPk%" /f /v KeyManagementServiceName /reg:32 -%nul% reg delete "HKLM\%SPPk%" /f /v KeyManagementServicePort -%nul% reg delete "HKLM\%SPPk%" /f /v KeyManagementServicePort /reg:32 -%nul% reg delete "HKLM\%SPPk%" /f /v DisableDnsPublishing -%nul% reg delete "HKLM\%SPPk%" /f /v DisableKeyManagementServiceHostCaching -%nul% reg delete "HKLM\%SPPk%\%_wApp%" /f -if %winbuild% GEQ 9200 ( -%nul% reg delete "HKLM\%SPPk%\%_oApp%" /f -%nul% reg delete "HKLM\%SPPk%\%_oApp%" /f /reg:32 -) -if %winbuild% GEQ 9600 ( -%nul% reg delete "HKU\S-1-5-20\%SPPk%\%_wApp%" /f -%nul% reg delete "HKU\S-1-5-20\%SPPk%\%_oApp%" /f -) -%nul% reg delete "HKLM\%OPPk%" /f /v KeyManagementServiceName -%nul% reg delete "HKLM\%OPPk%" /f /v KeyManagementServicePort -%nul% reg delete "HKLM\%OPPk%" /f /v DisableDnsPublishing -%nul% reg delete "HKLM\%OPPk%" /f /v DisableKeyManagementServiceHostCaching -%nul% reg delete "HKLM\%OPPk%\%_oA14%" /f -%nul% reg delete "HKLM\%OPPk%\%_oApp%" /f - -exit /b - -::======================================================================================================================================== - :: Fix SPP related registry and folder permissions :fixsppperms: @@ -1429,7 +1276,7 @@ if ($env:permerror -eq 'Error Found In SPP Registries') { } # Fix perms for SPP in HKU\S-1-5-20 -# https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application +# https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application if ($env:permerror -ne 'Error Found In S-1-5-20 SPP') { exit @@ -1576,7 +1423,7 @@ exit /b :regownstart -%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':regown\:.*';. ([scriptblock]::Create($f[1]));" +%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regown\:.*';iex ($f[1]);" exit /b :: Below code takes ownership of a volatile registry key and deletes it @@ -1608,36 +1455,6 @@ $key.SetAccessControl($acl) ::======================================================================================================================================== -:: This code runs to undo below registry key KMS38 protection -:: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f - -:: This option is not used in KMS38 anymore, it's here only to remove previous versions protection. - -:regdel: -param ( - [switch]$protect -) - -$SID = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544') -$Admin = ($SID.Translate([System.Security.Principal.NTAccount])).Value - -if($protect) { -$ruleArgs = @("$Admin", "Delete, SetValue", "ContainerInherit", "None", "Deny") -} else { -$ruleArgs = @("$Admin", "FullControl", "Allow") -} - -$path = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f' -$key = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64').OpenSubKey($path, 'ReadWriteSubTree', 'ChangePermissions') -$acl = $key.GetAccessControl() - -$rule = [System.Security.AccessControl.RegistryAccessRule]::new.Invoke($ruleArgs) -$acl.ResetAccessRule($rule) -$key.SetAccessControl($acl) -:regdel: - -::======================================================================================================================================== - :dk_color if %_NCS% EQU 1 ( @@ -1672,7 +1489,7 @@ call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" choice /C:10 /N if !errorlevel!==2 exit /b -if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -1694,7 +1511,7 @@ exit /b set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe set psc=%ps% -nop -c set winbuild=1 -for /f "tokens=2 delims=[]" %%G in ('ver') do for /f "tokens=2,3,4 delims=. " %%H in ("%%~G") do set "winbuild=%%J" +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) diff --git a/README.md b/README.md index 02115e2..61accf5 100644 --- a/README.md +++ b/README.md @@ -1,111 +1,118 @@ -

MAS Logo

- -

Microsoft Activation Scripts (MAS)

- -

Open-source Windows and Office activator featuring HWID, Ohook, TSforge, and Online KMS activation methods, along with advanced troubleshooting.

- -
- -## How to Activate Windows / Office / Extended Updates (ESU)? - -### Method 1 - PowerShell ❤️ - -1. **Open PowerShell** - Click the **Start Menu**, type `PowerShell`, then open it. - -2. **Copy and paste the code below, then press enter.** - - For **Windows 8, 10, 11**: 📌 - ``` - irm https://get.activated.win | iex - ``` - If the above is blocked (by ISP/DNS), try this (needs updated Windows 10 or 11): - ``` - iex (curl.exe -s --doh-url https://1.1.1.1/dns-query https://get.activated.win | Out-String) - ``` - - For **Windows 7** and later: - ``` - iex ((New-Object Net.WebClient).DownloadString('https://get.activated.win')) - ``` - - **Script not launching❓Use the below-listed Method 2.** - -3. The activation menu will appear. **Choose the green-highlighted options** to activate Windows or Office. - -4. **Done!** - ---- - -### Method 2 - Traditional (Windows Vista and later) - -1. Download the script: [**MAS_AIO.cmd**](https://dev.azure.com/massgrave/Microsoft-Activation-Scripts/_apis/git/repositories/Microsoft-Activation-Scripts/items?path=/MAS/All-In-One-Version-KL/MAS_AIO.cmd&download=true) or the [full ZIP](https://dev.azure.com/massgrave/Microsoft-Activation-Scripts/_apis/git/repositories/Microsoft-Activation-Scripts/items?$format=zip). -2. Run the file named `MAS_AIO.cmd`. -3. You will see the activation options. Follow the on-screen instructions. -4. That's all. - ---- - -> [!TIP] -> - Some ISPs/DNS block access to our domains. You can bypass this by enabling [DNS-over-HTTPS (DoH)](https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/encrypted-dns-browsers/) in your browser. -> - **Having trouble**❓Visit our [troubleshooting page](https://massgrave.dev/troubleshoot) or raise an issue on [GitHub](https://github.com/massgravel/Microsoft-Activation-Scripts/issues). - ---- - -- To activate additional products such as **Office for macOS, Visual Studio, RDS CALs, and Windows XP**, check [here](https://massgrave.dev/unsupported_products_activation). -- To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches). - ---- - -> [!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.9 -Release date: 19-Nov-2025 -``` - -### [Troubleshooting / Help](https://massgrave.dev/troubleshoot) -### [Download Original Windows & Office](https://massgrave.dev/genuine-installation-media) -### Homepage - [https://massgrave.dev/](https://massgrave.dev/) - -
- -[![1.1]][1] -[![1.2]][2] -[![1.3]][3] - -
- -
- -[![1.4]][4] -[![1.5]][5] -[![1.6]][6] -[![1.7]][7] - -
- -[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/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 - ---- - -

Made with Love ❤️

- +

MAS Logo

+ +

Microsoft Activation Scripts (MAS)

+ +

Open-source Windows and Office activator featuring HWID, Ohook, TSforge, KMS38, and Online KMS activation methods, along with advanced troubleshooting.

+ +
+ +## How to Activate Windows / Office? + +### Method 1 - PowerShell (Windows 8 and later) ❤️ + +1. **Open PowerShell** + To do that, press the Windows key + X, then select PowerShell or Terminal. + +2. **Copy and paste the code below, then press enter.** +``` +irm https://get.activated.win | iex +``` +Alternatively, you can use the following (this will be deprecated in the future): +``` +irm https://massgrave.dev/get | iex +``` + +3. You will see the activation options. + Press 1 HWID for Windows activation. + Press 2 Ohook for Office activation. + +4. That's all + +--- + +### Method 2 - Traditional (Windows Vista and later) + +
+ Click here to view + +1. Download the file using one of the links below: +`https://github.com/massgravel/Microsoft-Activation-Scripts/archive/refs/heads/master.zip` +or +`https://git.activated.win/massgrave/Microsoft-Activation-Scripts/archive/master.zip` +2. Right-click on the downloaded zip file and extract it. +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. + +
+ +--- + +- **[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 +Release date: 6-May-2025 +``` + +### [Troubleshooting / Help](https://massgrave.dev/troubleshoot) +### [Download Original Windows & Office](https://massgrave.dev/genuine-installation-media) +### Homepage - [https://massgrave.dev/](https://massgrave.dev/) + +
+ +[![1.1]][1] +[![1.2]][2] +[![1.3]][3] + +
+ +
+ +[![1.4]][4] +[![1.5]][5] +[![1.6]][6] +[![1.7]][7] + +
+ +[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 + +--- + +

Made with Love ❤️