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..dfb8b2f 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 +@::u78r-random +@set masver=3.0 @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 @@ -78,7 +76,7 @@ echo: echo Null service is not running, script may crash... echo: echo: -echo Check this webpage for help - %mas%fix_service +echo Help - %mas%fix_service echo: echo: ping 127.0.0.1 -n 20 @@ -93,7 +91,7 @@ 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 Help - %mas%troubleshoot echo: echo: ping 127.0.0.1 -n 20 >nul @@ -139,41 +137,14 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" 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 ( +if %winbuild% LSS 7600 ( %nceline% echo Unsupported OS version detected [%winbuild%]. -echo MAS only supports Windows Vista/7/8/8.1/10/11 and their Server equivalents. -if %winbuild% EQU 6000 ( -echo: -echo Windows Vista RTM is not supported because Powershell cannot be installed. -echo Upgrade to Windows Vista SP1 or SP2. -) -goto dk_done -) - -if %winbuild% LSS 7600 if not exist "%SysPath%\WindowsPowerShell\v1.0\Modules" ( -%nceline% -if not exist %ps% ( -echo PowerShell is not installed in your system. -) -echo Install PowerShell 2.0 using the following URL. -echo: -echo https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 -if %_unattended%==0 start https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 +echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. goto dk_done ) @@ -209,6 +180,33 @@ goto dk_done ::======================================================================================================================================== +:: Check PowerShell + +REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +echo: +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% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto dk_done +) + +::======================================================================================================================================== + :: Elevate script as admin and pass arguments and preventing loop %nul1% fltmc || ( @@ -221,86 +219,6 @@ goto dk_done ::======================================================================================================================================== -:: Check PowerShell - -::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) - -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: - -REM check LanguageMode - -echo: !tstresult2! | 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... -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 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 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 ', '))}""" -) - -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 ( @@ -311,35 +229,34 @@ set terminal= :: Check if script is running in Terminal app +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + if defined terminal ( -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 -) -if !lines! GEQ 100 set terminal= +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= ) +if defined ps32onArm goto :skipQE 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 +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" ) +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) :skipQE ::======================================================================================================================================== @@ -348,18 +265,12 @@ exit /b 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= -) +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 activ%-%ated.win') do ( +if not "%%#"=="" set old=1 +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck%upver%.activ%-%ated.win') do ( +if not "%%#"=="" set old= ) ) @@ -376,7 +287,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 +301,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 +336,15 @@ 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 +if %winbuild% GEQ 9200 set _ohookgo=1 +if %winbuild% LSS 9200 set _okmsgo=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 +365,38 @@ 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 +if defined _okmsgo ( +call :dk_color3 %_White% " [5] " %_Green% "Online KMS" %_White% " - Windows / Office" +) else ( +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 +472,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 +511,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 +534,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%..." @@ -714,13 +620,8 @@ if not exist %SysPath%\%%# ( %eline% echo [%SysPath%\%%#] 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%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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) ) @@ -766,7 +667,7 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" goto dk_done ) ) @@ -828,7 +729,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 ) @@ -853,7 +754,7 @@ echo %mas% ) else ( echo 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) echo: goto dk_done @@ -876,7 +777,6 @@ call :dk_color %Blue% "Windows Subscription [SKU ID-%slcSKU%] detected. Script w echo: ) -set generickey=1 call :dk_inskey "[%key%]" ::======================================================================================================================================== @@ -886,15 +786,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 +862,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 +932,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: +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%licensing-servers-issue" ) ::========================================================================================================================================== @@ -1053,17 +946,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 +969,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: +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware" ) 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 +981,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 +994,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: +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%licensing-servers-issue" ) ) ) @@ -1132,7 +1013,7 @@ call :dk_color %Blue% "Use TSforge activation option from the main menu instead. ) else ( 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) ) @@ -1166,15 +1047,9 @@ goto :dk_done :dk_setvar -set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe -set psc=%ps% -nop -c +set psc=powershell.exe 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" - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set _NCS=1 if %winbuild% LSS 10586 set _NCS=0 @@ -1258,7 +1133,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% @@ -1315,23 +1190,19 @@ 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] +echo Installing Generic Product Key %~1 [Successful] ) else ( -call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" -if not defined showfix ( +call :dk_color %Red% "Installing Generic Product Key %~1 [Failed] %keyerror%" +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 ) -set generickey= exit /b :: Activation command @@ -1359,9 +1230,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% @@ -1386,8 +1257,6 @@ exit /b :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" @@ -1433,13 +1302,13 @@ function InstallLicenseArr($Str) { ForEach ($x in $a) {InstallLicenseFile "$x"} } function InstallLicenseDir($Loc) { - Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName} + dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} } function ReinstallLicenses() { - $Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens") - foreach ($Path in $Paths) { - if (Test-Path $Path) { InstallLicenseDir "$Path" } - } + $Oem = "$env:SysPath\oem" + $Spp = "$env:SysPath\spp\tokens" + InstallLicenseDir "$Spp" + If (Test-Path $Oem) {InstallLicenseDir "$Oem"} } :xrm: @@ -1447,7 +1316,6 @@ function ReinstallLicenses() { :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 @@ -1458,21 +1326,16 @@ exit /b :dk_sppissue -sc start %_slser% %nul% +sc start sppsvc %nul% 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 sc start sppsvc [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'}" +%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}" exit /b :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) @@ -1480,7 +1343,7 @@ exit /b :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 d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') set winos= for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) @@ -1536,20 +1399,19 @@ 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% +sc start sppsvc %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 exist %SysPath%\sppsvc.exe 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 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware" echo: ) @@ -1568,118 +1430,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 @@ -1699,7 +1483,6 @@ for %%# in (%serv_ste%) do ( if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%) if /i %%#==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% @@ -1714,26 +1497,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 +1523,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% "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 +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" ) ) -::============================== - -:: 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,21 +1611,42 @@ 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" ( + +if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( set 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%]" ) ) ) + + +%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%" ) -::============================== -:: Check SKU value to find if there is any difference +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,76 +1664,191 @@ 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 ( + +for %%# in (SppEx%w%tComObj.exe sppsvc.exe sppsvc.exe\PerfOptions) do ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#")) ) 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 ( +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 +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. Help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" +set error=1 +set showfix=1 +) + + +set tokenstore= +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% "Help - " %_Yellow% " %mas%troubleshoot" +) + + +:: This code creates token folder only if it's missing and sets default permission for it + +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% "Start-Job { Stop-Service sppsvc -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 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 @@ -2201,7 +1858,7 @@ exit /b $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.*') { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { $count++ } } @@ -2210,7 +1867,7 @@ $minBuildNumber = 14393 if ($osVersion.Build -ge $minBuildNumber) { $subkeyHashTable = @{} foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { - if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { $keyNumber = $subkeyName -replace '.*-', '' $subkeyHashTable[$keyNumber] = $true } @@ -2224,7 +1881,7 @@ if ($osVersion.Build -ge $minBuildNumber) { } } $wpaKey.GetSubKeyNames() | ForEach-Object { - if ($_ -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($_ -match '.*-.*-.*-.*-.*-') { if ($PSVersionTable.PSVersion.Major -lt 3) { cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1" if ($LASTEXITCODE -ne 0) { @@ -2253,10 +1910,8 @@ $wpaKey.Close() if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -) else if not exist %ps% ( -echo %~3 ) exit /b @@ -2264,10 +1919,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' -) else if not exist %ps% ( -echo %~3 %~6 ) exit /b @@ -2282,8 +1935,7 @@ 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 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -2302,10 +1954,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 +1966,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 +2006,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 +2014,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 +2027,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 @@ -2516,6 +2100,17 @@ for %%A in (%_act% %_rem%) do (if "%%A"=="1" set _unattended=1) ::======================================================================================================================================== +if %winbuild% LSS 9200 ( +%eline% +echo Unsupported OS version detected [%winbuild%]. +echo Ohook Activation is supported only on Windows 8/10/11 and their server equivalents. +echo: +call :dk_color %Blue% "Use Online KMS activation option instead." +goto dk_done +) + +::======================================================================================================================================== + if %_rem%==1 goto :oh_uninstall :oh_menu @@ -2558,8 +2153,8 @@ goto :oh_menu cls if not defined terminal ( -mode 140, 32 -if exist "%SysPath%\spp\store_test\" mode 140, 32 +mode 130, 32 +if exist "%SysPath%\spp\store_test\" mode 134, 32 %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=32;$B.Height=300;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}" %nul% ) title Ohook Activation %masver% @@ -2568,17 +2163,12 @@ echo: echo Initializing... call :dk_chkmal -if not exist %SysPath%\%_slexe% ( +if not exist %SysPath%\sppsvc.exe ( %eline% -echo [%SysPath%\%_slexe%] file is missing, aborting... +echo [%SysPath%\sppsvc.exe] 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%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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -2604,7 +2194,7 @@ call :dk_showosinfo echo Initiating Diagnostic Tests... -set "_serv=%_slser% Winmgmt" +set "_serv=sppsvc Winmgmt" :: Software Protection :: Windows Management Instrumentation @@ -2613,17 +2203,16 @@ set notwinact=1 set ohookact=1 call :dk_errorcheck -call :oh_setspp - :: Check unsupported office versions +set o14msi= set o14c2r= set o16uwp= set _68=HKLM\SOFTWARE\Microsoft\Office set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=Office 2010 MSI ) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=Office 2010 MSI ) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=Office 2010 MSI ) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=Office 2010 MSI ) %nul% reg query %_68%\14.0\CVH /f Click2run /k && set o14c2r=Office 2010 C2R %nul% reg query %_86%\14.0\CVH /f Click2run /k && set o14c2r=Office 2010 C2R @@ -2631,10 +2220,10 @@ if %winbuild% GEQ 10240 ( for /f "delims=" %%a in ('%psc% "(Get-AppxPackage -name 'Microsoft.Office.Desktop' | Select-Object -ExpandProperty InstallLocation)" %nul6%') do (if exist "%%a\Integration\Integrator.exe" set o16uwp=Office UWP ) ) -if not "%o14c2r%%o16uwp%"=="" ( +if not "%o14msi%%o14c2r%%o16uwp%"=="" ( echo: -call :dk_color %Red% "Checking Unsupported Office Install [ %o14c2r%%o16uwp%]" -if not "%o16uwp%"=="" call :dk_color %Blue% "Use TSforge option to activate it." +call :dk_color %Red% "Checking Unsupported Office Install [ %o14msi%%o14c2r%%o16uwp%]" +if not "%o14msi%%o16uwp%"=="" call :dk_color %Blue% "Use Online KMS option to activate it." ) if %winbuild% GEQ 10240 %psc% "Get-AppxPackage -name "Microsoft.MicrosoftOfficeHub"" | find /i "Office" %nul1% && ( @@ -2665,10 +2254,10 @@ set o15c2r= set error=1 ) -if "%o16c2r%%o15c2r%%o16msi%%o15msi%%o14msi%"=="" ( +if "%o16c2r%%o15c2r%%o16msi%%o15msi%"=="" ( set error=1 echo: -if not "%o14c2r%%o16uwp%"=="" ( +if not "%o14msi%%o14c2r%%o16uwp%"=="" ( call :dk_color %Red% "Checking Supported Office Install [Not Found]" ) else ( call :dk_color %Red% "Checking Installed Office [Not Found]" @@ -2676,7 +2265,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." @@ -2687,8 +2276,8 @@ goto dk_done ) set multioffice= -if not "%o16c2r%%o15c2r%%o16msi%%o15msi%%o14msi%"=="1" set multioffice=1 -if not "%o14c2r%%o16uwp%"=="" set multioffice=1 +if not "%o16c2r%%o15c2r%%o16msi%%o15msi%"=="1" set multioffice=1 +if not "%o14msi%%o14c2r%%o16uwp%"=="" set multioffice=1 if defined multioffice ( call :dk_color %Gray% "Checking Multiple Office Install [Found, its recommended to install only one version]" @@ -2732,8 +2321,12 @@ set "_oIntegrator=%_oRoot%\integration\integrator.exe" if /i "%_oArch%"=="x64" (set "_hookPath=%_oRoot%\vfs\System" & set "_hook=sppc64.dll") if /i "%_oArch%"=="x86" (set "_hookPath=%_oRoot%\vfs\SystemX86" & set "_hook=sppc32.dll") - -call :oh_ppcpath +if not "%osarch%"=="x86" ( +if /i "%_oArch%"=="x64" set "_sppcPath=%SystemRoot%\System32\sppc.dll" +if /i "%_oArch%"=="x86" set "_sppcPath=%SystemRoot%\SysWOW64\sppc.dll" +) else ( +set "_sppcPath=%SystemRoot%\System32\sppc.dll" +) echo: echo Activating Office... [C2R ^| %_version% ^| %_oArch%] @@ -2744,21 +2337,9 @@ set error=1 goto :starto16c2r ) -if defined noOsppc ( -call :dk_color %Red% "Checking OSPPC.DLL [Not found. Aborting activation...]" -call :dk_color %Blue% "%_fixmsg%" -set error=1 -goto :starto16c2r -) - -call :oh_expiredpreview 2013 call :oh_fixprids call :oh_process -if defined isOspp ( -call :oh_hookinstall_ospp -) else ( call :oh_hookinstall -) ::======================================================================================================================================== @@ -2790,8 +2371,12 @@ set "_oIntegrator=%_oRoot%\integration\integrator.exe" if /i "%_oArch%"=="x64" (set "_hookPath=%_oRoot%\vfs\System" & set "_hook=sppc64.dll") if /i "%_oArch%"=="x86" (set "_hookPath=%_oRoot%\vfs\SystemX86" & set "_hook=sppc32.dll") - -call :oh_ppcpath +if not "%osarch%"=="x86" ( +if /i "%_oArch%"=="x64" set "_sppcPath=%SystemRoot%\System32\sppc.dll" +if /i "%_oArch%"=="x86" set "_sppcPath=%SystemRoot%\SysWOW64\sppc.dll" +) else ( +set "_sppcPath=%SystemRoot%\System32\sppc.dll" +) echo: echo Activating Office... [C2R ^| %_version% %_AudienceData%^| %_oArch%] @@ -2802,37 +2387,25 @@ set error=1 goto :startmsi ) -if defined noOsppc ( -call :dk_color %Red% "Checking OSPPC.DLL [Not found. Aborting activation...]" -call :dk_color %Blue% "%_fixmsg%" -set error=1 -goto :startmsi -) - -call :oh_expiredpreview 2016 2019 2021 2024 call :oh_fixprids call :oh_process -if defined isOspp ( -call :oh_hookinstall_ospp -) else ( 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 @@ -2853,9 +2426,6 @@ echo Adding a Registry to Prevent Banner [Successful] :startmsi -if defined o14msi call :oh_setspp 14 -if defined o14msi call :oh_processmsi 14 %o14msi_reg% -call :oh_setspp if defined o15msi call :oh_processmsi 15 %o15msi_reg% if defined o16msi call :oh_processmsi 16 %o16msi_reg% @@ -2874,10 +2444,10 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) goto :dk_done @@ -2887,7 +2457,7 @@ goto :dk_done :oh_uninstall cls -if not defined terminal mode 145, 32 +if not defined terminal mode 99, 32 title Uninstall Ohook Activation %masver% set _present= @@ -2903,7 +2473,6 @@ if defined o16c2r_reg (for /f "skip=2 tokens=2*" %%a in ('"reg query %o16c2r_reg if defined o15c2r_reg (for /f "skip=2 tokens=2*" %%a in ('"reg query %o15c2r_reg% /v InstallPath" %nul6%') do (set "_15CHook=%%b\root\vfs")) if defined o16msi_reg (for /f "skip=2 tokens=2*" %%a in ('"reg query %o16msi_reg%\Common\InstallRoot /v Path" %nul6%') do (set "_16MHook=%%b")) if defined o15msi_reg (for /f "skip=2 tokens=2*" %%a in ('"reg query %o15msi_reg%\Common\InstallRoot /v Path" %nul6%') do (set "_15MHook=%%b")) -if defined o14msi_reg (for /f "skip=2 tokens=2*" %%a in ('"reg query %o14msi_reg%\Common\InstallRoot /v Path" %nul6%') do (set "_14MHook=%%b")) if defined _16CHook (if exist "%_16CHook%\System\sppc*dll" (set _present=1& del /s /f /q "%_16CHook%\System\sppc*dll" & if exist "%_16CHook%\System\sppc*dll" set _unerror=1)) if defined _16CHook (if exist "%_16CHook%\SystemX86\sppc*dll" (set _present=1& del /s /f /q "%_16CHook%\SystemX86\sppc*dll" & if exist "%_16CHook%\SystemX86\sppc*dll" set _unerror=1)) @@ -2911,9 +2480,8 @@ if defined _15CHook (if exist "%_15CHook%\System\sppc*dll" (set _present=1& d if defined _15CHook (if exist "%_15CHook%\SystemX86\sppc*dll" (set _present=1& del /s /f /q "%_15CHook%\SystemX86\sppc*dll" & if exist "%_15CHook%\SystemX86\sppc*dll" set _unerror=1)) if defined _16MHook (if exist "%_16MHook%sppc*dll" (set _present=1& del /s /f /q "%_16MHook%sppc*dll" & if exist "%_16MHook%sppc*dll" set _unerror=1)) if defined _15MHook (if exist "%_15MHook%sppc*dll" (set _present=1& del /s /f /q "%_15MHook%sppc*dll" & if exist "%_15MHook%sppc*dll" set _unerror=1)) -if defined _14MHook (if exist "%_14MHook%sppc*dll" (set _present=1& del /s /f /q "%_14MHook%sppc*dll" & if exist "%_14MHook%sppc*dll" set _unerror=1)) -for %%# in (14 15 16) do ( +for %%# in (15 16) do ( for %%A in ("%ProgramFiles%" "%ProgramW6432%" "%ProgramFiles(x86)%") do ( if exist "%%~A\Microsoft Office\Office%%#\sppc*dll" (set _present=1& del /s /f /q "%%~A\Microsoft Office\Office%%#\sppc*dll" & if exist "%%~A\Microsoft Office\Office%%#\sppc*dll" set _unerror=1) ) @@ -2927,31 +2495,6 @@ if exist "%%~A\Microsoft %%~G\root\vfs\%%#\sppc*dll" (set _present=1& del /s /f ) ) -::================================== - -for %%# in (OSPPC.DLL sppcs.dll) do ( -for %%A in ("%CommonProgramFiles%" "%CommonProgramW6432%" "%CommonProgramFiles(x86)%") do ( -for %%G in ("%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\%%#") do ( -set size=0 -set size=%%~zG -if !size! GEQ 1 if !size! LSS 100000 ( -set _present=1 -del /f /q "%%~G" -if exist "%%~G" (move /y "%%~G" "!_ttemp!\needsToBeDeleted%random%" %nul%) -if exist "%%~G" (set _unerror=1) else (echo Deleted file - %%~G) -) -if /i sppcs.dll==%%# if !size! GEQ 100000 ( -move /y "%%~G" "%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPC.DLL" %nul% -if exist "%%~G" (move /y "%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPC.DLL" "!_ttemp!\needsToBeDeleted%random%" %nul%) -move /y "%%~G" "%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPC.DLL" %nul% -if exist "%%~G" (set _unerror=1&echo Failed to rename sppcs.dll back to "%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPC.DLL") else (echo Renamed sppcs.dll back to "%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPC.DLL") -) -) -) -) - -::================================== - reg query HKCU\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency %nul% && ( echo: echo Deleting - Registry keys for skipping license check @@ -2981,8 +2524,6 @@ reg unload HKU\%%# %nul% ) ) -::================================== - set "kmskey=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\0ff1ce15-a989-479d-af46-f275c6370663" reg query "%kmskey%" %nul% && ( echo: @@ -3029,7 +2570,6 @@ set _oLPath= set _hookPath= set _hook= set _sppcPath= -set _osppPath= set _actid= set _prod= set _lic= @@ -3038,6 +2578,7 @@ set _prids= set _config= set _version= set _License= +set _oBranding= exit /b ::======================================================================================================================================== @@ -3048,7 +2589,6 @@ set o16c2r= set o15c2r= set o16msi= set o15msi= -set o14msi= set _68=HKLM\SOFTWARE\Microsoft\Office set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office @@ -3058,78 +2598,10 @@ for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\ClickToRun /v InstallPath" % 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 o15c2r=1&set o15c2r_reg=%_86%\15.0\ClickToRun) 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 o15c2r=1&set o15c2r_reg=%_68%\15.0\ClickToRun) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=1&set o14msi_reg=%_86%\14.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=1&set o14msi_reg=%_68%\14.0) - -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 ( -if not "%osarch%"=="x86" ( -if /i "%_oArch%"=="x64" set "_sppcPath=%SystemRoot%\System32\sppc.dll" -if /i "%_oArch%"=="x86" set "_sppcPath=%SystemRoot%\SysWOW64\sppc.dll" -) else ( -set "_sppcPath=%SystemRoot%\System32\sppc.dll" -) -) - -set noOsppc= -set _hook68= -set _hook86= -set _osppPath68= -set _osppPath86= - -if defined isOspp ( -if not "%osarch%"=="x86" ( -if /i "%_oArch%"=="x64" ( -for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /v Path" %nul6%') do (set "_osppPath68=%%b") -if not exist "!_osppPath68!OSPPC.DLL" set noOsppc=1 -) -if /i "%_oArch%"=="x86" ( -for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /v Path" %nul6%') do (set "_osppPath68=%%b") -for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\OfficeSoftwareProtectionPlatform /v Path" %nul6%') do (set "_osppPath86=%%b") -if not exist "!_osppPath68!OSPPC.DLL" set noOsppc=1 -if not exist "!_osppPath86!OSPPC.DLL" set noOsppc=1 -) -) else ( -for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /v Path" %nul6%') do (set "_osppPath86=%%b") -if not exist "!_osppPath86!OSPPC.DLL" set noOsppc=1 -) -if "!_osppPath68:~-1!"=="\" set "_osppPath68=!_osppPath68:~0,-1!" -if "!_osppPath86:~-1!"=="\" set "_osppPath86=!_osppPath86:~0,-1!" -) - -if defined _osppPath68 set _hook68=sppc64.dll -if defined _osppPath86 set _hook86=sppc32.dll +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) exit /b @@ -3205,7 +2677,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% || ( @@ -3225,24 +2697,15 @@ set hasherror= if %_hook%==sppc32.dll set offset=2564 if %_hook%==sppc64.dll set offset=3076 -::====================================== +del /s /q "%_hookPath%\sppcs.dll" %nul% +del /s /q "%_hookPath%\sppc.dll" %nul% -:: Remove previous Install - -for %%# in (sppcs.dll sppc.dll) do ( -del /f /q "%_hookPath%\%%#" %nul% -if exist "%_hookPath%\%%#" (move /y "%_hookPath%\%%#" "!_ttemp!\needsToBeDeleted%random%" %nul%) -if exist "%_hookPath%\%%#" (set "ierror=Remove Previous Ohook Install [%%#]") -) - -if defined ierror goto :oh_hookinstall_error - -::====================================== +if exist "%_hookPath%\sppcs.dll" set "ierror=Remove Previous Ohook Install" +if exist "%_hookPath%\sppc.dll" set "ierror=Remove Previous Ohook Install" mklink "%_hookPath%\sppcs.dll" "%_sppcPath%" %nul% -if not exist "%_hookPath%\sppcs.dll" ( -set ierror=mklink sppcs.dll -goto :oh_hookinstall_error +if not %errorlevel%==0 ( +if not defined ierror set ierror=mklink ) set exhook= @@ -3257,122 +2720,17 @@ popd call :oh_extractdll "%_hookPath%\sppc.dll" "%offset%" ) ) -if not exist "%_hookPath%\sppc.dll" ( -set ierror=Copy -goto :oh_hookinstall_error -) +if not exist "%_hookPath%\sppc.dll" (if not defined ierror set ierror=Copy) echo: -echo Symlinking System's sppc.dll ["%_hookPath%\sppcs.dll"] [Successful] +if not defined ierror ( +echo Symlinking System's sppc.dll to ["%_hookPath%\sppcs.dll"] [Successful] if defined exhook ( echo Copying Custom %_hook% to ["%_hookPath%\sppc.dll"] [Successful] ) else ( echo Extracting Custom %_hook% to ["%_hookPath%\sppc.dll"] [Successful] ) - -goto :oh_hookinstall_error - -::======================================================================================================================================== - -:oh_hookinstall_ospp - -set ierror= -set hasherror= - -if defined _hook86 set offset86=2564 -if defined _hook68 set offset68=3076 - -::====================================== - -:: Remove previous Install - -for %%# in (OSPPC.DLL sppcs.dll) do ( -for %%A in ("%_osppPath68%\%%#" "%_osppPath86%\%%#") do ( -set size=0 -set size=%%~zA -if !size! GEQ 1 if !size! LSS 100000 ( -del /f /q "%%~A" %nul% -if exist "%%~A" (move /y "%%~A" "!_ttemp!\needsToBeDeleted%random%" %nul%) -if exist "%%~A" (set "ierror=Remove Previous Ohook Install [%%#]") -) -) -) - -if defined ierror goto :oh_hookinstall_error - -for %%A in ("%_osppPath68%" "%_osppPath86%") do ( -if exist "%%~A\sppcs.dll" (move /y "%%~A\sppcs.dll" "%%~A\OSPPC.DLL" %nul%) -if exist "%%~A\sppcs.dll" ( -move /y "%%~A\OSPPC.DLL" "!_ttemp!\needsToBeDeleted%random%" %nul% -move /y "%%~A\sppcs.dll" "%%~A\OSPPC.DLL" %nul% -) -if exist "%%~A\sppcs.dll" (set "ierror=Move sppcs.dll back to OSPPC.DLL") -) - -del /f /q "%_hookPath%\sppcs.dll" %nul% -if exist "%_hookPath%\sppcs.dll" (move /y "%_hookPath%\sppcs.dll" "!_ttemp!\needsToBeDeleted%random%" %nul%) -if exist "%_hookPath%\sppcs.dll" (set "ierror=Remove Previous Ohook mklink sppcs.dll") - -if defined ierror goto :oh_hookinstall_error - -::====================================== - -if defined _osppPath68 (move /y "%_osppPath68%\OSPPC.DLL" "%_osppPath68%\sppcs.dll" %nul% & if not exist "%_osppPath68%\sppcs.dll" set ierror=1) -if defined _osppPath86 (move /y "%_osppPath86%\OSPPC.DLL" "%_osppPath86%\sppcs.dll" %nul% & if not exist "%_osppPath86%\sppcs.dll" set ierror=1) - -if defined ierror ( -set "ierror=Rename OSPPC.DLL" -goto :oh_hookinstall_error -) - -if defined _osppPath68 if defined _osppPath86 (mklink "%_hookPath%\sppcs.dll" "%_osppPath86%\sppcs.dll" %nul%) -if defined _osppPath68 if not defined _osppPath86 (mklink "%_hookPath%\sppcs.dll" "%_osppPath68%\sppcs.dll" %nul%) -if defined _osppPath86 if not defined _osppPath68 (mklink "%_hookPath%\sppcs.dll" "%_osppPath86%\sppcs.dll" %nul%) - -if not exist "%_hookPath%\sppcs.dll" ( -set ierror=mklink sppcs.dll -goto :oh_hookinstall_error -) - -set exhook= -if exist "!_work!\BIN\%_hook68%" if exist "!_work!\BIN\%_hook86%" set exhook=1 - -if defined exhook ( -pushd "!_work!\BIN\" -if defined _osppPath68 (copy /y /b "%_hook68%" "%_osppPath68%\OSPPC.DLL" %nul%) -if defined _osppPath86 (copy /y /b "%_hook86%" "%_osppPath86%\OSPPC.DLL" %nul%) -popd ) else ( -if defined _osppPath68 (set _hook=%_hook68%&call :oh_extractdll "%_osppPath68%\OSPPC.DLL" "%offset68%") -if defined _osppPath86 (set _hook=%_hook86%&call :oh_extractdll "%_osppPath86%\OSPPC.DLL" "%offset86%") -) - -if defined _osppPath68 (if not exist "%_osppPath68%\OSPPC.DLL" set ierror=1) -if defined _osppPath86 (if not exist "%_osppPath86%\OSPPC.DLL" set ierror=1) - -if defined ierror ( -set ierror=Copy -goto :oh_hookinstall_error -) - -echo: -if defined _osppPath68 (echo Renaming OSPPC.DLL to sppcs.dll ["%_osppPath68%\sppcs.dll"]) -if defined _osppPath86 (echo Renaming OSPPC.DLL to sppcs.dll ["%_osppPath86%\sppcs.dll"]) -if defined exhook ( -if defined _osppPath68 (echo Copying Custom %_hook68% to ["%_osppPath68%\OSPPC.DLL"]) -if defined _osppPath86 (echo Copying Custom %_hook86% to ["%_osppPath86%\OSPPC.DLL"]) -) else ( -if defined _osppPath68 (echo Extracting Custom %_hook68% to ["%_osppPath68%\OSPPC.DLL"]) -if defined _osppPath86 (echo Extracting Custom %_hook86% to ["%_osppPath86%\OSPPC.DLL"]) -) - -echo Symlinking Renamed sppcs.dll ["%_hookPath%\sppcs.dll"] - -::======================================================================================================================================== - -:oh_hookinstall_error - -if defined ierror ( set error=1 call :dk_color %Red% "Installing Ohook [Failed to %ierror%]" echo: @@ -3391,9 +2749,9 @@ if not defined exhook if not defined ierror ( if defined hasherror ( set error=1 set ierror=1 -call :dk_color %Red% "Modifying Hash of Custom sppcs.dll [Failed]" +call :dk_color %Red% "Modifying Hash of Custom %_hook% [Failed]" ) else ( -echo Modifying Hash of Custom sppcs.dll [Successful] +echo Modifying Hash of Custom %_hook% [Successful] ) ) @@ -3401,26 +2759,6 @@ exit /b ::======================================================================================================================================== -:oh_setspp - -set isOspp= -if %winbuild% GEQ 9200 ( -set spp=SoftwareLicensingProduct -set sps=SoftwareLicensingService -) else ( -set isOspp=1 -set spp=OfficeSoftwareProtectionProduct -set sps=OfficeSoftwareProtectionService -) -if "%1"=="14" ( -set isOspp=1 -set spp=OfficeSoftwareProtectionProduct -set sps=OfficeSoftwareProtectionService -) -exit /b - -::======================================================================================================================================== - :oh_process for %%# in (%_oIds%) do ( @@ -3440,11 +2778,10 @@ call :ohookdata getinfo !_prod! if not "!key!"=="" ( echo "!allapps!" | find /i "!_actid!" %nul1% || call :oh_installlic -if not %oVer%==14 set generickey=1 call :dk_inskey "[!key!] [!_prod!] [!_lic!]" ) else ( set error=1 -call :dk_color %Red% "Checking Product In Script [Office %oVer%.0 !_prod! key not found in script]" +call :dk_color %Red% "Checking Product In Script [Office %oVer%.0 !_prod! not found in script]" call :dk_color %Blue% "Make sure you are using the latest version of MAS." set fixes=%fixes% %mas% call :dk_color %_Yellow% "%mas%" @@ -3454,7 +2791,7 @@ call :dk_color %_Yellow% "%mas%" :: 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 defined winserver if defined _config if exist "%_oLPath%\Word2019VL_KMS_Client_AE*.xrm-ms" ( +if defined winserver if defined _config ( echo %_oIds% | find /i "Retail" %nul1% && ( set scaIsNeeded=1 reg add %_config% /v SharedComputerLicensing /t REG_SZ /d "1" /f %nul1% @@ -3471,11 +2808,7 @@ exit /b :: Process Office MSI Version call :oh_reset -if "%1"=="14" ( -call :dk_actids 59a52881-a989-479d-af46-f275c6370663 -) else ( call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 -) set oVer=%1 for /f "skip=2 tokens=2*" %%a in ('"reg query %2\Common\InstallRoot /v Path" %nul6%') do (set "_oRoot=%%b") @@ -3488,37 +2821,39 @@ if "%osarch%"=="x86" set _oArch=x86 if /i "%_oArch%"=="x64" (set "_hookPath=%_oRoot%" & set "_hook=sppc64.dll") if /i "%_oArch%"=="x86" (set "_hookPath=%_oRoot%" & set "_hook=sppc32.dll") +if not "%osarch%"=="x86" ( +if /i "%_oArch%"=="x64" set "_sppcPath=%SystemRoot%\System32\sppc.dll" +if /i "%_oArch%"=="x86" set "_sppcPath=%SystemRoot%\SysWOW64\sppc.dll" +) else ( +set "_sppcPath=%SystemRoot%\System32\sppc.dll" +) -call :oh_ppcpath +set "_common=%CommonProgramFiles%" +if defined PROCESSOR_ARCHITEW6432 set "_common=%CommonProgramW6432%" +set "_common2=%CommonProgramFiles(x86)%" -call :msiofficedata %2 +for /r "%_common%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" +if not defined _oBranding for /r "%_common2%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" + +call :ohookdata getmsiprod %2 echo: echo Activating Office... [MSI ^| %_version% ^| %_oArch%] +if not defined _oBranding ( +set error=1 +call :dk_color %Red% "Checking BRANDING.XML [Not Found, aborting activation...]" +exit /b +) + if not defined _oIds ( set error=1 call :dk_color %Red% "Checking Installed Products [Product IDs not found, aborting activation...]" exit /b ) -if defined noOsppc ( -call :dk_color %Red% "Checking OSPPC.DLL [Not found. Aborting activation...]" -call :dk_color %Blue% "%_fixmsg%" -set error=1 -exit /b -) - -if %oVer%==14 if defined SingleImage ( -echo Checking Installed Products [SingleImage product found, Professional Retail key will be used for activation] -) - call :oh_process -if defined isOspp ( -call :oh_hookinstall_ospp -) else ( call :oh_hookinstall -) exit /b @@ -3527,7 +2862,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 +2914,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 +2940,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 +2947,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 +2958,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 +3041,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 +3052,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 @@ -3776,69 +3091,15 @@ exit /b :: 1st column = Office version number :: 2nd column = Activation ID -:: 3rd column = For Office 2013 and later, the generated keys are listed. For Office 2010, the blocked keys sourced from the Internet are listed. -:: For Office 2013 and later, key preference is given in this order, Retail:TB:Sub > Retail > OEM:NONSLP > Volume:MAK > Volume:GVLK -:: For Office 2010, key preference is given in this order, Retail > Volume:MAK +:: 3rd column = Generic key. Preference is given in this order, Retail:TB:Sub > Retail > OEM:NONSLP > Volume:MAK > Volume:GVLK :: 4th column = Last part of license description :: 5th column = Edition -:: 6th column = Other Edition IDs if they are part of the same primary product (For reference only) :: Separator = "_" -::=============== - -:: We couldn't find any keys (blocked/generic doesn't matter) for these Office 2010 products. If you have them, please share with us. - -14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_Retail________ExcelR_[HSExcelR] -14_7004b7f0-6407-4f45-8eac-966e5f868bde_Retail________GrooveR -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] - -:: These installers are not publicly available, so it doesn't matter if we don't have their keys. - -14_19316117-30a8-4773-8fd9-7f7231f4e060_SubPrepid_____HomeBusinessSubR -14_4d06f72e-fd50-4bc2-a24b-d448d7f17ef2_SubPrepid_____ProjectProSubR -14_e98ef0c0-71c4-42ce-8305-287d8721e26c_SubPrepid_____ProPlusSubR -14_14f5946a-debc-4716-babc-7e2c240fec08_Retail________MondoR -14_533b656a-4425-480b-8e30-1a2358898350_MAK___________MondoVL - :ohookdata set f= for %%# in ( -:: Office 2010 -14_4d463c2c-0505-4626-8cdb-a4da82e2d8ed_7KTYC-XR43P-C3MRW-BJKFD-XB%f%YPG_Retail________AccessR -14_745fb377-0a59-4ca9-b9a9-c359557a2c4e_7XHPQ-BQMYG-YBP49-CY8B2-T8%f%CGQ_ByPass________AccessRuntimeR -14_95ab3ec8-4106-4f9d-b632-03c019d1d23f_89RTQ-MT4GK-6CPTX-WWP7C-J9%f%KXR_MAK___________AccessVL -14_71dc86ff-f056-40d0-8ffb-9592705c9b76_39TRR-C2F37-9WYJ2-MJQXH-B9%f%38K_MAK___________ExcelVL -14_fdad0dfa-417d-4b4f-93e4-64ea8867b7fd_RCGT3-FPQDV-H49CD-PPDBF-TH%f%47G_MAK___________GrooveVL -14_7b7d1f17-fdcb-4820-9789-9bec6e377821_3YR9B-D9W79-BY66R-R8XYP-QY%f%YYY_Retail________HomeBusinessR_[HomeBusinessDemoR] -14_09e2d37e-474b-4121-8626-58ad9be5776f_3X43R-HHHXX-FRHRW-2M2WJ-8V%f%PHD_Retail________HomeStudentR_[HomeStudentDemoR] -14_ef1da464-01c8-43a6-91af-e4e5713744f9_XDGJY-KFHW9-JWX9X-YM4GW-GC%f%8WR_Retail________InfoPathR -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 -14_8b559c37-0117-413e-921b-b853aeb6e210_367X9-9HP9R-TKHY6-DH4QH-K9%f%PY7_Retail________ProfessionalR_[ProfessionalAcadR,ProfessionalDemoR,OEM-SingleImage] -14_725714d7-d58f-4d12-9fa8-35873c6f7215_6JD4G-KRW3J-48MGV-DM6FC-T9%f%WKR_Retail________ProjectProR_[ProjectProMSDNR] -14_1cf57a59-c532-4e56-9a7d-ffa2fe94b474_3XDTH-MMGJ6-F9MKX-THP8D-G9%f%BP7_MAK___________ProjectProVL -14_688f6589-2bd9-424e-a152-b13f36aa6de1_2W96V-RTQ9R-2BPVT-PT8H9-MV%f%68T_Retail________ProjectStdR -14_11b39439-6b93-4642-9570-f2eb81be2238_4DTT4-D4MKX-23KFH-JKR6T-YK%f%G2J_MAK___________ProjectStdVL -14_71af7e84-93e6-4363-9b69-699e04e74071_2J9H6-H4D3G-PCXD2-96XVM-TR%f%R73_Retail________ProPlusR_[ProPlusAcadR,ProPlusMSDNR,Sub4R] -14_fdf3ecb9-b56f-43b2-a9b8-1b48b6bae1a7_6CD6C-9R8PB-T2D9Y-8RKKX-W7%f%DFK_MAK___________ProPlusVL_[ProPlusAcadVL] -14_98677603-a668-4fa4-9980-3f1f05f78f69_CTRJP-P72VV-JBF8Y-4W6WW-HX%f%HVG_Retail________PublisherR -14_3d014759-b128-4466-9018-e80f6320d9d0_32YG9-3VX77-YXJVV-PRVFW-TT%f%8BV_MAK___________PublisherVL -14_8090771e-d41a-4482-929e-de87f1f47e46_7VKXH-9BWCG-RPTBB-JBRV3-GR%f%HYC_MAK___________SmallBusBasicsVL -14_b78df69e-0966-40b1-ae85-30a5134dedd0_H48K6-FB4Y6-P83GH-9J7XG-HD%f%KKX_ByPass________SPDR -14_b6d2565c-341d-4768-ad7d-addbe00bb5ce_W3BTX-H6BW7-Q6DFW-BXFFY-8R%f%VJP_Retail________StandardR_[StandardMSDNR][KeyisforMSDNR] -14_1f76e346-e0be-49bc-9954-70ec53a4fcfe_2XTQP-GDR7C-GTXPC-6W6PV-4R%f%XGC_MAK___________StandardVL_[StandardAcadVL] -14_2745e581-565a-4670-ae90-6bf7c57ffe43_VXHHB-W7HBD-7M342-RJ7P8-CH%f%BD6_ByPass________StarterR -14_66cad568-c2dc-459d-93ec-2f3cb967ee34_2RDPT-WPYQM-C2WXF-BTPDW-2J%f%2HM_Retail________VisioSIR_Prem[Pro,Std] -14_36756cb8-8e69-4d11-9522-68899507cd6a_7PKFT-X2MKQ-GT6X2-8CB2W-CH%f%C9K_MAK___________VisioSIVL_Prem[Pro,Std] -14_98d4050e-9c98-49bf-9be1-85e12eb3ab13_6J3XK-DFKGK-X373V-QJHYM-V3%f%FC2_MAK___________WordVL :: Office 2013 15_ab4d047b-97cf-4126-a69f-34df08e2f254_B7RFY-7NXPK-Q4342-Y9X2H-3J%f%X4X_Retail________AccessRetail 15_259de5be-492b-44b3-9d78-9645f848f7b0_X3XNB-HJB7K-66THH-8DWQ3-XH%f%GJP_Bypass________AccessRuntimeRetail @@ -3894,7 +3155,6 @@ for %%# in ( 15_e3dacc06-3bc2-4e13-8e59-8e05f3232325_H8DN8-Y2YP3-CR9JT-DHDR9-C7%f%GP3_Subscription2_O365ProPlusRetail 15_0bc1dae4-6158-4a1c-a893-807665b934b2_2QCNB-RMDKJ-GC8PB-7QGQV-7Q%f%TQJ_Subscription2_O365SmallBusPremRetail :: Office 365 - 16.0 version -16_dabaa1f2-109b-496d-bf49-1536cc862900_3HYJN-9KG99-F8VG9-V3DT8-JF%f%MHV_Subscription__O365AppsBasicRetail 16_742178ed-6b28-42dd-b3d7-b7c0ea78741b_Y9NF9-M2QWD-FF6RJ-QJW36-RR%f%F2T_SubTest_______O365BusinessRetail 16_2f5c71b4-5b7a-4005-bb68-f9fac26f2ea3_W62NQ-267QR-RTF74-PF2MH-JQ%f%MTH_Subscription__O365EduCloudRetail 16_a96f8dae-da54-4fad-bdc6-108da592707a_3NMDC-G7C3W-68RGP-CB4MH-4C%f%XCH_SubTest1______O365HomePremRetail @@ -4062,6 +3322,17 @@ if %oVer%==16 (echo "%%D" | find /i "Subscription" %nul% && set _sublic=1) ) ) +if %1==getmsiprod if %oVer%==%%A ( +for /f "tokens=*" %%x in ('findstr /i /c:"%%B" "%_oBranding%"') do set "prodId=%%x" +set prodId=!prodId:"/>=! +set prodId=!prodId:~-4! +reg query "%2\Registration\{%%B}" /v ProductCode %nul2% | find /i "-!prodId!-" %nul% && ( +reg query "%2\Common\InstalledPackages" %nul2% | find /i "-!prodId!-" %nul% && ( +if defined _oIds (set _oIds=!_oIds! %%E) else (set _oIds=%%E) +) +) +) + ) ) exit /b @@ -4074,7 +3345,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: @@ -4113,7 +3384,7 @@ $Writer.Write($unixTimestamp) $Writer.Flush() # Write the current state of the MemoryStream to a temporary file -$tempFilePath = "$env:windir\Temp\$([System.IO.Path]::GetRandomFileName())" +$tempFilePath = [System.IO.Path]::Combine($env:windir, "Temp", [System.IO.Path]::GetRandomFileName()) [System.IO.File]::WriteAllBytes($tempFilePath, $MemoryStream.ToArray()) # Update hash using the temporary file @@ -4157,13 +3428,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 +3619,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" @@ -4375,6 +3641,8 @@ 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"=="-el" (set _elev=1) if /i "%%A"=="/Z-Windows" (set _actwin=1) @@ -4387,26 +3655,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% || ( -%eline% -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 -goto dk_done -) -) ::======================================================================================================================================== @@ -4423,9 +3675,9 @@ echo: echo ______________________________________________________________ echo: echo [1] Activate - Windows -echo [2] Activate - ESU -echo [3] Activate - Office [All] -echo [4] Activate - Office [Project/Visio] +echo [2] Activate - Windows [ESU] +echo [3] Activate - Office [All] +echo [4] Activate - Office [Project/Visio] echo [5] Activate - All echo _______________________________________________ echo: @@ -4435,12 +3687,7 @@ echo [A] Activate - Windows %KS% Host echo [B] Activate - Office %KS% Host echo [C] Activate - Windows 8/8.1 APPX Sideloading echo [D] Activate - Manually Select Products -if defined _vis ( -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 +3696,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 +3715,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 @@ -4537,17 +3733,12 @@ echo: echo Initializing... call :dk_chkmal -if not exist %SysPath%\%_slexe% ( +if not exist %SysPath%\sppsvc.exe ( %eline% -echo [%SysPath%\%_slexe%] file is missing, aborting... +echo [%SysPath%\sppsvc.exe] 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%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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -4560,21 +3751,21 @@ echo Install .NET Framework 4.8 and Windows Management Framework 5.1 ) echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) ) if %winbuild% LSS 9200 if exist "%SysPath%\wlms\wlms.exe" ( sc query wlms | find /i "RUNNING" %nul% && ( -sc stop %_slser% %nul% +sc stop sppsvc %nul% if !errorlevel! EQU 1051 ( %eline% -echo Evaluation WLMS service is running, %_slser% service can not be stopped. Aborting... +echo Evaluation WLMS service is running, sppsvc service can not be stopped. Aborting... echo Install Non-Eval version for Windows build %winbuild%. echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) ) @@ -4601,79 +3792,30 @@ 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" +set "_serv=sppsvc Winmgmt" :: Software Protection :: Windows Management Instrumentation call :dk_errorcheck +if defined error ( +call :dk_color %Red% "Some errors were detected. Aborting the operation..." +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" +goto :dk_done +) + call :ts_getedition if not defined tsedition ( call :dk_color %Red% "Checking Windows Edition ID [Not found in installed licenses, aborting...]" set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto :dk_done ) -if /i !tsmethod!==KMS4k ( -call :_taskclear-cache -echo Clearing %KS% Cache [Successful] -) - ::======================================================================================================================================== if %_resall%==1 goto :ts_resetall @@ -4695,24 +3837,15 @@ 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 +3854,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,164 +3861,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 - -::======================================================================================================================================== - -:ts_winvista - -:: Process Windows Vista - -:: 1st column = Activation ID -:: 2nd column = Generic key -:: 3rd column = Key channel -:: 4th column = Edition ID -:: Separator = _ - -:: Keys aren't available for these editions, but since these editions aren't publicly available, it doesn't matter -:: a797d61e-1475-470b-86c8-f737a72c188d StarterN -:: 5e9f548a-c8a9-44e6-a6c2-3f8d0a7a99dd ServerComputeClusterV - -set f= -set key= -set tempid= -if not defined allapps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -for %%# in ( -:: WindowsVista -9de9abe2-d01d-4538-af84-4498bdbc2ba3_4D2XH-PRBMM-8Q22B-K8BM3-MR%f%W4W_____Retail_Business -db442be4-81ed-4ab3-9d66-2417e8a5c81c_76884-QXFY2-6Q2WX-2QTQ8-QX%f%X44_____Retail_BusinessN -b51791c2-b562-4b73-97b0-735a0e4429a6_YQPQV-RW8R3-XMPFG-RXG9R-JG%f%TVF_____Retail_Enterprise -58c37517-42f8-4723-bb44-30b05791ff2a_Q7J9R-G63R4-BFMHF-FWM9R-RW%f%DMV_____Retail_EnterpriseN -95c6e80a-0ff8-4bd0-95f2-c4a39b79d09e_RCG7P-TX42D-HM8FM-TCFCW-3V%f%4VD_____Retail_HomeBasic -d0333dad-c14e-46f2-b62a-8b47a1b9768b_HY2VV-XC6FF-MD6WV-FPYBQ-GF%f%JBT_____Retail_HomeBasicN -9e042223-03bf-49ae-808f-ff37f128d40d_X9HTF-MKJQQ-XK376-TJ7T4-76%f%PKF_____Retail_HomePremium -92d8977c-d506-4e63-b500-6d39283b6cd5_KJ6TP-PF9W2-23T3Q-XTV7M-PX%f%DT2_____Retail_HomePremiumN -89e51a3c-76c0-4beb-a650-53d34c8f8186_X9PYV-YBQRV-9BXWV-TQDMK-QD%f%WK4_____Retail_Starter -30fab9cc-8614-4339-989f-7ce61fb7a5c4_VMCB9-FDRV6-6CDQM-RV23K-RP%f%8F7_____Retail_Ultimate -1eefed20-8ac0-478c-8774-70cd44782ea1_CVX38-P27B4-2X8BT-RXD4J-V7%f%CKX_____Retail_UltimateN -:: WindowsServer2008 -c9ad502b-ef48-41d1-a2a0-38a38e82fed0_24FV9-H7JW8-C8Q6X-BQKMK-K9%f%77J_____Retail_ServerComputeCluster -866e924e-c2a3-4872-aca1-6b48c13962d5_6QBHY-DXTPJ-T9W3P-DTJXX-4V%f%QMB_____Retail_ServerDatacenter -d020c729-07f0-4f8f-87ce-bf803275c786_83TWG-TD3TC-HRDP2-K93FJ-Y3%f%4YC_OEM:NONSLP_ServerDatacenterV -32b40e5e-0c6d-4c6f-ab12-a031933fd2c6_MRB7H-QJRHG-FXTBR-B2Q2M-8W%f%MTJ_____Retail_ServerEnterprise -256cc990-1692-4ea8-965c-2d423d5dd24e_H4VB6-QPRWH-VDCYM-996P8-MH%f%KFY_OEM:NONSLP_ServerEnterpriseIA64 -1ba5e036-e386-42c4-b7eb-16bdb4fa1945_H8H7M-HDPQT-PJHQF-M7B83-9C%f%VGV_____Retail_ServerEnterpriseV -8df04457-07c8-4301-bce9-d61eb76cb2d6_RGBMC-PQBVF-94Q9K-HD63B-VY%f%6MP_____Retail_ServerHomePremium -5bd23b19-aa71-4a5b-8b68-c8801c2baff6_6C8KR-MD3QK-9GWFW-44CY2-W9%f%CBM_____Retail_ServerHomeStandard -b86c7736-91ff-4de9-bfa9-b32b8a09acac_7XRBY-6MP2K-VQPT8-F37JV-YY%f%Q83_____Retail_ServerMediumBusinessManagement -d3f5642f-081d-40b2-a4b9-efd3054d4584_6PDTD-JK48J-662TF-8J2QV-R4%f%CRB_____Retail_ServerMediumBusinessMessaging -c6936a36-69f3-4994-9857-3069c7b9ec7a_D694V-CMWKH-PY92X-PFQKQ-JC%f%B69_____Retail_ServerMediumBusinessSecurity -cc4c2cf8-ef29-4d8e-b168-2b65a3db3309_MRDK3-YYQF3-88BQJ-D6FJG-69%f%YJY_____Retail_ServerSBSPremium -b3827b27-bd38-4284-98af-e4f4d1c051a0_2KB23-GJRBD-W3T9C-6CH2W-39%f%B7V_____Retail_ServerSBSPrime -5dad0eff-3f6f-4310-8844-422f9dc7c84b_H4XDD-B27GY-667P6-XWVV7-GY%f%G8J_____Retail_ServerSBSStandard -603504f9-109f-49f0-9271-8c66f7878f58_8YVM4-YQBDH-7WDQM-R27WR-WV%f%CWG_____Retail_ServerStandard -65ab7338-9ad0-43fe-af1b-190b577495e2_H9MW3-6V7GK-94P9G-7FTPJ-VK%f%CKF_____Retail_ServerStandardV -2be204da-24a0-4943-b66c-81e8464acd7e_2264C-TD9T8-P8HPW-CC9GH-MH%f%M2V_____Retail_ServerStorageEnterprise -60207eba-8b4a-486c-a013-023b4b742c2f_RCYMT-YX342-8T6YY-XYHYC-3D%f%D7X_____Retail_ServerStorageExpress -368856e9-43f7-4601-8358-e561f36c7dd8_FKFT2-WXYY9-WBPY7-6YMY4-X4%f%8JF_____Retail_ServerStorageStandard -4bf433fa-ab04-4c6c-b55b-00170e14b8cd_8X9J7-HCJ7J-3WDJT-QM7D8-46%f%4YH_____Retail_ServerStorageWorkgroup -a77a6806-f59e-4953-97d7-229317b8e6a6_BGT39-9FYH7-X2CYD-T628F-QP%f%QPW_____Retail_ServerWeb -f92f836d-4d3e-4e90-a08f-2d612d65e716_HPH76-FHFPP-DRW9D-7W2V4-HW%f%GKT_____Retail_ServerWinSB -3059a9fd-b068-4f0d-acaf-66324dca67ac_2V8G6-KRXYR-MMGXJ-6RWM3-GX%f%CCG_____Retail_ServerWinSBV -) do ( -for /f "tokens=1-4 delims=_" %%A in ("%%#") do if %tsedition%==%%D if not defined key ( -echo "%allapps%" | find /i "%%A" %nul1% && ( -set key=%%B -set tempid=%%A -) -) -) - -if not defined key ( -set error=1 -call :dk_color %Red% "Checking Activation ID [%tsedition% SKU-%osSKU% not found in the system]" -call :dk_color %Blue% "%_fixmsg%" -goto :ts_esu -) - -echo Checking Activation ID [%tempid%] [%tsedition%] - -set generickey=1 -call :dk_inskey "[%key%]" -set tsids=%tsids% %tempid% goto :ts_esu ::======================================================================================================================================== @@ -5002,7 +3970,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 @@ -5013,23 +3981,25 @@ goto :ts_esu echo Resetting Rearm / GracePeriod [Successful] ) -set generickey=1 -call :dk_inskey "[%key%]" +%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 %keyerror% EQU 0 ( +call :dk_refresh +echo Installing Activable Evaluation Key [%key%] [Successful] +) else ( +set error=1 +call :dk_color %Red% "Installing Activable Evaluation Key [%key%] [Failed] %keyerror%" +call :dk_color %Blue% "%_fixmsg%" +) ::======================================================================================================================================== :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 +4021,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- @@ -5072,7 +4029,7 @@ REM Windows7EmbeddedPOSReady7 4f1f646c-1e66-4908-acc7-d1606229b29e_POS-ESU-Year3[1-3y]_-Embedded[POS]- REM Windows7EmbeddedStandard 6aaf1c7d-527f-4ed5-b908-9fc039dfc654_WES-ESU-Year3[1-3y]_-Embedded[Standard]- -REM WindowsServer2008/WindowsServer2008R2 +REM WindowsServer2008R2 8e7bfb1e-acc1-4f56-abae-b80fce56cd4b_Server-ESU-PA[1-6y]_-ServerDatacenter-ServerDatacenterCore-ServerDatacenterV-ServerDatacenterVCore-ServerStandard-ServerStandardCore-ServerStandardV-ServerStandardVCore-ServerEnterprise-ServerEnterpriseCore-ServerEnterpriseV-ServerEnterpriseVCore- REM Windows8.1 4afc620f-12a4-48ad-8015-2aebfbd6e47c_Client-ESU-Year3[1-3y]_-Enterprise-EnterpriseN-Professional-ProfessionalN- @@ -5080,10 +4037,10 @@ 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% +83d49986-add3-41d7-ba33-87c7bfb5c0fb_Client-ESU-Year3[1-3y]_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN- +0b533b5e-08b6-44f9-b885-c2de291ba456_Client-ESU-Year6[4-6y]_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN- +4dac5a0c-5709-4595-a32c-14a56a4a6b31_Client-IoT-ESU-Year3[1-3y]_-IoTEnterprise- REM Removed IoTEnterpriseS because it already has longer support +f69e2d51-3bbd-4ddf-8da7-a145e9dca597_Client-IoT-ESU-Year6[4-6y]_-IoTEnterprise- REM Removed IoTEnterpriseS because it already has longer support ) do ( for /f "tokens=1-3 delims=_" %%A in ("%%#") do ( echo "%allapps%" | find /i "%%A" %nul1% && ( @@ -5102,18 +4059,10 @@ set esuexistbutnosup=1 ) ) -if defined esuexistsup if defined _vis ( -set key=9FPV7-MWGT8-7XPDF-JC23W-WT7TW -REM This is a non-generic blocked MAK key for Server-ESU-PA -call :dk_inskey "[!key!]" -goto :ts_off -) - if defined esuexistsup ( echo "%tsids%" | find /i "4220f546-f522-46df-8202-4d07afd26454" %nul1% && ( echo "%tsids%" | find /i "7e94be23-b161-4956-a682-146ab291774c" %nul1% || ( -call :dk_color %Gray% "To get Client-ESU-Year6[4-6y] license, install updates from the below URL." -call :dk_color %Blue% "%mas%tsforge#windows-esu" +call :dk_color %Gray% "Now update Windows to get Client-ESU-Year6[4-6y] license and activate that using this script." ) ) goto :ts_off @@ -5125,20 +4074,14 @@ 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 ) set esuavail= -if defined _vis if defined isServer set esuavail=1 -if %winbuild% LEQ 7602 if not defined _vis if not defined isThinpc set esuavail=1 +if %winbuild% LEQ 7602 if not defined isThinpc set esuavail=1 if %winbuild% GTR 7602 if %winbuild% LSS 10240 if defined isServer set esuavail=1 if %winbuild% GEQ 10240 if %winbuild% LEQ 19045 if not defined isServer set esuavail=1 if %winbuild% EQU 9600 set esuavail=1 @@ -5146,7 +4089,7 @@ if %winbuild% EQU 9600 set esuavail=1 if defined esuavail ( call :dk_color %Red% "Checking Activation ID [ESU license is not found, make sure Windows is fully updated]" set fixes=%fixes% %mas%tsforge#windows-esu -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%tsforge#windows-esu" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%tsforge#windows-esu" ) else ( call :dk_color %Gray% "Checking Activation ID [ESU is not available for %winos%]" ) @@ -5160,7 +4103,7 @@ if not %_actoff%==1 goto :ts_act if %winbuild% LSS 9200 ( echo: call :dk_color %Gray% "Checking Supported Office [TSforge for Office is supported on Windows 8 and later versions]" -call :dk_color %Blue% "On Windows Vista / 7, use Ohook activation option for Office instead." +call :dk_color %Blue% "On Windows 7 build, use Online %KS% activation option for Office instead." goto :ts_act ) @@ -5193,15 +4136,14 @@ set o14c2r= set _68=HKLM\SOFTWARE\Microsoft\Office set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=Office 2010 MSI ) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=Office 2010 MSI ) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=Office 2010 MSI ) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=Office 2010 MSI ) %nul% reg query %_68%\14.0\CVH /f Click2run /k && set o14c2r=Office 2010 C2R %nul% reg query %_86%\14.0\CVH /f Click2run /k && set o14c2r=Office 2010 C2R if not "%o14msi%%o14c2r%"=="" ( echo: call :dk_color %Red% "Checking Unsupported Office Install [ %o14msi%%o14c2r%]" -if defined o14msi call :dk_color %Blue% "Use Ohook activation option for Office 2010." ) if %winbuild% GEQ 10240 %psc% "Get-AppxPackage -name "Microsoft.MicrosoftOfficeHub"" | find /i "Office" %nul1% && ( @@ -5257,7 +4199,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 +4303,6 @@ set error=1 goto :ts_starto16c2r ) -call :oh_expiredpreview 2013 if "%_actprojvis%"=="0" call :oh_fixprids call :ts_process @@ -5403,30 +4344,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,22 +4372,11 @@ 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." ) -call :dk_color %Gray% "%KS% Host [Not to be confused with %KS% Client] license causes the %_slser% service to run continuously." +call :dk_color %Gray% "%KS% Host [Not to be confused with %KS% Client] license causes the sppsvc service to run continuously." call :dk_color %Blue% "Only use this activation when necessary, you can revert to normal activation from the previous menu." if %_unattended%==0 ( @@ -5479,18 +4390,16 @@ set _arr= set tempid= set keytype=kmshost -if defined _vis goto :ts_whost_vista - :: Install current edition csvlk license so that correct edition can reflect for csvlk 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) ) @@ -5512,53 +4421,6 @@ goto :ts_act ::======================================================================================================================================== -:ts_whost_vista - -:: Process Windows K-M-S host for Vista - -:: 1st column = Activation ID -:: 2nd column = CSVLK key -:: 3rd column = Edition IDs -:: Separator = _ - -set f= -set key= -set tempid= -if not defined allapps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -for %%# in ( -:: WindowsVista -212a64dc-43b1-4d3d-a30c-2fc69d2095c6_TWVG3-9Q4P8-W9XJF-Y76FJ-DW%f%Q4R_-Business-BusinessN-Enterprise-EnterpriseN- -:: WindowsServer2008 -c90d1b4e-8aa8-439e-8b9e-b6d6b6a6d975_BHC4Q-6D7B7-QMVH7-4MKQH-Y9%f%VK7_-ServerComputeCluster-ServerDatacenter-ServerDatacenterV-ServerEnterprise-ServerEnterpriseIA64-ServerEnterpriseV-ServerStandard-ServerStandardV-ServerWeb- -56df4151-1f9f-41bf-acaa-2941c071872b_PVGKG-2R7XQ-7WTFD-FXTJR-DQ%f%BQ3_-ServerComputeCluster-ServerEnterprise-ServerEnterpriseV-ServerStandard-ServerStandardV-ServerWeb- -c448fa06-49d1-44ec-82bb-0085545c3b51_KH4PC-KJFX6-XFVHQ-GDK2G-JC%f%JY9_-ServerComputeCluster-ServerWeb- -) do ( -for /f "tokens=1-3 delims=_" %%A in ("%%#") do if not defined key ( -echo "%allapps%" | find /i "%%A" %nul1% && ( -echo "%%C" | find /i "-%tsedition%-" %nul1% && ( -set key=%%B -set tempid=%%A -) -) -) -) - -if defined key ( -echo Checking Activation ID [%tempid%] [%tsedition%] -) else ( -call :dk_color %Red% "Checking Activation ID [Not Found] [%tsedition%] [%osSKU%]" -call :dk_color %Blue% "%KS% Host license is not found on your system. It is available for the below editions." -call :dk_color %Blue% "Business, BusinessN, Enterprise, EnterpriseN, and Server editions, etc." -goto :ts_act -) - -call :dk_inskey "[%key%]" -set tsids=%tsids% %tempid% -goto :ts_act - -::======================================================================================================================================== - :ts_ohost :: Process Office K-M-S host @@ -5566,23 +4428,6 @@ goto :ts_act echo: echo Processing Office %KS% Host... -if defined _vis ( -echo: -call :dk_color %Blue% "Windows Vista and Server 2008 do not support the installation of Office KMS Host." -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% @@ -5608,7 +4453,7 @@ echo Checking Activation ID [%%A] [%%B] if not defined ohostexist ( call :dk_color %Gray% "Checking Activation ID [Not found for Office %KS% Host]" -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%tsforge#office-kms-host" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%tsforge#office-kms-host" ) echo: @@ -5635,17 +4480,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 @@ -5676,20 +4510,16 @@ goto :ts_act :ts_resetall echo: -if defined _vis ( -echo Processing Reset of Rearm / Timers... -) else ( 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." set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) else ( call :dk_color %Green% "Reset process has been successfully done." ) @@ -5704,17 +4534,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 +4551,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 @@ -5740,10 +4559,6 @@ goto :dk_done for /f "delims=" %%a in ('%psc% "$ids = Get-WmiObject -Query 'SELECT ID FROM SoftwareLicensingProduct' | Select-Object -ExpandProperty ID; $ids" %nul6%') do call set "allactids= %%a !allactids! " -if defined _vis ( -echo: -call :dk_color %Blue% "On Windows Vista and Server 2008, you must manually install the key before activating it." -) echo: call :dk_color %Gray% "Enter / Paste the Activation ID shown in first column in the opened text file, or just press Enter to return:" echo Add space after each Activation ID if you are adding multiple: @@ -5807,14 +4622,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,47 +4682,33 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) ) 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...) -) +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" +call :dk_color2 %Blue% "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 year 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 year ESU license is added just as a placeholder." ) ) -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." ) @@ -5923,7 +4724,7 @@ call :dk_reeval %nul% if not defined tsids if defined error if not defined showfix ( set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) goto :dk_done @@ -5939,7 +4740,8 @@ mode 100, 30 title Remove TSforge Activation %masver% echo: -echo TSforge activation doesn't modify any Windows components and doesn't install any new files. +echo TSforge activation doesn't modify any Windows component. +echo TSforge activation doesn't install any new file in the system. echo: echo Instead, it appends data to one of data files used by Software Protection Platform. echo: @@ -5966,7 +4768,7 @@ set _prids= set _config= set _version= set _License= -set _oMSI= +set _oBranding= exit /b ::======================================================================================================================================== @@ -5986,10 +4788,10 @@ for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\ClickToRun /v InstallPath" % 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 o15c2r=1&set o15c2r_reg=%_86%\15.0\ClickToRun) 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 o15c2r=1&set o15c2r_reg=%_68%\15.0\ClickToRun) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) exit /b @@ -6009,19 +4811,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,63 +4818,17 @@ 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) - -if defined no365 ( +echo %%# | findstr /i "O365" %nul% && ( 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 ( -echo %%# | findstr /i "ARM" %nul% && ( -set _License=MondoRetail -set _altoffid=MondoRetail -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!" @@ -6097,7 +4840,7 @@ call :dk_color %Red% "Checking Activation ID [Office %oVer%.0 ! set error=1 set showfix=1 set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) echo %%# | find /i "2024" %nul% && ( @@ -6113,7 +4856,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 ( echo %_oIds% | find /i "Retail" %nul1% && ( set scaIsNeeded=1 reg add %_config% /v SharedComputerLicensing /t REG_SZ /d "1" /f %nul1% @@ -6132,7 +4875,6 @@ exit /b call :ts_reset call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 -set _oMSI=1 set oVer=%1 for /f "skip=2 tokens=2*" %%a in ('"reg query %2\Common\InstallRoot /v Path" %nul6%') do (set "_oRoot=%%b") for /f "skip=2 tokens=2*" %%a in ('"reg query %2\Common\ProductVersion /v LastProduct" %nul6%') do (set "_version=%%b") @@ -6146,17 +4888,26 @@ set "_common=%CommonProgramFiles%" if defined PROCESSOR_ARCHITEW6432 set "_common=%CommonProgramW6432%" set "_common2=%CommonProgramFiles(x86)%" +for /r "%_common%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" +if not defined _oBranding for /r "%_common2%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" + if exist "%_common%\Microsoft Shared\OFFICE%oVer%\Office Setup Controller\pkeyconfig-office.xrm-ms" ( set "pkeypath=%_common%\Microsoft Shared\OFFICE%oVer%\Office Setup Controller\pkeyconfig-office.xrm-ms" ) else if exist "%_common2%\Microsoft Shared\OFFICE%oVer%\Office Setup Controller\pkeyconfig-office.xrm-ms" ( set "pkeypath=%_common2%\Microsoft Shared\OFFICE%oVer%\Office Setup Controller\pkeyconfig-office.xrm-ms" ) -call :msiofficedata %2 +call :ts_msiofficedata %2 echo: echo Processing Office... [MSI ^| %_version% ^| %_oArch%] +if not defined _oBranding ( +set error=1 +call :dk_color %Red% "Checking BRANDING.XML [Not Found. Aborting activation...]" +exit /b +) + if not defined _oIds ( set error=1 call :dk_color %Red% "Checking Installed Products [Product IDs not found. Aborting activation...]" @@ -6172,240 +4923,33 @@ exit /b :ts_checkwinperm -%psc% "Get-WmiObject -Query 'SELECT Name, Description FROM SoftwareLicensingProduct WHERE LicenseStatus=''1'' AND GracePeriodRemaining=''0'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn IS NULL' | Where-Object { $_.Description -notmatch 'KMS' } | Select-Object -Property Name" %nul2% | findstr /i "Windows" %nul1% && set _perm=1||set _perm= +%psc% "Get-WmiObject -Query 'SELECT Name, Description FROM SoftwareLicensingProduct WHERE LicenseStatus=''1'' AND GracePeriodRemaining=''0'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn IS NULL' | Where-Object { $_.Description -notmatch 'KMS_' } | Select-Object -Property Name" %nul2% | findstr /i "Windows" %nul1% && set _perm=1||set _perm= 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 Microsoft.Win32; using System; using System.IO; using System.Linq; using System.Runtime.InteropServices; + using System.ServiceProcess; using System.Text; + using LibTSforge.Crypto; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; + using LibTSforge.TokenStore; public enum PSVersion { Vista, Win7, + Win8Early, Win8, WinBlue, WinModern @@ -6476,8 +5020,8 @@ namespace LibTSforge 0x92, 0xA6, 0x56, 0x96 }; - // 2^31 - 8 minutes - public static readonly ulong TimerMax = (ulong)TimeSpan.FromMinutes(2147483640).Ticks; + // 2^31 - 1 minutes + public static ulong TimerMax = (ulong)TimeSpan.FromMinutes(2147483647).Ticks; public static readonly string ZeroCID = new string('0', 48); } @@ -6545,6 +5089,20 @@ namespace LibTSforge } return result; } + + public static T CastToStruct(this byte[] data) where T : struct + { + GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); + try + { + IntPtr ptr = handle.AddrOfPinnedObject(); + return (T)Marshal.PtrToStructure(ptr, typeof(T)); + } + finally + { + handle.Free(); + } + } } public static class FileStreamExt @@ -6565,12 +5123,6 @@ namespace LibTSforge public static class Utils { - [DllImport("kernel32.dll")] - public static extern uint GetSystemDefaultLCID(); - - [DllImport("kernel32.dll")] - public static extern bool Wow64EnableWow64FsRedirection(bool Wow64FsEnableRedirection); - public static string DecodeString(byte[] data) { return Encoding.Unicode.GetString(data).Trim('\0'); @@ -6581,6 +5133,9 @@ namespace LibTSforge return Encoding.Unicode.GetBytes(str + '\0'); } + [DllImport("kernel32.dll")] + public static extern uint GetSystemDefaultLCID(); + public static uint CRC32(byte[] data) { const uint polynomial = 0x04C11DB7; @@ -6604,6 +5159,157 @@ namespace LibTSforge return ~crc; } + public static void KillSPP() + { + ServiceController sc; + + try + { + sc = new ServiceController("sppsvc"); + + if (sc.Status == ServiceControllerStatus.Stopped) + return; + } + catch (InvalidOperationException ex) + { + throw new InvalidOperationException("Unable to access sppsvc: " + ex.Message); + } + + Logger.WriteLine("Stopping sppsvc..."); + + bool stopped = false; + + for (int i = 0; stopped == false && i < 60; i++) + { + try + { + if (sc.Status != ServiceControllerStatus.StopPending) + sc.Stop(); + + sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMilliseconds(500)); + } + catch (System.ServiceProcess.TimeoutException) + { + continue; + } + catch (InvalidOperationException) + { + System.Threading.Thread.Sleep(500); + continue; + } + + stopped = true; + } + + if (!stopped) + throw new System.TimeoutException("Failed to stop sppsvc"); + + Logger.WriteLine("sppsvc stopped successfully."); + } + + public static string GetPSPath(PSVersion version) + { + switch (version) + { + case PSVersion.Win7: + return Directory.GetFiles( + Environment.GetFolderPath(Environment.SpecialFolder.System), + "7B296FB0-376B-497e-B012-9C450E1B7327-*.C7483456-A289-439d-8115-601632D005A0") + .FirstOrDefault() ?? ""; + case PSVersion.Win8Early: + case PSVersion.WinBlue: + case PSVersion.Win8: + case PSVersion.WinModern: + return Path.Combine( + Environment.ExpandEnvironmentVariables( + (string)Registry.GetValue( + @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform", + "TokenStore", + string.Empty + ) + ), + "data.dat" + ); + default: + return ""; + } + } + + public static string GetTokensPath(PSVersion version) + { + switch (version) + { + case PSVersion.Win7: + return Path.Combine( + Environment.ExpandEnvironmentVariables("%WINDIR%"), + @"ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\tokens.dat" + ); + case PSVersion.Win8Early: + case PSVersion.WinBlue: + case PSVersion.Win8: + case PSVersion.WinModern: + return Path.Combine( + Environment.ExpandEnvironmentVariables( + (string)Registry.GetValue( + @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform", + "TokenStore", + string.Empty + ) + ), + "tokens.dat" + ); + default: + return ""; + } + } + + public static IPhysicalStore GetStore(PSVersion version, bool production) + { + string psPath; + + try + { + psPath = GetPSPath(version); + } + catch + { + throw new FileNotFoundException("Failed to get path of physical store."); + } + + if (string.IsNullOrEmpty(psPath) || !File.Exists(psPath)) + { + throw new FileNotFoundException(string.Format("Physical store not found at expected path {0}.", psPath)); + } + + if (version == PSVersion.Vista) + { + throw new NotSupportedException("Physical store editing is not supported for Windows Vista."); + } + + return version == PSVersion.Win7 ? new PhysicalStoreWin7(psPath, production) : (IPhysicalStore)new PhysicalStoreModern(psPath, production, version); + } + + public static ITokenStore GetTokenStore(PSVersion version) + { + string tokPath; + + try + { + tokPath = GetTokensPath(version); + } + catch + { + throw new FileNotFoundException("Failed to get path of physical store."); + } + + if (string.IsNullOrEmpty(tokPath) || !File.Exists(tokPath)) + { + throw new FileNotFoundException(string.Format("Token store not found at expected path {0}.", tokPath)); + } + + return new TokenStoreModern(tokPath); + } + public static string GetArchitecture() { string arch = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", EnvironmentVariableTarget.Machine).ToUpperInvariant(); @@ -6619,7 +5325,65 @@ namespace LibTSforge if (build >= 7600 && build <= 7602) return PSVersion.Win7; if (build == 9200) return PSVersion.Win8; - throw new NotSupportedException("Unable to auto-detect version info"); + throw new NotSupportedException("Unable to auto-detect version info, please specify one manually using the /ver argument."); + } + + public static bool DetectCurrentKey() + { + SLApi.RefreshLicenseStatus(); + + using (RegistryKey wpaKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\WPA")) + { + foreach (string subKey in wpaKey.GetSubKeyNames()) + { + if (subKey.StartsWith("8DEC0AF1") && subKey.EndsWith("-1")) + { + return subKey.Contains("P"); + } + } + } + + throw new FileNotFoundException("Failed to autodetect key type, specify physical store key with /prod or /test arguments."); + } + + public static void DumpStore(PSVersion version, bool production, string filePath, string encrFilePath) + { + if (encrFilePath == null) + { + encrFilePath = GetPSPath(version); + } + + if (string.IsNullOrEmpty(encrFilePath) || !File.Exists(encrFilePath)) + { + throw new FileNotFoundException("Store does not exist at expected path '" + encrFilePath + "'."); + } + + KillSPP(); + + using (FileStream fs = File.Open(encrFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)) + { + byte[] encrData = fs.ReadAllBytes(); + File.WriteAllBytes(filePath, PhysStoreCrypto.DecryptPhysicalStore(encrData, production)); + } + + Logger.WriteLine("Store dumped successfully to '" + filePath + "'."); + } + + public static void LoadStore(PSVersion version, bool production, string filePath) + { + if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) + { + throw new FileNotFoundException("Store file '" + filePath + "' does not exist."); + } + + KillSPP(); + + using (IPhysicalStore store = GetStore(version, production)) + { + store.WriteRaw(File.ReadAllBytes(filePath)); + } + + Logger.WriteLine("Loaded store file succesfully."); } } @@ -6635,7 +5399,7 @@ namespace LibTSforge } -// LibTSforge/SPP/PKeyConfig.cs +// SPP/PKeyConfig.cs namespace LibTSforge.SPP { using System; @@ -6661,7 +5425,7 @@ namespace LibTSforge.SPP public bool Contains(int n) { - return Start <= n && n <= End; + return Start <= n && End <= n; } } @@ -6712,8 +5476,8 @@ namespace LibTSforge.SPP public class PKeyConfig { - public readonly Dictionary Products = new Dictionary(); - private readonly List loadedPkeyConfigs = new List(); + public Dictionary Products = new Dictionary(); + private List loadedPkeyConfigs = new List(); public void LoadConfig(Guid actId) { @@ -6774,14 +5538,12 @@ namespace LibTSforge.SPP ranges[refActIdStr] = new List(); } - KeyRange keyRange = new KeyRange - { - Start = int.Parse(rangeNode.SelectSingleNode("./p:Start", nsmgr).InnerText), - End = int.Parse(rangeNode.SelectSingleNode("./p:End", nsmgr).InnerText), - EulaType = rangeNode.SelectSingleNode("./p:EulaType", nsmgr).InnerText, - PartNumber = rangeNode.SelectSingleNode("./p:PartNumber", nsmgr).InnerText, - Valid = rangeNode.SelectSingleNode("./p:IsValid", nsmgr).InnerText.ToLower() == "true" - }; + KeyRange keyRange = new KeyRange(); + keyRange.Start = int.Parse(rangeNode.SelectSingleNode("./p:Start", nsmgr).InnerText); + keyRange.End = int.Parse(rangeNode.SelectSingleNode("./p:End", nsmgr).InnerText); + keyRange.EulaType = rangeNode.SelectSingleNode("./p:EulaType", nsmgr).InnerText; + keyRange.PartNumber = rangeNode.SelectSingleNode("./p:PartNumber", nsmgr).InnerText; + keyRange.Valid = rangeNode.SelectSingleNode("./p:IsValid", nsmgr).InnerText.ToLower() == "true"; ranges[refActIdStr].Add(keyRange); } @@ -6791,30 +5553,19 @@ 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, - Edition = configNode.SelectSingleNode("./p:EditionId", nsmgr).InnerText, - 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, - Ranges = keyRanges, - ActivationId = refActId - }; + ProductConfig productConfig = new ProductConfig(); + productConfig.GroupId = group; + productConfig.Edition = configNode.SelectSingleNode("./p:EditionId", nsmgr).InnerText; + productConfig.Description = configNode.SelectSingleNode("./p:ProductDescription", nsmgr).InnerText; + productConfig.Channel = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText; + productConfig.Randomized = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText.ToLower() == "true"; + productConfig.Algorithm = algorithms[group]; + productConfig.Ranges = keyRanges; + productConfig.ActivationId = refActId; Products[refActId] = productConfig; } @@ -6857,18 +5608,23 @@ namespace LibTSforge.SPP } } } + + public PKeyConfig() + { + + } } } -// LibTSforge/SPP/ProductKey.cs +// SPP/ProductKey.cs namespace LibTSforge.SPP { using System; using System.IO; using System.Linq; - using Crypto; - using PhysicalStore; + using LibTSforge.Crypto; + using LibTSforge.PhysicalStore; public class ProductKey { @@ -6882,11 +5638,11 @@ namespace LibTSforge.SPP public ulong Security; public bool Upgrade; public PKeyAlgorithm Algorithm; - public readonly string EulaType; - public readonly string PartNumber; - public readonly string Edition; - public readonly string Channel; - public readonly Guid ActivationId; + public string EulaType; + public string PartNumber; + public string Edition; + public string Channel; + public Guid ActivationId; private string mpc; private string pid2; @@ -6896,11 +5652,6 @@ namespace LibTSforge.SPP get { return BitConverter.GetBytes(klow).Concat(BitConverter.GetBytes(khigh)).ToArray(); } } - public ProductKey() - { - - } - public ProductKey(int serial, ulong security, bool upgrade, PKeyAlgorithm algorithm, ProductConfig config, KeyRange range) { Group = config.GroupId; @@ -6929,22 +5680,22 @@ namespace LibTSforge.SPP public Guid GetPkeyId() { - VariableBag pkb = new VariableBag(PSVersion.WinModern); - pkb.Blocks.AddRange(new[] + VariableBag pkb = new VariableBag(); + pkb.Blocks.AddRange(new CRCBlock[] { - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyBindingProductKey", ValueAsStr = ToString() }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = "SppPkeyBindingMiscData", Value = new byte[] { } }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyBindingAlgorithm", @@ -6955,6 +5706,16 @@ namespace LibTSforge.SPP return new Guid(CryptoUtils.SHA256Hash(pkb.Serialize()).Take(16).ToArray()); } + public string GetDefaultMPC() + { + int build = Environment.OSVersion.Version.Build; + string defaultMPC = build >= 10240 ? "03612" : + build >= 9600 ? "06401" : + build >= 9200 ? "05426" : + "55041"; + return defaultMPC; + } + public string GetMPC() { if (mpc != null) @@ -6962,15 +5723,10 @@ namespace LibTSforge.SPP return mpc; } - int build = Environment.OSVersion.Version.Build; - - mpc = build >= 10240 ? "03612" : - build >= 9600 ? "06401" : - build >= 9200 ? "05426" : - "55041"; + mpc = GetDefaultMPC(); // setup.cfg doesn't exist in Windows 8+ - string setupcfg = string.Format(@"{0}\oobe\{1}", Environment.SystemDirectory, "setup.cfg"); + string setupcfg = string.Format("{0}\\oobe\\{1}", Environment.SystemDirectory, "setup.cfg"); if (!File.Exists(setupcfg) || Edition.Contains(";")) { @@ -7108,17 +5864,17 @@ namespace LibTSforge.SPP { if (version == PSVersion.Win7) { - ulong shortauth = ((ulong)Group << 41) | (Security << 31) | ((ulong)Serial << 1) | (Upgrade ? (ulong)1 : 0); - return BitConverter.GetBytes(shortauth); + Random rnd = new Random(Group * 1000000000 + Serial); + byte[] data = new byte[8]; + rnd.NextBytes(data); + return data; } int serialHigh = Serial / 1000000; int serialLow = Serial % 1000000; BinaryWriter writer = new BinaryWriter(new MemoryStream()); - string algoId = Algorithm == PKeyAlgorithm.PKEY2005 ? "B8731595-A2F6-430B-A799-FBFFB81A8D73" : "660672EF-7809-4CFD-8D54-41B7FB738988"; - - writer.Write(new Guid(algoId).ToByteArray()); + writer.Write(new Guid("B8731595-A2F6-430B-A799-FBFFB81A8D73").ToByteArray()); writer.Write(Group); writer.Write(serialHigh); writer.Write(serialLow); @@ -7177,7 +5933,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/SLAPI.cs +// SPP/SLAPI.cs namespace LibTSforge.SPP { using System; @@ -7224,40 +5980,40 @@ namespace LibTSforge.SPP public static readonly Guid WINDOWS_APP_ID = new Guid("55c92734-d682-4d71-983e-d6ec3f16059f"); - [DllImport("slc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] private static extern void SLOpen(out IntPtr hSLC); - [DllImport("slc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] private static extern void SLClose(IntPtr hSLC); [DllImport("slc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetWindowsInformationDWORD(string ValueName, ref int Value); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLInstallProofOfPurchase(IntPtr hSLC, string pwszPKeyAlgorithm, string pwszPKeyString, uint cbPKeySpecificData, byte[] pbPKeySpecificData, ref Guid PKeyId); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLUninstallProofOfPurchase(IntPtr hSLC, ref Guid PKeyId); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetPKeyInformation(IntPtr hSLC, ref Guid pPKeyId, string pwszValueName, out SLDATATYPE peDataType, out uint pcbValue, out IntPtr ppbValue); - [DllImport("slcext.dll", CharSet = CharSet.Unicode)] + [DllImport("sppcext.dll", CharSet = CharSet.Unicode)] private static extern uint SLActivateProduct(IntPtr hSLC, ref Guid pProductSkuId, byte[] cbAppSpecificData, byte[] pvAppSpecificData, byte[] pActivationInfo, string pwszProxyServer, ushort wProxyPort); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGenerateOfflineInstallationId(IntPtr hSLC, ref Guid pProductSkuId, ref string ppwszInstallationId); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLDepositOfflineConfirmationId(IntPtr hSLC, ref Guid pProductSkuId, string pwszInstallationId, string pwszConfirmationId); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetSLIDList(IntPtr hSLC, SLIDTYPE eQueryIdType, ref Guid pQueryId, SLIDTYPE eReturnIdType, out uint pnReturnIds, out IntPtr ppReturnIds); - [DllImport("slc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] private static extern void SLGetLicensingStatusInformation(IntPtr hSLC, ref Guid pAppID, IntPtr pProductSkuId, string pwszRightName, out uint pnStatusCount, out IntPtr ppLicensingStatus); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetInstalledProductKeyIds(IntPtr hSLC, ref Guid pProductSkuId, out uint pnProductKeyIds, out IntPtr ppProductKeyIds); [DllImport("slc.dll", CharSet = CharSet.Unicode)] @@ -7266,6 +6022,9 @@ namespace LibTSforge.SPP [DllImport("slc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetProductSkuInformation(IntPtr hSLC, ref Guid pProductSkuId, string pwszValueName, out SLDATATYPE peDataType, out uint pcbValue, out IntPtr ppbValue); + [DllImport("slc.dll", CharSet = CharSet.Unicode)] + private static extern uint SLGetProductSkuInformation(IntPtr hSLC, ref Guid pProductSkuId, string pwszValueName, IntPtr peDataType, out uint pcbValue, out IntPtr ppbValue); + [DllImport("slc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetLicense(IntPtr hSLC, ref Guid pLicenseFileId, out uint pcbLicenseFile, out IntPtr ppbLicenseFile); @@ -7275,7 +6034,7 @@ namespace LibTSforge.SPP [DllImport("slc.dll", CharSet = CharSet.Unicode)] private static extern uint SLFireEvent(IntPtr hSLC, string pwszEventId, ref Guid pApplicationId); - private class SLContext : IDisposable + public class SLContext : IDisposable { public readonly IntPtr Handle; @@ -7338,10 +6097,11 @@ namespace LibTSforge.SPP { using (SLContext sl = new SLContext()) { + uint status; uint count; IntPtr pProductKeyIds; - uint status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_PRODUCT_SKU, ref actId, SLIDTYPE.SL_ID_PKEY, out count, out pProductKeyIds); + status = SLGetInstalledProductKeyIds(sl.Handle, ref actId, out count, out pProductKeyIds); if (status != 0 || count == 0) { @@ -7365,7 +6125,7 @@ namespace LibTSforge.SPP SLConsumeWindowsRight(0); } - public static void RefreshTrustedTime(Guid actId) + public static bool RefreshTrustedTime(Guid actId) { using (SLContext sl = new SLContext()) { @@ -7373,7 +6133,8 @@ namespace LibTSforge.SPP uint count; IntPtr ppbValue; - SLGetProductSkuInformation(sl.Handle, ref actId, "TrustedTime", out type, out count, out ppbValue); + uint status = SLGetProductSkuInformation(sl.Handle, ref actId, "TrustedTime", out type, out count, out ppbValue); + return (int)status >= 0 && status != 0xC004F012; } } @@ -7389,10 +6150,11 @@ namespace LibTSforge.SPP { using (SLContext sl = new SLContext()) { + uint status; uint count; IntPtr pAppIds; - uint status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_PRODUCT_SKU, ref actId, SLIDTYPE.SL_ID_APPLICATION, out count, out pAppIds); + status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_PRODUCT_SKU, ref actId, SLIDTYPE.SL_ID_APPLICATION, out count, out pAppIds); if (status != 0 || count == 0) { @@ -7420,10 +6182,11 @@ namespace LibTSforge.SPP { using (SLContext sl = new SLContext()) { + uint status; uint count; IntPtr ppReturnLics; - uint status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_LICENSE, ref licId, SLIDTYPE.SL_ID_LICENSE_FILE, out count, out ppReturnLics); + status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_LICENSE, ref licId, SLIDTYPE.SL_ID_LICENSE_FILE, out count, out ppReturnLics); if (status != 0 || count == 0) { @@ -7485,7 +6248,7 @@ namespace LibTSforge.SPP IntPtr ppbValue; uint status = SLGetProductSkuInformation(sl.Handle, ref actId, "msft:sl/EUL/PHONE/PUBLIC", out type, out count, out ppbValue); - return status != 0xC004F012; + return status >= 0 && status != 0xC004F012; } } @@ -7568,11 +6331,11 @@ namespace LibTSforge.SPP } } - public static void UninstallProductKey(Guid pkeyId) + public static uint UninstallProductKey(Guid pkeyId) { using (SLContext sl = new SLContext()) { - SLUninstallProofOfPurchase(sl.Handle, ref pkeyId); + return SLUninstallProofOfPurchase(sl.Handle, ref pkeyId); } } @@ -7590,391 +6353,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/SPPUtils.cs -namespace LibTSforge.SPP -{ - using Microsoft.Win32; - using System; - using System.IO; - using System.Linq; - using System.ServiceProcess; - using Crypto; - using PhysicalStore; - using TokenStore; - - public static class SPPUtils - { - public static void KillSPP(PSVersion version) - { - ServiceController sc; - - string svcName = version == PSVersion.Vista ? "slsvc" : "sppsvc"; - - try - { - sc = new ServiceController(svcName); - - if (sc.Status == ServiceControllerStatus.Stopped) - return; - } - catch (InvalidOperationException ex) - { - throw new InvalidOperationException(string.Format("Unable to access {0}: ", svcName) + ex.Message); - } - - Logger.WriteLine(string.Format("Stopping {0}...", svcName)); - - bool stopped = false; - - for (int i = 0; stopped == false && i < 1080; i++) - { - try - { - if (sc.Status != ServiceControllerStatus.StopPending) - sc.Stop(); - - sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMilliseconds(500)); - } - catch (System.ServiceProcess.TimeoutException) - { - continue; - } - catch (InvalidOperationException ex) - { - Logger.WriteLine("Warning: Stopping sppsvc failed, retrying. Details: " + ex.Message); - System.Threading.Thread.Sleep(500); - continue; - } - - stopped = true; - } - - if (!stopped) - throw new System.TimeoutException(string.Format("Failed to stop {0}", svcName)); - - Logger.WriteLine(string.Format("{0} stopped successfully.", svcName)); - - if (version == PSVersion.Vista && SPSys.IsSpSysRunning()) - { - Logger.WriteLine("Unloading spsys..."); - - int status = SPSys.ControlSpSys(false); - - if (status < 0) - { - throw new IOException("Failed to unload spsys"); - } - - Logger.WriteLine("spsys unloaded successfully."); - } - } - - public static void RestartSPP(PSVersion version) - { - if (version == PSVersion.Vista) - { - ServiceController sc; - - try - { - sc = new ServiceController("slsvc"); - - if (sc.Status == ServiceControllerStatus.Running) - return; - } - catch (InvalidOperationException ex) - { - throw new InvalidOperationException("Unable to access slsvc: " + ex.Message); - } - - Logger.WriteLine("Starting slsvc..."); - - bool started = false; - - for (int i = 0; started == false && i < 360; i++) - { - try - { - if (sc.Status != ServiceControllerStatus.StartPending) - sc.Start(); - - sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromMilliseconds(500)); - } - catch (System.ServiceProcess.TimeoutException) - { - continue; - } - catch (InvalidOperationException ex) - { - Logger.WriteLine("Warning: Starting slsvc failed, retrying. Details: " + ex.Message); - System.Threading.Thread.Sleep(500); - continue; - } - - started = true; - } - - if (!started) - throw new System.TimeoutException("Failed to start slsvc"); - - Logger.WriteLine("slsvc started successfully."); - } - - SLApi.RefreshLicenseStatus(); - } - - public static bool DetectCurrentKey() - { - SLApi.RefreshLicenseStatus(); - - using (RegistryKey wpaKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\WPA")) - { - foreach (string subKey in wpaKey.GetSubKeyNames()) - { - if (subKey.StartsWith("8DEC0AF1")) - { - return subKey.Contains("P"); - } - } - } - - throw new FileNotFoundException("Failed to autodetect key type, specify physical store key with /prod or /test arguments."); - } - - public static string GetPSPath(PSVersion version) - { - switch (version) - { - case PSVersion.Vista: - case PSVersion.Win7: - return Directory.GetFiles( - Environment.GetFolderPath(Environment.SpecialFolder.System), - "7B296FB0-376B-497e-B012-9C450E1B7327-*.C7483456-A289-439d-8115-601632D005A0") - .FirstOrDefault() ?? ""; - default: - string psDir = Environment.ExpandEnvironmentVariables( - (string)Registry.GetValue( - @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform", - "TokenStore", - "" - ) - ); - string psPath = Path.Combine(psDir, "data.dat"); - - if (string.IsNullOrEmpty(psDir) || !File.Exists(psPath)) - { - string[] psDirs = - { - @"spp\store", - @"spp\store\2.0", - @"spp\store_test", - @"spp\store_test\2.0" - }; - - foreach (string dir in psDirs) - { - psPath = Path.Combine( - Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.System), - dir - ), - "data.dat" - ); - - if (File.Exists(psPath)) return psPath; - } - } - else - { - return psPath; - } - - throw new FileNotFoundException("Failed to locate physical store."); - } - } - - public static string GetTokensPath(PSVersion version) - { - switch (version) - { - case PSVersion.Vista: - return Path.Combine( - Environment.ExpandEnvironmentVariables("%WINDIR%"), - @"ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareLicensing\tokens.dat" - ); - case PSVersion.Win7: - return Path.Combine( - Environment.ExpandEnvironmentVariables("%WINDIR%"), - @"ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\tokens.dat" - ); - default: - string tokDir = Environment.ExpandEnvironmentVariables( - (string)Registry.GetValue( - @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform", - "TokenStore", - "" - ) - ); - string tokPath = Path.Combine(tokDir, "tokens.dat"); - - if (string.IsNullOrEmpty(tokDir) || !File.Exists(tokPath)) - { - string[] tokDirs = - { - @"spp\store", - @"spp\store\2.0", - @"spp\store_test", - @"spp\store_test\2.0" - }; - - foreach (string dir in tokDirs) - { - tokPath = Path.Combine( - Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.System), - dir - ), - "tokens.dat" - ); - - if (File.Exists(tokPath)) return tokPath; - } - } - else - { - return tokPath; - } - - throw new FileNotFoundException("Failed to locate token store."); - } - } - - public static IPhysicalStore GetStore(PSVersion version, bool production) - { - string psPath = GetPSPath(version); - - switch (version) - { - case PSVersion.Vista: - return new PhysicalStoreVista(psPath, production); - case PSVersion.Win7: - return new PhysicalStoreWin7(psPath, production); - default: - return new PhysicalStoreModern(psPath, production, version); - } - } - - public static ITokenStore GetTokenStore(PSVersion version) - { - string tokPath = GetTokensPath(version); - - return new TokenStoreModern(tokPath); - } - - public static void DumpStore(PSVersion version, bool production, string filePath, string encrFilePath) - { - bool manageSpp = false; - - if (encrFilePath == null) - { - encrFilePath = GetPSPath(version); - manageSpp = true; - KillSPP(version); - } - - if (string.IsNullOrEmpty(encrFilePath) || !File.Exists(encrFilePath)) - { - throw new FileNotFoundException("Store does not exist at expected path '" + encrFilePath + "'."); - } - - try - { - using (FileStream fs = File.Open(encrFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - byte[] encrData = fs.ReadAllBytes(); - File.WriteAllBytes(filePath, PhysStoreCrypto.DecryptPhysicalStore(encrData, production, version)); - } - Logger.WriteLine("Store dumped successfully to '" + filePath + "'."); - } - finally - { - if (manageSpp) - { - RestartSPP(version); - } - } - } - - public static void LoadStore(PSVersion version, bool production, string filePath) - { - if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) - { - throw new FileNotFoundException("Store file '" + filePath + "' does not exist."); - } - - KillSPP(version); - - using (IPhysicalStore store = GetStore(version, production)) - { - store.WriteRaw(File.ReadAllBytes(filePath)); - } - - RestartSPP(version); - - Logger.WriteLine("Loaded store file successfully."); - } - } -} - - -// LibTSforge/SPP/SPSys.cs -namespace LibTSforge.SPP -{ - using Microsoft.Win32.SafeHandles; - using System; - using System.Runtime.InteropServices; - - public class SPSys - { - [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] - private static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile); - private static SafeFileHandle CreateFileSafe(string device) - { - return new SafeFileHandle(CreateFile(device, 0xC0000000, 0, IntPtr.Zero, 3, 0, IntPtr.Zero), true); - } - - [return: MarshalAs(UnmanagedType.Bool)] - [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] - private static extern bool DeviceIoControl([In] SafeFileHandle hDevice, [In] uint dwIoControlCode, [In] IntPtr lpInBuffer, [In] int nInBufferSize, [Out] IntPtr lpOutBuffer, [In] int nOutBufferSize, out int lpBytesReturned, [In] IntPtr lpOverlapped); - - public static bool IsSpSysRunning() - { - SafeFileHandle file = CreateFileSafe(@"\\.\SpDevice"); - IntPtr buffer = Marshal.AllocHGlobal(1); - int bytesReturned; - DeviceIoControl(file, 0x80006008, IntPtr.Zero, 0, buffer, 1, out bytesReturned, IntPtr.Zero); - bool running = Marshal.ReadByte(buffer) != 0; - Marshal.FreeHGlobal(buffer); - file.Close(); - return running; - } - - public static int ControlSpSys(bool start) - { - SafeFileHandle file = CreateFileSafe(@"\\.\SpDevice"); - IntPtr buffer = Marshal.AllocHGlobal(4); - int bytesReturned; - DeviceIoControl(file, start ? 0x8000a000 : 0x8000a004, IntPtr.Zero, 0, buffer, 4, out bytesReturned, IntPtr.Zero); - int result = Marshal.ReadInt32(buffer); - Marshal.FreeHGlobal(buffer); - file.Close(); - return result; - } - } -} - - -// LibTSforge/Crypto/CryptoUtils.cs +// Crypto/CryptoUtils.cs namespace LibTSforge.Crypto { using System; @@ -8083,21 +6462,10 @@ namespace LibTSforge.Crypto public static bool HMACVerify(byte[] key, byte[] data, byte[] signature) { + HMACSHA1 hmac = new HMACSHA1(key); return Enumerable.SequenceEqual(signature, HMACSign(key, data)); } - public static byte[] SaltSHASum(byte[] salt, byte[] data) - { - SHA1 sha1 = SHA1.Create(); - byte[] sha_data = salt.Concat(data).ToArray(); - return sha1.ComputeHash(sha_data); - } - - public static bool SaltSHAVerify(byte[] salt, byte[] data, byte[] checksum) - { - return Enumerable.SequenceEqual(checksum, SaltSHASum(salt, data)); - } - public static byte[] SHA256Hash(byte[] data) { using (SHA256 sha256 = SHA256.Create()) @@ -8109,7 +6477,7 @@ namespace LibTSforge.Crypto } -// LibTSforge/Crypto/Keys.cs +// Crypto/Keys.cs namespace LibTSforge.Crypto { public static class Keys @@ -8199,7 +6567,7 @@ namespace LibTSforge.Crypto } -// LibTSforge/Crypto/PhysStoreCrypto.cs +// Crypto/PhysStoreCrypto.cs namespace LibTSforge.Crypto { using System; @@ -8210,7 +6578,7 @@ namespace LibTSforge.Crypto public static class PhysStoreCrypto { - public static byte[] DecryptPhysicalStore(byte[] data, bool production, PSVersion version) + public static byte[] DecryptPhysicalStore(byte[] data, bool production) { byte[] rsaKey = production ? Keys.PRODUCTION : Keys.TEST; BinaryReader br = new BinaryReader(new MemoryStream(data)); @@ -8218,40 +6586,29 @@ namespace LibTSforge.Crypto byte[] aesKeySig = br.ReadBytes(0x80); byte[] encAesKey = br.ReadBytes(0x80); - if (!CryptoUtils.RSAVerifySignature(rsaKey, encAesKey, aesKeySig)) + if (CryptoUtils.RSAVerifySignature(rsaKey, encAesKey, aesKeySig)) { - throw new Exception("Failed to decrypt physical store."); - } + byte[] aesKey = CryptoUtils.RSADecrypt(rsaKey, encAesKey); + byte[] decData = CryptoUtils.AESDecrypt(br.ReadBytes((int)br.BaseStream.Length - 0x110), aesKey); + byte[] hmacKey = decData.Take(0x10).ToArray(); + byte[] hmacSig = decData.Skip(0x10).Take(0x14).ToArray(); + byte[] psData = decData.Skip(0x28).ToArray(); - byte[] aesKey = CryptoUtils.RSADecrypt(rsaKey, encAesKey); - byte[] decData = CryptoUtils.AESDecrypt(br.ReadBytes((int)br.BaseStream.Length - 0x110), aesKey); - byte[] hmacKey = decData.Take(0x10).ToArray(); // SHA-1 salt on Vista - byte[] hmacSig = decData.Skip(0x10).Take(0x14).ToArray(); // SHA-1 hash on Vista - byte[] psData = decData.Skip(0x28).ToArray(); - - if (version != PSVersion.Vista) - { if (!CryptoUtils.HMACVerify(hmacKey, psData, hmacSig)) { - throw new InvalidDataException("Failed to verify HMAC. Physical store is corrupt."); - } - } - else - { - if (!CryptoUtils.SaltSHAVerify(hmacKey, psData, hmacSig)) - { - throw new InvalidDataException("Failed to verify checksum. Physical store is corrupt."); + Logger.WriteLine("Warning: Failed to verify HMAC. Physical store is either corrupt or in Vista format."); } + + return psData; } - return psData; + throw new Exception("Failed to decrypt physical store."); } public static byte[] EncryptPhysicalStore(byte[] data, bool production, PSVersion version) { Dictionary versionTable = new Dictionary { - {PSVersion.Vista, 2}, {PSVersion.Win7, 5}, {PSVersion.Win8, 1}, {PSVersion.WinBlue, 2}, @@ -8265,9 +6622,9 @@ namespace LibTSforge.Crypto byte[] encAesKey = CryptoUtils.RSAEncrypt(rsaKey, aesKey); byte[] aesKeySig = CryptoUtils.RSASign(rsaKey, encAesKey); - byte[] hmacSig = version != PSVersion.Vista ? CryptoUtils.HMACSign(hmacKey, data) : CryptoUtils.SaltSHASum(hmacKey, data); + byte[] hmacSig = CryptoUtils.HMACSign(hmacKey, data); - byte[] decData = { }; + byte[] decData = new byte[] { }; decData = decData.Concat(hmacKey).Concat(hmacSig).Concat(BitConverter.GetBytes(0)).Concat(data).ToArray(); byte[] encData = CryptoUtils.AESEncrypt(decData, aesKey); @@ -8284,15 +6641,15 @@ namespace LibTSforge.Crypto } -// LibTSforge/Modifiers/GenPKeyInstall.cs +// Modifiers/GenPKeyInstall.cs namespace LibTSforge.Modifiers { using System; using System.IO; using Microsoft.Win32; - using PhysicalStore; - using SPP; - using TokenStore; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; + using LibTSforge.TokenStore; public static class GenPKeyInstall { @@ -8318,7 +6675,6 @@ namespace LibTSforge.Modifiers public static void InstallGenPKey(PSVersion version, bool production, Guid actId) { - if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008."); if (actId == Guid.Empty) throw new ArgumentException("Activation ID must be specified for generated product key install."); PKeyConfig pkc = new PKeyConfig(); @@ -8345,7 +6701,7 @@ namespace LibTSforge.Modifiers if (pkey.Algorithm == PKeyAlgorithm.PKEY2009) { uint status = SLApi.InstallProductKey(pkey); - Logger.WriteLine(string.Format("Installing generated product key {0} status {1:X}", pkey, status)); + Logger.WriteLine(string.Format("Installing generated product key {0} status {1:X}", pkey.ToString(), status)); if ((int)status < 0) { @@ -8360,57 +6716,57 @@ namespace LibTSforge.Modifiers if (pkey.Channel == "Volume:GVLK" && version == PSVersion.Win7) throw new NotSupportedException("Fake GVLK generation is not supported on Windows 7."); - VariableBag pkb = new VariableBag(version); - pkb.Blocks.AddRange(new[] + VariableBag pkb = new VariableBag(); + pkb.Blocks.AddRange(new CRCBlock[] { - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyBindingProductKey", ValueAsStr = pkey.ToString() }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyBindingMPC", ValueAsStr = pkey.GetMPC() }, - new CRCBlockModern { + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = "SppPkeyBindingPid2", ValueAsStr = pkey.GetPid2() }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = "SppPkeyBindingPid3", Value = pkey.GetPid3() }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = "SppPkeyBindingPid4", Value = pkey.GetPid4() }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyChannelId", ValueAsStr = pkey.Channel }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyBindingEditionId", ValueAsStr = pkey.Edition }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = (version == PSVersion.Win7) ? "SppPkeyShortAuthenticator" : "SppPkeyPhoneActivationData", Value = pkey.GetPhoneData(version) }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = "SppPkeyBindingMiscData", @@ -8428,11 +6784,11 @@ namespace LibTSforge.Modifiers SLApi.UninstallAllProductKeys(appId); } - SPPUtils.KillSPP(version); + Utils.KillSPP(); - using (IPhysicalStore ps = SPPUtils.GetStore(version, production)) + using (IPhysicalStore ps = Utils.GetStore(version, production)) { - using (ITokenStore tks = SPPUtils.GetTokenStore(version)) + using (ITokenStore tks = Utils.GetTokenStore(version)) { Logger.WriteLine("Writing to physical store and token store..."); @@ -8456,7 +6812,7 @@ namespace LibTSforge.Modifiers uriMap.Data[pkeyId] = pkey.GetAlgoUri(); tks.SetEntry(uriMapName, "xml", uriMap.Serialize()); - string skuMetaName = actId + metSuffix; + string skuMetaName = actId.ToString() + metSuffix; TokenMeta skuMeta = tks.GetMetaEntry(skuMetaName); foreach (string k in skuMeta.Data.Keys) @@ -8483,7 +6839,7 @@ namespace LibTSforge.Modifiers Data = pkb.Serialize() }); - string cachePath = SPPUtils.GetTokensPath(version).Replace("tokens.dat", @"cache\cache.dat"); + string cachePath = Utils.GetTokensPath(version).Replace("tokens.dat", @"cache\cache.dat"); if (File.Exists(cachePath)) File.Delete(cachePath); } } @@ -8495,22 +6851,22 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/GracePeriodReset.cs +// Modifiers/GracePeriodReset.cs namespace LibTSforge.Modifiers { + using System; using System.Collections.Generic; using System.Linq; - using PhysicalStore; - using SPP; + using LibTSforge.PhysicalStore; public static class GracePeriodReset { public static void Reset(PSVersion version, bool production) { - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { string value = "msft:sl/timer"; List blocks = store.FindBlocks(value).ToList(); @@ -8521,31 +6877,26 @@ namespace LibTSforge.Modifiers } } - SPPUtils.RestartSPP(version); Logger.WriteLine("Successfully reset all grace and evaluation period timers."); } } } -// LibTSforge/Modifiers/KeyChangeLockDelete.cs +// Modifiers/KeyChangeLockDelete.cs namespace LibTSforge.Modifiers { using System.Collections.Generic; using System.Linq; - using PhysicalStore; - using SPP; - using System; - + using LibTSforge.PhysicalStore; + using LibTSforge; public static class KeyChangeLockDelete { public static void Delete(PSVersion version, bool production) { - if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008."); - - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { List values = new List { @@ -8568,17 +6919,17 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/KMSHostCharge.cs +// Modifiers/KMSHostCharge.cs namespace LibTSforge.Modifiers { using System; using System.IO; - using PhysicalStore; - using SPP; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; public static class KMSHostCharge { - public static void Charge(PSVersion version, bool production, Guid actId) + public static void Charge(PSVersion version, Guid actId, bool production) { if (actId == Guid.Empty) { @@ -8602,113 +6953,76 @@ namespace LibTSforge.Modifiers string key = string.Format("SPPSVC\\{0}", appId); long ldapTimestamp = DateTime.Now.ToFileTime(); - byte[] cmidGuids = { }; - byte[] reqCounts = { }; - byte[] kmsChargeData = { }; - BinaryWriter writer = new BinaryWriter(new MemoryStream()); - if (version == PSVersion.Vista) + for (int i = 0; i < currClients; i++) { - writer.Write(new byte[44]); - writer.Seek(0, SeekOrigin.Begin); - - writer.Write(totalClients); - writer.Write(43200); - writer.Write(32); - - writer.Seek(20, SeekOrigin.Begin); - writer.Write((byte)currClients); - - writer.Seek(32, SeekOrigin.Begin); - writer.Write((byte)currClients); - - writer.Seek(0, SeekOrigin.End); - - for (int i = 0; i < currClients; i++) - { - writer.Write(Guid.NewGuid().ToByteArray()); - writer.Write(ldapTimestamp - (10 * (i + 1))); - } - - kmsChargeData = writer.GetBytes(); - } - else - { - for (int i = 0; i < currClients; i++) - { - writer.Write(ldapTimestamp - (10 * (i + 1))); - writer.Write(Guid.NewGuid().ToByteArray()); - } - - cmidGuids = writer.GetBytes(); - - writer = new BinaryWriter(new MemoryStream()); - - writer.Write(new byte[40]); - - writer.Seek(4, SeekOrigin.Begin); - writer.Write((byte)currClients); - - writer.Seek(24, SeekOrigin.Begin); - writer.Write((byte)currClients); - - reqCounts = writer.GetBytes(); + writer.Write(ldapTimestamp - (10 * (i + 1))); + writer.Write(Guid.NewGuid().ToByteArray()); } - SPPUtils.KillSPP(version); + byte[] cmidGuids = writer.GetBytes(); + + writer = new BinaryWriter(new MemoryStream()); + + writer.Write(new byte[40]); + + writer.Seek(4, SeekOrigin.Begin); + writer.Write((byte)currClients); + + writer.Seek(24, SeekOrigin.Begin); + writer.Write((byte)currClients); + byte[] reqCounts = writer.GetBytes(); + + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { - if (version != PSVersion.Vista) + VariableBag kmsCountData = new VariableBag(); + kmsCountData.Blocks.AddRange(new CRCBlock[] { - VariableBag kmsCountData = new VariableBag(version); - kmsCountData.Blocks.AddRange(new[] + new CRCBlock { - new CRCBlockModern - { - DataType = CRCBlockType.BINARY, - KeyAsStr = "SppBindingLicenseData", - Value = hwidBlock - }, - new CRCBlockModern - { - DataType = CRCBlockType.UINT, - Key = new byte[] { }, - ValueAsInt = (uint)totalClients - }, - new CRCBlockModern - { - DataType = CRCBlockType.UINT, - Key = new byte[] { }, - ValueAsInt = 1051200000 - }, - new CRCBlockModern - { - DataType = CRCBlockType.UINT, - Key = new byte[] { }, - ValueAsInt = (uint)currClients - }, - new CRCBlockModern - { - DataType = CRCBlockType.BINARY, - Key = new byte[] { }, - Value = cmidGuids - }, - new CRCBlockModern - { - DataType = CRCBlockType.BINARY, - Key = new byte[] { }, - Value = reqCounts - } - }); + DataType = CRCBlockType.BINARY, + KeyAsStr = "SppBindingLicenseData", + Value = hwidBlock + }, + new CRCBlock + { + DataType = CRCBlockType.UINT, + Key = new byte[] { }, + ValueAsInt = (uint)totalClients + }, + new CRCBlock + { + DataType = CRCBlockType.UINT, + Key = new byte[] { }, + ValueAsInt = 1051200000 + }, + new CRCBlock + { + DataType = CRCBlockType.UINT, + Key = new byte[] { }, + ValueAsInt = (uint)currClients + }, + new CRCBlock + { + DataType = CRCBlockType.BINARY, + Key = new byte[] { }, + Value = cmidGuids + }, + new CRCBlock + { + DataType = CRCBlockType.BINARY, + Key = new byte[] { }, + Value = reqCounts + } + }); - kmsChargeData = kmsCountData.Serialize(); - } - - string countVal = version == PSVersion.Vista ? "C8F6FFF1-79CE-404C-B150-F97991273DF1" : string.Format("msft:spp/kms/host/2.0/store/counters/{0}", appId); + byte[] kmsChargeData = kmsCountData.Serialize(); + string countVal = string.Format("msft:spp/kms/host/2.0/store/counters/{0}", appId); store.DeleteBlock(key, countVal); store.AddBlock(new PSBlock @@ -8722,38 +7036,32 @@ namespace LibTSforge.Modifiers Logger.WriteLine(string.Format("Set charge count to {0} successfully.", currClients)); } - - SPPUtils.RestartSPP(version); } } } -// LibTSforge/Modifiers/RearmReset.cs +// Modifiers/RearmReset.cs namespace LibTSforge.Modifiers { + using System; using System.Collections.Generic; using System.Linq; - using PhysicalStore; - using SPP; + using LibTSforge.PhysicalStore; public static class RearmReset { public static void Reset(PSVersion version, bool production) { - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { List blocks; - if (version == PSVersion.Vista) - { - blocks = store.FindBlocks("740D70D8-6448-4b2f-9063-4A7A463600C5").ToList(); - } - else if (version == PSVersion.Win7) + if (version == PSVersion.Win7) { blocks = store.FindBlocks(0xA0000).ToList(); } @@ -8764,11 +7072,7 @@ namespace LibTSforge.Modifiers foreach (PSBlock block in blocks) { - if (version == PSVersion.Vista) - { - store.DeleteBlock(block.KeyAsStr, block.ValueAsStr); - } - else if (version == PSVersion.Win7) + if (version == PSVersion.Win7) { store.SetBlock(block.KeyAsStr, block.ValueAsInt, new byte[8]); } @@ -8785,110 +7089,38 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/SetIIDParams.cs +// Modifiers/TamperedFlagsDelete.cs namespace LibTSforge.Modifiers { - using PhysicalStore; - using SPP; - using System.IO; using System; - - public static class SetIIDParams - { - public static void SetParams(PSVersion version, bool production, Guid actId, PKeyAlgorithm algorithm, int group, int serial, ulong security) - { - if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008."); - - Guid appId; - - if (actId == Guid.Empty) - { - appId = SLApi.WINDOWS_APP_ID; - actId = SLApi.GetDefaultActivationID(appId, true); - - if (actId == Guid.Empty) - { - throw new Exception("No applicable activation IDs found."); - } - } - else - { - appId = SLApi.GetAppId(actId); - } - - Guid pkeyId = SLApi.GetInstalledPkeyID(actId); - - SPPUtils.KillSPP(version); - - Logger.WriteLine("Writing TrustedStore data..."); - - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) - { - string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId); - PSBlock keyBlock = store.GetBlock(key, pkeyId.ToString()); - - if (keyBlock == null) - { - throw new InvalidDataException("Failed to get product key data for activation ID " + actId + "."); - } - - VariableBag pkb = new VariableBag(keyBlock.Data, version); - - ProductKey pkey = new ProductKey - { - Group = group, - Serial = serial, - Security = security, - Algorithm = algorithm, - Upgrade = false - }; - - string blockName = version == PSVersion.Win7 ? "SppPkeyShortAuthenticator" : "SppPkeyPhoneActivationData"; - pkb.SetBlock(blockName, pkey.GetPhoneData(version)); - store.SetBlock(key, pkeyId.ToString(), pkb.Serialize()); - } - - Logger.WriteLine("Successfully set IID parameters."); - } - } -} - - -// LibTSforge/Modifiers/TamperedFlagsDelete.cs -namespace LibTSforge.Modifiers -{ using System.Linq; - using PhysicalStore; - using SPP; + using LibTSforge.PhysicalStore; public static class TamperedFlagsDelete { public static void DeleteTamperFlags(PSVersion version, bool production) { - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { - if (version == PSVersion.Vista) + if (version != PSVersion.Win7) { - DeleteFlag(store, "6BE8425B-E3CF-4e86-A6AF-5863E3DCB606"); - } - else if (version == PSVersion.Win7) - { - SetFlag(store, 0xA0001); + string recreatedFlag = "__##USERSEP-RESERVED##__$$RECREATED-FLAG$$"; + string recoveredFlag = "__##USERSEP-RESERVED##__$$RECOVERED-FLAG$$"; + + DeleteFlag(store, recreatedFlag); + DeleteFlag(store, recoveredFlag); } else { - DeleteFlag(store, "__##USERSEP-RESERVED##__$$RECREATED-FLAG$$"); - DeleteFlag(store, "__##USERSEP-RESERVED##__$$RECOVERED-FLAG$$"); + SetFlag(store, 0xA0001); } Logger.WriteLine("Successfully cleared the tamper state."); } - - SPPUtils.RestartSPP(version); } private static void DeleteFlag(IPhysicalStore store, string flag) @@ -8904,19 +7136,17 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/UniqueIdDelete.cs +// Modifiers/UniqueIdDelete.cs namespace LibTSforge.Modifiers { using System; - using PhysicalStore; - using SPP; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; public static class UniqueIdDelete { public static void DeleteUniqueId(PSVersion version, bool production, Guid actId) { - if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008."); - Guid appId; if (actId == Guid.Empty) @@ -8934,13 +7164,14 @@ namespace LibTSforge.Modifiers appId = SLApi.GetAppId(actId); } + string instId = SLApi.GetInstallationID(actId); Guid pkeyId = SLApi.GetInstalledPkeyID(actId); - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId); PSBlock keyBlock = store.GetBlock(key, pkeyId.ToString()); @@ -8950,7 +7181,7 @@ namespace LibTSforge.Modifiers throw new Exception("No product key found."); } - VariableBag pkb = new VariableBag(keyBlock.Data, version); + VariableBag pkb = new VariableBag(keyBlock.Data); pkb.DeleteBlock("SppPkeyUniqueIdToken"); @@ -8963,230 +7194,18 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Activators/KMS4K.cs +// Activators/ZeroCID.cs namespace LibTSforge.Activators { using System; using System.IO; - using PhysicalStore; - using SPP; - - public class KMS4k - { - public static void Activate(PSVersion version, bool production, Guid actId) - { - Guid appId; - if (actId == Guid.Empty) - { - appId = SLApi.WINDOWS_APP_ID; - actId = SLApi.GetDefaultActivationID(appId, true); - - if (actId == Guid.Empty) - { - throw new NotSupportedException("No applicable activation IDs found."); - } - } - else - { - appId = SLApi.GetAppId(actId); - } - - if (SLApi.GetPKeyChannel(SLApi.GetInstalledPkeyID(actId)) != "Volume:GVLK") - { - throw new NotSupportedException("Non-Volume:GVLK product key installed."); - } - - SPPUtils.KillSPP(version); - - Logger.WriteLine("Writing TrustedStore data..."); - - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) - { - string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId); - - ulong unknown = 0; - ulong time1; - ulong time2 = (ulong)DateTime.UtcNow.ToFileTime(); - ulong expiry = Constants.TimerMax; - - if (version == PSVersion.Vista || version == PSVersion.Win7) - { - 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 - }, - new CRCBlockModern - { - DataType = CRCBlockType.STRING, - Key = new byte[] { }, - ValueAsStr = "msft:rm/algorithm/hwid/4.0" - }, - new CRCBlockModern - { - DataType = CRCBlockType.BINARY, - KeyAsStr = "SppBindingLicenseData", - Value = hwidBlock - } - }); - - 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[] kmsBindingData = kmsBinding.Serialize(); - - Timer kmsTimer = new Timer - { - Unknown = unknown, - Time1 = time1, - Time2 = time2, - Expiry = expiry - }; - - 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.AddBlocks(new[] - { - new PSBlock - { - Type = BlockType.NAMED, - Flags = (version == PSVersion.WinModern) ? (uint)0x400 : 0, - KeyAsStr = key, - ValueAsStr = storeVal, - Data = kmsBindingData - }, - new PSBlock - { - Type = BlockType.TIMER, - Flags = (version == PSVersion.Win7) ? (uint)0 : 0x4, - KeyAsStr = key, - ValueAsStr = timerVal, - Data = kmsTimer.CastToArray() - } - }); - } - } - - SPPUtils.RestartSPP(version); - SLApi.FireStateChangedEvent(appId); - Logger.WriteLine("Activated using KMS4k successfully."); - } - } -} - - -// LibTSforge/Activators/ZeroCID.cs -namespace LibTSforge.Activators -{ - using System; - using System.IO; - using System.Linq; - using Crypto; - using PhysicalStore; - using SPP; + using LibTSforge.Crypto; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; public static class ZeroCID { - private static void Deposit(Guid actId, string instId) + public static void Deposit(Guid actId, string instId) { uint status = SLApi.DepositConfirmationID(actId, instId, Constants.ZeroCID); Logger.WriteLine(string.Format("Depositing fake CID status {0:X}", status)); @@ -9224,16 +7243,16 @@ namespace LibTSforge.Activators string instId = SLApi.GetInstallationID(actId); Guid pkeyId = SLApi.GetInstalledPkeyID(actId); - if (version == PSVersion.Vista || version == PSVersion.Win7) + if (version == PSVersion.Win7) { Deposit(actId, instId); } - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { byte[] hwidBlock = Constants.UniversalHWIDBlock; @@ -9243,11 +7262,7 @@ namespace LibTSforge.Activators byte[] iidHash; - if (version == PSVersion.Vista) - { - iidHash = CryptoUtils.SHA256Hash(Utils.EncodeString(instId)).Take(0x10).ToArray(); - } - else if (version == PSVersion.Win7) + if (version == PSVersion.Win7) { iidHash = CryptoUtils.SHA256Hash(Utils.EncodeString(instId)); } @@ -9264,39 +7279,11 @@ namespace LibTSforge.Activators throw new InvalidDataException("Failed to get product key data for activation ID " + actId + "."); } - VariableBag pkb = new VariableBag(keyBlock.Data, version); + VariableBag pkb = new VariableBag(keyBlock.Data); byte[] pkeyData; - if (version == PSVersion.Vista) - { - pkeyData = pkb.GetBlock("PKeyBasicInfo").Value; - string uniqueId = Utils.DecodeString(pkeyData.Skip(0x120).Take(0x80).ToArray()); - string extPid = Utils.DecodeString(pkeyData.Skip(0x1A0).Take(0x80).ToArray()); - - uint group; - uint.TryParse(extPid.Split('-')[1], out group); - - if (group == 0) - { - throw new FormatException("Extended PID has invalid format."); - } - - ulong shortauth; - - try - { - shortauth = BitConverter.ToUInt64(Convert.FromBase64String(uniqueId.Split('&')[1]), 0); - } - catch - { - throw new FormatException("Key Unique ID has invalid format."); - } - - shortauth |= (ulong)group << 41; - pkeyData = BitConverter.GetBytes(shortauth); - } - else if (version == PSVersion.Win7) + if (version == PSVersion.Win7) { pkeyData = pkb.GetBlock("SppPkeyShortAuthenticator").Value; } @@ -9309,34 +7296,26 @@ namespace LibTSforge.Activators store.SetBlock(key, pkeyId.ToString(), pkb.Serialize()); BinaryWriter writer = new BinaryWriter(new MemoryStream()); - writer.Write(iidHash.Length); + writer.Write(0x20); writer.Write(iidHash); writer.Write(hwidBlock.Length); writer.Write(hwidBlock); byte[] tsHwidData = writer.GetBytes(); writer = new BinaryWriter(new MemoryStream()); - writer.Write(iidHash.Length); + writer.Write(0x20); writer.Write(iidHash); writer.Write(pkeyData.Length); writer.Write(pkeyData); byte[] tsPkeyInfoData = writer.GetBytes(); - string phoneVersion = version == PSVersion.Vista ? "6.0" : "7.0"; - Guid indexSlid = version == PSVersion.Vista ? actId : pkeyId; - string hwidBlockName = string.Format("msft:Windows/{0}/Phone/Cached/HwidBlock/{1}", phoneVersion, indexSlid); - string pkeyInfoName = string.Format("msft:Windows/{0}/Phone/Cached/PKeyInfo/{1}", phoneVersion, indexSlid); - - store.DeleteBlock(key, hwidBlockName); - store.DeleteBlock(key, pkeyInfoName); - - store.AddBlocks(new[] { + store.AddBlocks(new PSBlock[] { new PSBlock { Type = BlockType.NAMED, Flags = 0, KeyAsStr = key, - ValueAsStr = hwidBlockName, + ValueAsStr = "msft:Windows/7.0/Phone/Cached/HwidBlock/" + pkeyId, Data = tsHwidData }, new PSBlock @@ -9344,18 +7323,18 @@ namespace LibTSforge.Activators Type = BlockType.NAMED, Flags = 0, KeyAsStr = key, - ValueAsStr = pkeyInfoName, + ValueAsStr = "msft:Windows/7.0/Phone/Cached/PKeyInfo/" + pkeyId, Data = tsPkeyInfoData } }); } - if (version != PSVersion.Vista && version != PSVersion.Win7) + if (version != PSVersion.Win7) { Deposit(actId, instId); } - SPPUtils.RestartSPP(version); + SLApi.RefreshLicenseStatus(); SLApi.FireStateChangedEvent(appId); Logger.WriteLine("Activated using ZeroCID successfully."); } @@ -9363,7 +7342,7 @@ namespace LibTSforge.Activators } -// LibTSforge/TokenStore/Common.cs +// TokenStore/Common.cs namespace LibTSforge.TokenStore { using System.Collections.Generic; @@ -9380,7 +7359,7 @@ namespace LibTSforge.TokenStore public class TokenMeta { public string Name; - public readonly Dictionary Data = new Dictionary(); + public Dictionary Data = new Dictionary(); public byte[] Serialize() { @@ -9403,7 +7382,7 @@ namespace LibTSforge.TokenStore return writer.GetBytes(); } - private void Deserialize(byte[] data) + public void Deserialize(byte[] data) { BinaryReader reader = new BinaryReader(new MemoryStream(data)); reader.ReadInt32(); @@ -9433,7 +7412,7 @@ namespace LibTSforge.TokenStore } -// LibTSforge/TokenStore/ITokenStore.cs +// TokenStore/ITokenStore.cs namespace LibTSforge.TokenStore { using System; @@ -9453,14 +7432,14 @@ namespace LibTSforge.TokenStore } -// LibTSforge/TokenStore/TokenStoreModern.cs +// TokenStore/TokenStoreModern.cs namespace LibTSforge.TokenStore { using System; using System.Collections.Generic; using System.IO; using System.Linq; - using Crypto; + using LibTSforge.Crypto; public class TokenStoreModern : ITokenStore { @@ -9474,29 +7453,29 @@ namespace LibTSforge.TokenStore private static readonly byte[] CONTS_FOOTER = Enumerable.Repeat((byte)0xAA, 0x20).ToArray(); private List Entries = new List(); - private readonly FileStream TokensFile; + public FileStream TokensFile; public void Deserialize() { if (TokensFile.Length < BLOCK_SIZE) return; TokensFile.Seek(0x24, SeekOrigin.Begin); - uint nextBlock; + uint nextBlock = 0; BinaryReader reader = new BinaryReader(TokensFile); do { - reader.ReadUInt32(); + uint curOffset = reader.ReadUInt32(); nextBlock = reader.ReadUInt32(); for (int i = 0; i < ENTRIES_PER_BLOCK; i++) { - uint curOffset = reader.ReadUInt32(); + curOffset = reader.ReadUInt32(); bool populated = reader.ReadUInt32() == 1; uint contentOffset = reader.ReadUInt32(); uint contentLength = reader.ReadUInt32(); uint allocLength = reader.ReadUInt32(); - byte[] contentData = { }; + byte[] contentData = new byte[] { }; if (populated) { @@ -9596,10 +7575,11 @@ namespace LibTSforge.TokenStore writer.WritePadding(BLOCK_PAD_SIZE); writer.BaseStream.Seek(curBlockOffset, SeekOrigin.Begin); + byte[] blockHash; byte[] blockData = new byte[BLOCK_SIZE - 0x20]; tokens.Read(blockData, 0, BLOCK_SIZE - 0x20); - byte[] blockHash = CryptoUtils.SHA256Hash(blockData); + blockHash = CryptoUtils.SHA256Hash(blockData); writer.BaseStream.Seek(curBlockOffset + BLOCK_SIZE - 0x20, SeekOrigin.Begin); writer.Write(blockHash); @@ -9730,6 +7710,11 @@ namespace LibTSforge.TokenStore Deserialize(); } + public TokenStoreModern() + { + + } + public void Dispose() { Serialize(); @@ -9739,7 +7724,7 @@ namespace LibTSforge.TokenStore } -// LibTSforge/PhysicalStore/Common.cs +// PhysicalStore/Common.cs namespace LibTSforge.PhysicalStore { using System.Runtime.InteropServices; @@ -9760,17 +7745,10 @@ namespace LibTSforge.PhysicalStore public ulong Time2; public ulong Expiry; } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct VistaTimer - { - public ulong Time; - public ulong Expiry; - } } -// LibTSforge/PhysicalStore/IPhysicalStore.cs +// PhysicalStore/IPhysicalStore.cs namespace LibTSforge.PhysicalStore { using System; @@ -9865,13 +7843,13 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/PhysicalStoreModern.cs +// PhysicalStore/PhysicalStoreModern.cs namespace LibTSforge.PhysicalStore { using System; using System.Collections.Generic; using System.IO; - using Crypto; + using LibTSforge.Crypto; public class ModernBlock { @@ -9961,7 +7939,7 @@ namespace LibTSforge.PhysicalStore public sealed class PhysicalStoreModern : IPhysicalStore { - private byte[] PreHeaderBytes = { }; + private byte[] PreHeaderBytes = new byte[] { }; private readonly Dictionary> Data = new Dictionary>(); private readonly FileStream TSFile; private readonly PSVersion Version; @@ -10149,50 +8127,46 @@ namespace LibTSforge.PhysicalStore public void DeleteBlock(string key, string value) { - if (!Data.ContainsKey(key)) + if (Data.ContainsKey(key)) { - return; - } + List blocks = Data[key]; - List blocks = Data[key]; - - foreach (ModernBlock block in blocks) - { - if (block.ValueAsStr == value) + foreach (ModernBlock block in blocks) { - blocks.Remove(block); - break; + if (block.ValueAsStr == value) + { + blocks.Remove(block); + break; + } } - } - Data[key] = blocks; + Data[key] = blocks; + } } public void DeleteBlock(string key, uint value) { - if (!Data.ContainsKey(key)) + if (Data.ContainsKey(key)) { - return; - } + List blocks = Data[key]; - List blocks = Data[key]; - - foreach (ModernBlock block in blocks) - { - if (block.ValueAsInt == value) + foreach (ModernBlock block in blocks) { - blocks.Remove(block); - break; + if (block.ValueAsInt == value) + { + blocks.Remove(block); + break; + } } - } - Data[key] = blocks; + Data[key] = blocks; + } } public PhysicalStoreModern(string tsPath, bool production, PSVersion version) { TSFile = File.Open(tsPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); - Deserialize(PhysStoreCrypto.DecryptPhysicalStore(TSFile.ReadAllBytes(), production, version)); + Deserialize(PhysStoreCrypto.DecryptPhysicalStore(TSFile.ReadAllBytes(), production)); TSFile.Seek(0, SeekOrigin.Begin); Version = version; Production = production; @@ -10212,7 +8186,7 @@ namespace LibTSforge.PhysicalStore public byte[] ReadRaw() { - byte[] data = PhysStoreCrypto.DecryptPhysicalStore(TSFile.ReadAllBytes(), Production, Version); + byte[] data = PhysStoreCrypto.DecryptPhysicalStore(TSFile.ReadAllBytes(), Production); TSFile.Seek(0, SeekOrigin.Begin); return data; } @@ -10283,372 +8257,13 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/PhysicalStoreVista.cs +// PhysicalStore/PhysicalStoreWin7.cs namespace LibTSforge.PhysicalStore { using System; using System.Collections.Generic; using System.IO; - using Crypto; - - public class VistaBlock - { - public BlockType Type; - public uint Flags; - public byte[] Value; - public string ValueAsStr - { - get - { - return Utils.DecodeString(Value); - } - set - { - Value = Utils.EncodeString(value); - } - } - public uint ValueAsInt - { - get - { - return BitConverter.ToUInt32(Value, 0); - } - set - { - Value = BitConverter.GetBytes(value); - } - } - public byte[] Data; - public string DataAsStr - { - get - { - return Utils.DecodeString(Data); - } - set - { - Data = Utils.EncodeString(value); - } - } - public uint DataAsInt - { - get - { - return BitConverter.ToUInt32(Data, 0); - } - set - { - Data = BitConverter.GetBytes(value); - } - } - - internal void Encode(BinaryWriter writer) - { - writer.Write((uint)Type); - writer.Write(Flags); - writer.Write(Value.Length); - writer.Write(Data.Length); - writer.Write(Value); - writer.Write(Data); - } - - internal static VistaBlock Decode(BinaryReader reader) - { - uint type = reader.ReadUInt32(); - uint flags = reader.ReadUInt32(); - - int valueLen = reader.ReadInt32(); - int dataLen = reader.ReadInt32(); - - byte[] value = reader.ReadBytes(valueLen); - byte[] data = reader.ReadBytes(dataLen); - return new VistaBlock - { - Type = (BlockType)type, - Flags = flags, - Value = value, - Data = data, - }; - } - } - - public sealed class PhysicalStoreVista : IPhysicalStore - { - private byte[] PreHeaderBytes = { }; - private readonly List Blocks = new List(); - private readonly FileStream TSPrimary; - private readonly FileStream TSSecondary; - private readonly bool Production; - - public byte[] Serialize() - { - BinaryWriter writer = new BinaryWriter(new MemoryStream()); - writer.Write(PreHeaderBytes); - - foreach (VistaBlock block in Blocks) - { - block.Encode(writer); - writer.Align(4); - } - - return writer.GetBytes(); - } - - public void Deserialize(byte[] data) - { - int len = data.Length; - - BinaryReader reader = new BinaryReader(new MemoryStream(data)); - PreHeaderBytes = reader.ReadBytes(8); - - while (reader.BaseStream.Position < len - 0x14) - { - Blocks.Add(VistaBlock.Decode(reader)); - reader.Align(4); - } - } - - public void AddBlock(PSBlock block) - { - Blocks.Add(new VistaBlock - { - Type = block.Type, - Flags = block.Flags, - Value = block.Value, - Data = block.Data - }); - } - - public void AddBlocks(IEnumerable blocks) - { - foreach (PSBlock block in blocks) - { - AddBlock(block); - } - } - - public PSBlock GetBlock(string key, string value) - { - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsStr == value) - { - return new PSBlock - { - Type = block.Type, - Flags = block.Flags, - Key = new byte[0], - Value = block.Value, - Data = block.Data - }; - } - } - - return null; - } - - public PSBlock GetBlock(string key, uint value) - { - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsInt == value) - { - return new PSBlock - { - Type = block.Type, - Flags = block.Flags, - Key = new byte[0], - Value = block.Value, - Data = block.Data - }; - } - } - - return null; - } - - public void SetBlock(string key, string value, byte[] data) - { - for (int i = 0; i < Blocks.Count; i++) - { - VistaBlock block = Blocks[i]; - - if (block.ValueAsStr == value) - { - block.Data = data; - Blocks[i] = block; - break; - } - } - } - - public void SetBlock(string key, uint value, byte[] data) - { - for (int i = 0; i < Blocks.Count; i++) - { - VistaBlock block = Blocks[i]; - - if (block.ValueAsInt == value) - { - block.Data = data; - Blocks[i] = block; - break; - } - } - } - - public void SetBlock(string key, string value, string data) - { - SetBlock(key, value, Utils.EncodeString(data)); - } - - public void SetBlock(string key, string value, uint data) - { - SetBlock(key, value, BitConverter.GetBytes(data)); - } - - public void SetBlock(string key, uint value, string data) - { - SetBlock(key, value, Utils.EncodeString(data)); - } - - public void SetBlock(string key, uint value, uint data) - { - SetBlock(key, value, BitConverter.GetBytes(data)); - } - - public void DeleteBlock(string key, string value) - { - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsStr == value) - { - Blocks.Remove(block); - return; - } - } - } - - public void DeleteBlock(string key, uint value) - { - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsInt == value) - { - Blocks.Remove(block); - return; - } - } - } - - public PhysicalStoreVista(string primaryPath, bool production) - { - TSPrimary = File.Open(primaryPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); - TSSecondary = File.Open(primaryPath.Replace("-0.", "-1."), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); - Production = production; - - Deserialize(PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), production, PSVersion.Vista)); - TSPrimary.Seek(0, SeekOrigin.Begin); - } - - public void Dispose() - { - if (TSPrimary.CanWrite && TSSecondary.CanWrite) - { - byte[] data = PhysStoreCrypto.EncryptPhysicalStore(Serialize(), Production, PSVersion.Vista); - - TSPrimary.SetLength(data.LongLength); - TSSecondary.SetLength(data.LongLength); - - TSPrimary.Seek(0, SeekOrigin.Begin); - TSSecondary.Seek(0, SeekOrigin.Begin); - - TSPrimary.WriteAllBytes(data); - TSSecondary.WriteAllBytes(data); - - TSPrimary.Close(); - TSSecondary.Close(); - } - } - - public byte[] ReadRaw() - { - byte[] data = PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), Production, PSVersion.Vista); - TSPrimary.Seek(0, SeekOrigin.Begin); - return data; - } - - public void WriteRaw(byte[] data) - { - byte[] encrData = PhysStoreCrypto.EncryptPhysicalStore(data, Production, PSVersion.Vista); - - TSPrimary.SetLength(encrData.LongLength); - TSSecondary.SetLength(encrData.LongLength); - - TSPrimary.Seek(0, SeekOrigin.Begin); - TSSecondary.Seek(0, SeekOrigin.Begin); - - TSPrimary.WriteAllBytes(encrData); - TSSecondary.WriteAllBytes(encrData); - - TSPrimary.Close(); - TSSecondary.Close(); - } - - public IEnumerable FindBlocks(string valueSearch) - { - List results = new List(); - - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsStr.Contains(valueSearch)) - { - results.Add(new PSBlock - { - Type = block.Type, - Flags = block.Flags, - Key = new byte[0], - Value = block.Value, - Data = block.Data - }); - } - } - - return results; - } - - public IEnumerable FindBlocks(uint valueSearch) - { - List results = new List(); - - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsInt == valueSearch) - { - results.Add(new PSBlock - { - Type = block.Type, - Flags = block.Flags, - Key = new byte[0], - Value = block.Value, - Data = block.Data - }); - } - } - - return results; - } - } -} - - -// LibTSforge/PhysicalStore/PhysicalStoreWin7.cs -namespace LibTSforge.PhysicalStore -{ - using System; - using System.Collections.Generic; - using System.IO; - using Crypto; + using LibTSforge.Crypto; public class Win7Block { @@ -10750,7 +8365,7 @@ namespace LibTSforge.PhysicalStore public sealed class PhysicalStoreWin7 : IPhysicalStore { - private byte[] PreHeaderBytes = { }; + private byte[] PreHeaderBytes = new byte[] { }; private readonly List Blocks = new List(); private readonly FileStream TSPrimary; private readonly FileStream TSSecondary; @@ -10924,7 +8539,7 @@ namespace LibTSforge.PhysicalStore TSSecondary = File.Open(primaryPath.Replace("-0.", "-1."), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); Production = production; - Deserialize(PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), production, PSVersion.Win7)); + Deserialize(PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), production)); TSPrimary.Seek(0, SeekOrigin.Begin); } @@ -10950,7 +8565,7 @@ namespace LibTSforge.PhysicalStore public byte[] ReadRaw() { - byte[] data = PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), Production, PSVersion.Win7); + byte[] data = PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), Production); TSPrimary.Seek(0, SeekOrigin.Begin); return data; } @@ -11019,7 +8634,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/VariableBag.cs +// PhysicalStore/VariableBag.cs namespace LibTSforge.PhysicalStore { using System; @@ -11033,7 +8648,7 @@ namespace LibTSforge.PhysicalStore BINARY = 1 << 2 } - public abstract class CRCBlock + public class CRCBlock { public CRCBlockType DataType; public byte[] Key; @@ -11072,57 +8687,7 @@ namespace LibTSforge.PhysicalStore } } - public abstract void Encode(BinaryWriter writer); - public abstract void Decode(BinaryReader reader); - public abstract uint CRC(); - } - - public class CRCBlockVista : CRCBlock - { - public override void Encode(BinaryWriter writer) - { - uint crc = CRC(); - writer.Write((uint)DataType); - writer.Write(0); - writer.Write(Key.Length); - writer.Write(Value.Length); - writer.Write(crc); - - writer.Write(Key); - - writer.Write(Value); - } - - public override void Decode(BinaryReader reader) - { - uint type = reader.ReadUInt32(); - reader.ReadUInt32(); - uint lenName = reader.ReadUInt32(); - uint lenVal = reader.ReadUInt32(); - uint crc = reader.ReadUInt32(); - - byte[] key = reader.ReadBytes((int)lenName); - byte[] value = reader.ReadBytes((int)lenVal); - - DataType = (CRCBlockType)type; - Key = key; - Value = value; - - if (CRC() != crc) - { - throw new InvalidDataException("Invalid CRC in variable bag."); - } - } - - public override uint CRC() - { - return Utils.CRC32(Value); - } - } - - public class CRCBlockModern : CRCBlock - { - public override void Encode(BinaryWriter writer) + public void Encode(BinaryWriter writer) { uint crc = CRC(); writer.Write(crc); @@ -11137,7 +8702,7 @@ namespace LibTSforge.PhysicalStore writer.Align(8); } - public override void Decode(BinaryReader reader) + public static CRCBlock Decode(BinaryReader reader) { uint crc = reader.ReadUInt32(); uint type = reader.ReadUInt32(); @@ -11150,17 +8715,22 @@ namespace LibTSforge.PhysicalStore byte[] value = reader.ReadBytes((int)lenVal); reader.Align(8); - DataType = (CRCBlockType)type; - Key = key; - Value = value; + CRCBlock block = new CRCBlock + { + DataType = (CRCBlockType)type, + Key = key, + Value = value, + }; - if (CRC() != crc) + if (block.CRC() != crc) { throw new InvalidDataException("Invalid CRC in variable bag."); } + + return block; } - public override uint CRC() + public uint CRC() { BinaryWriter wtemp = new BinaryWriter(new MemoryStream()); wtemp.Write(0); @@ -11176,9 +8746,8 @@ namespace LibTSforge.PhysicalStore public class VariableBag { public List Blocks = new List(); - private readonly PSVersion Version; - private void Deserialize(byte[] data) + public void Deserialize(byte[] data) { int len = data.Length; @@ -11186,19 +8755,7 @@ namespace LibTSforge.PhysicalStore while (reader.BaseStream.Position < len - 0x10) { - CRCBlock block; - - if (Version == PSVersion.Vista) - { - block = new CRCBlockVista(); - } - else - { - block = new CRCBlockModern(); - } - - block.Decode(reader); - Blocks.Add(block); + Blocks.Add(CRCBlock.Decode(reader)); } } @@ -11208,13 +8765,7 @@ namespace LibTSforge.PhysicalStore foreach (CRCBlock block in Blocks) { - if (Version == PSVersion.Vista) - { - ((CRCBlockVista)block).Encode(writer); - } else - { - ((CRCBlockModern)block).Encode(writer); - } + block.Encode(writer); } return writer.GetBytes(); @@ -11260,48 +8811,35 @@ namespace LibTSforge.PhysicalStore } } - public VariableBag(byte[] data, PSVersion version) + public VariableBag(byte[] data) { - Version = version; Deserialize(data); } - public VariableBag(PSVersion version) + public VariableBag() { - Version = version; + } } } '@ $ErrorActionPreference = 'Stop' -$binPath = "$env:_work\BIN\LibTSforge.dll" -$psMajorVer = (Get-Host).Version.Major -$build = [System.Environment]::OSVersion.Version.Build +$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" } -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" } - - $ctemp = "$env:SystemRoot\Temp\" - if (-Not (Test-Path -Path $ctemp)) { New-Item -Path $ctemp -ItemType Directory > $null } - $env:TMP = $ctemp - $env:TEMP = $ctemp - - $cp.GenerateInMemory = $true - Add-Type -Language $lang -TypeDefinition $src -CompilerParameters $cp -} +$ctemp = "$env:SystemRoot\Temp\" +if (-Not (Test-Path -Path $ctemp)) { New-Item -Path $ctemp -ItemType Directory > $null } +$env:TMP = $ctemp +$env:TEMP = $ctemp +$cp.GenerateInMemory = $true +Add-Type -Language $lang -TypeDefinition $src -CompilerParameters $cp if ($env:_debug -eq '0') { [LibTSforge.Logger]::HideOutput = $true } -[void][LibTSforge.Utils]::Wow64EnableWow64FsRedirection($false) $ver = [LibTSforge.Utils]::DetectVersion() -$prod = [LibTSforge.SPP.SPPUtils]::DetectCurrentKey() +$prod = [LibTSforge.Utils]::DetectCurrentKey() $tsactids = @($args) function Get-WmiInfo { @@ -11314,97 +8852,26 @@ function Get-WmiInfo { } } -function slGetSkuInfo($SkuId) { - $t = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0) - $t.DefinePInvokeMethod('SLOpen', 'slc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $t.DefinePInvokeMethod('SLClose', 'slc.dll', 22, 1, [IntPtr], @([IntPtr]), 1, 3).SetImplementationFlags(128) - $t.DefinePInvokeMethod('SLGetProductSkuInformation', 'slc.dll', 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $w = $t.CreateType() - $hSLC = 0 - try { - [void]$w::SLOpen([ref]$hSLC) - $c = 0; $b = 0 - $r = $w::SLGetProductSkuInformation($hSLC, [ref][Guid]$SkuId, "msft:sl/EUL/PHONE/PUBLIC", [ref]$null, [ref]$c, [ref]$b) - return ($r -eq 0) - } - finally { - [void]$w::SLClose($hSLC) - } -} - -if (-not $env:resetstuff) { +if ($env:resetstuff -eq $null) { 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))) { - $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.Modifiers.GenPKeyInstall]::InstallGenPKey($ver, $prod, $tsactid) + [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 + [LibTSforge.Modifiers.KMSHostCharge]::Charge($ver, $tsactid, $prod) + 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 { @@ -11420,13 +8887,13 @@ if (-not $env:resetstuff) { } } -if ($env:resetstuff) { +if ($env:resetstuff -eq '1') { try { - if (-not $env:_vis) { [LibTSforge.Modifiers.TamperedFlagsDelete]::DeleteTamperFlags($ver, $prod) } + [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) } + [LibTSforge.Modifiers.KeyChangeLockDelete]::Delete($ver, $prod) } catch { $errcode = 3 @@ -11671,7 +9138,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,121 +9153,138 @@ 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 +:: 1st column = Office version number +:: 2nd column = Activation ID +:: 3rd column = Edition :: Separator = "_" -:tsksdata +:ts_msiofficedata -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- +15_ab4d047b-97cf-4126-a69f-34df08e2f254_AccessRetail +15_259de5be-492b-44b3-9d78-9645f848f7b0_AccessRuntimeRetail +15_4374022d-56b8-48c1-9bb7-d8f2fc726343_AccessVolume +15_1b1d9bd5-12ea-4063-964c-16e7e87d6e08_ExcelRetail +15_ac1ae7fd-b949-4e04-a330-849bc40638cf_ExcelVolume +15_cfaf5356-49e3-48a8-ab3c-e729ab791250_GrooveRetail +15_4825ac28-ce41-45a7-9e6e-1fed74057601_GrooveVolume +15_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_HomeBusinessPipcRetail +15_a2b90e7a-a797-4713-af90-f0becf52a1dd_HomeBusinessRetail +15_1fdfb4e4-f9c9-41c4-b055-c80daf00697d_HomeStudentARMRetail +15_ebef9f05-5273-404a-9253-c5e252f50555_HomeStudentPlusARMRetail +15_f2de350d-3028-410a-bfae-283e00b44d0e_HomeStudentRetail +15_44984381-406e-4a35-b1c3-e54f499556e2_InfoPathRetail +15_9e016989-4007-42a6-8051-64eb97110cf2_InfoPathVolume +15_9103f3ce-1084-447a-827e-d6097f68c895_LyncAcademicRetail +15_ff693bf4-0276-4ddb-bb42-74ef1a0c9f4d_LyncEntryRetail +15_fada6658-bfc6-4c4e-825a-59a89822cda8_LyncRetail +15_e1264e10-afaf-4439-a98b-256df8bb156f_LyncVolume +15_69ec9152-153b-471a-bf35-77ec88683eae_MondoRetail +15_f33485a0-310b-4b72-9a0e-b1d605510dbd_MondoVolume +15_3391e125-f6e4-4b1e-899c-a25e6092d40d_OneNoteFreeRetail +15_8b524bcc-67ea-4876-a509-45e46f6347e8_OneNoteRetail +15_b067e965-7521-455b-b9f7-c740204578a2_OneNoteVolume +15_12004b48-e6c8-4ffa-ad5a-ac8d4467765a_OutlookRetail +15_8d577c50-ae5e-47fd-a240-24986f73d503_OutlookVolume +15_5aab8561-1686-43f7-9ff5-2c861da58d17_PersonalPipcRetail +15_17e9df2d-ed91-4382-904b-4fed6a12caf0_PersonalRetail +15_31743b82-bfbc-44b6-aa12-85d42e644d5b_PowerPointRetail +15_e40dcb44-1d5c-4085-8e8f-943f33c4f004_PowerPointVolume +15_064383fa-1538-491c-859b-0ecab169a0ab_ProPlusRetail +15_2b88c4f2-ea8f-43cd-805e-4d41346e18a7_ProPlusVolume +15_4e26cac1-e15a-4467-9069-cb47b67fe191_ProfessionalPipcRetail +15_44bc70e2-fb83-4b09-9082-e5557e0c2ede_ProfessionalRetail +15_2f72340c-b555-418d-8b46-355944fe66b8_ProjectProRetail +15_ed34dc89-1c27-4ecd-8b2f-63d0f4cedc32_ProjectProVolume +15_58d95b09-6af6-453d-a976-8ef0ae0316b1_ProjectStdRetail +15_2b9e4a37-6230-4b42-bee2-e25ce86c8c7a_ProjectStdVolume +15_c3a0814a-70a4-471f-af37-2313a6331111_PublisherRetail +15_38ea49f6-ad1d-43f1-9888-99a35d7c9409_PublisherVolume +15_ba3e3833-6a7e-445a-89d0-7802a9a68588_SPDRetail +15_32255c0a-16b4-4ce2-b388-8a4267e219eb_StandardRetail +15_a24cca51-3d54-4c41-8a76-4031f5338cb2_StandardVolume +15_a56a3b37-3a35-4bbb-a036-eee5f1898eee_VisioProRetail +15_3e4294dd-a765-49bc-8dbd-cf8b62a4bd3d_VisioProVolume +15_980f9e3e-f5a8-41c8-8596-61404addf677_VisioStdRetail +15_44a1f6ff-0876-4edb-9169-dbb43101ee89_VisioStdVolume +15_191509f2-6977-456f-ab30-cf0492b1e93a_WordRetail +15_9cedef15-be37-4ff0-a08a-13a045540641_WordVolume +:: Office 365 - 15.0 version +15_742178ed-6b28-42dd-b3d7-b7c0ea78741b_O365BusinessRetail +15_a96f8dae-da54-4fad-bdc6-108da592707a_O365HomePremRetail +15_e3dacc06-3bc2-4e13-8e59-8e05f3232325_O365ProPlusRetail +15_0bc1dae4-6158-4a1c-a893-807665b934b2_O365SmallBusPremRetail +:: Office 365 - 16.0 version +16_742178ed-6b28-42dd-b3d7-b7c0ea78741b_O365BusinessRetail +16_2f5c71b4-5b7a-4005-bb68-f9fac26f2ea3_O365EduCloudRetail +16_a96f8dae-da54-4fad-bdc6-108da592707a_O365HomePremRetail +16_e3dacc06-3bc2-4e13-8e59-8e05f3232325_O365ProPlusRetail +16_0bc1dae4-6158-4a1c-a893-807665b934b2_O365SmallBusPremRetail :: 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- +16_bfa358b0-98f1-4125-842e-585fa13032e6_AccessRetail +16_9d9faf9e-d345-4b49-afce-68cb0a539c7c_AccessRuntimeRetail +16_3b2fa33f-cd5a-43a5-bd95-f49f3f546b0b_AccessVolume +16_424d52ff-7ad2-4bc7-8ac6-748d767b455d_ExcelRetail +16_685062a7-6024-42e7-8c5f-6bb9e63e697f_ExcelVolume +16_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_HomeBusinessPipcRetail +16_86834d00-7896-4a38-8fae-32f20b86fa2b_HomeBusinessRetail +16_090896a0-ea98-48ac-b545-ba5da0eb0c9c_HomeStudentARMRetail +16_6bbe2077-01a4-4269-bf15-5bf4d8efc0b2_HomeStudentPlusARMRetail +16_c28acdb8-d8b3-4199-baa4-024d09e97c99_HomeStudentRetail +16_e2127526-b60c-43e0-bed1-3c9dc3d5a468_HomeStudentVNextRetail +16_69ec9152-153b-471a-bf35-77ec88683eae_MondoRetail +16_2cd0ea7e-749f-4288-a05e-567c573b2a6c_MondoVolume +16_436366de-5579-4f24-96db-3893e4400030_OneNoteFreeRetail +16_83ac4dd9-1b93-40ed-aa55-ede25bb6af38_OneNoteRetail +16_23b672da-a456-4860-a8f3-e062a501d7e8_OneNoteVolume +16_5a670809-0983-4c2d-8aad-d3c2c5b7d5d1_OutlookRetail +16_50059979-ac6f-4458-9e79-710bcb41721a_OutlookVolume +16_5aab8561-1686-43f7-9ff5-2c861da58d17_PersonalPipcRetail +16_a9f645a1-0d6a-4978-926a-abcb363b72a6_PersonalRetail +16_f32d1284-0792-49da-9ac6-deb2bc9c80b6_PowerPointRetail +16_9b4060c9-a7f5-4a66-b732-faf248b7240f_PowerPointVolume +16_de52bd50-9564-4adc-8fcb-a345c17f84f9_ProPlusRetail +16_c47456e3-265d-47b6-8ca0-c30abbd0ca36_ProPlusVolume +16_4e26cac1-e15a-4467-9069-cb47b67fe191_ProfessionalPipcRetail +16_d64edc00-7453-4301-8428-197343fafb16_ProfessionalRetail +16_2f72340c-b555-418d-8b46-355944fe66b8_ProjectProRetail +16_82f502b5-b0b0-4349-bd2c-c560df85b248_ProjectProVolume +16_16728639-a9ab-4994-b6d8-f81051e69833_ProjectProXVolume +16_58d95b09-6af6-453d-a976-8ef0ae0316b1_ProjectStdRetail +16_82e6b314-2a62-4e51-9220-61358dd230e6_ProjectStdVolume +16_431058f0-c059-44c5-b9e7-ed2dd46b6789_ProjectStdXVolume +16_6e0c1d99-c72e-4968-bcb7-ab79e03e201e_PublisherRetail +16_fcc1757b-5d5f-486a-87cf-c4d6dedb6032_PublisherVolume +16_9103f3ce-1084-447a-827e-d6097f68c895_SkypeServiceBypassRetail +16_971cd368-f2e1-49c1-aedd-330909ce18b6_SkypeforBusinessEntryRetail +16_418d2b9f-b491-4d7f-84f1-49e27cc66597_SkypeforBusinessRetail +16_03ca3b9a-0869-4749-8988-3cbc9d9f51bb_SkypeforBusinessVolume +16_4a31c291-3a12-4c64-b8ab-cd79212be45e_StandardRetail +16_0ed94aac-2234-4309-ba29-74bdbb887083_StandardVolume +16_a56a3b37-3a35-4bbb-a036-eee5f1898eee_VisioProRetail +16_295b2c03-4b1c-4221-b292-1411f468bd02_VisioProVolume +16_0594dc12-8444-4912-936a-747ca742dbdb_VisioProXVolume +16_980f9e3e-f5a8-41c8-8596-61404addf677_VisioStdRetail +16_44151c2d-c398-471f-946f-7660542e3369_VisioStdVolume +16_1d1c6879-39a3-47a5-9a6d-aceefa6a289d_VisioStdXVolume +16_cacaa1bf-da53-4c3b-9700-11738ef1c2a5_WordRetail +16_c3000759-551f-4f4a-bcac-a4b42cbf1de2_WordVolume ) do ( -for /f "tokens=1-3 delims=_" %%A in ("%%#") do ( +for /f "tokens=1-5 delims=_" %%A in ("%%#") do ( -if %1==chkprod if "%oVer%"=="%%A" if not defined foundprod ( -if /i "%%B"=="%2" set foundprod=1 +if "%oVer%"=="%%A" ( +for /f "tokens=*" %%x in ('findstr /i /c:"%%B" "%_oBranding%"') do set "prodId=%%x" +set prodId=!prodId:"/>=! +set prodId=!prodId:~-4! +if "%oVer%"=="14" ( +REM Exception case for Visio because wrong primary product ID is mentioned in Branding.xml +echo %%C | find /i "Visio" %nul% && set prodId=0057 +) +reg query "%1\Registration\{%%B}" /v ProductCode %nul2% | find /i "-!prodId!-" %nul% && ( +reg query "%1\Common\InstalledPackages" %nul2% | find /i "-!prodId!-" %nul% && ( +if defined _oIds (set _oIds=!_oIds! %%C) else (set _oIds=%%C) ) - -if %1==getinfo if "%oVer%"=="%%A" ( -echo: %%C | find /i "-%2-" %nul% && ( -set _License=%%B -set _altoffid=%%B ) ) @@ -12060,6 +9544,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: +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "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% "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% "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% "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% "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% "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 ( +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% "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" + +sc query sppsvc | find /i "STOPPED" %nul% && ( +echo Stopping sppsvc Service [Successful] +) || ( +call :dk_color %Gray% "Stopping sppsvc Service [Failed]" +) + +%_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% "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 @@ -12208,17 +10484,12 @@ echo: echo Initializing... call :dk_chkmal -if not exist %SysPath%\%_slexe% ( +if not exist %SysPath%\sppsvc.exe ( %eline% -echo [%SysPath%\%_slexe%] file is missing, aborting... +echo [%SysPath%\sppsvc.exe] 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%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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -12267,7 +10538,7 @@ call :dk_color %Blue% "Internet is required for Online %KS% Activation." echo Initiating Diagnostic Tests... -set "_serv=%_slser% Winmgmt" +set "_serv=sppsvc Winmgmt" :: Software Protection :: Windows Management Instrumentation @@ -12311,7 +10582,7 @@ call :dk_color %Blue% "Go back to main menu and use [Change Edition] option." ) else ( call :dk_color %Blue% "Use TSforge activation option from the main menu to reset evaluation period." set fixes=%fixes% %mas%evaluation_editions -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" ) goto :ks_office @@ -12335,7 +10606,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) @@ -12357,19 +10628,17 @@ echo [%winos% ^| %winbuild% ^| SKU:%osSKU%] if %winbuild% GEQ 9200 if exist "%SysPath%\spp\tokens\skus\%osedition%\*GVLK*.xrm-ms" set sppks=1 if %winbuild% LSS 9200 if exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*VLKMS*.xrm-ms" set sppks=1 if %winbuild% LSS 9200 if exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*VL-BYPASS*.xrm-ms" set sppks=1 -if %winbuild% LSS 7600 if exist "%SysPath%\licensing\skus\Security-Licensing-SLC-Component-SKU-%osedition%\*KMS*.xrm-ms" set sppks=1 -if %winbuild% LSS 7600 if exist "%SysPath%\licensing\skus\Security-Licensing-SLC-Component-SKU-%osedition%\*VL-BYPASS*.xrm-ms" set sppks=1 if defined skunotfound ( -call :dk_color %Red% "Required license files not found." +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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) if defined sppks ( call :dk_color %Red% "%KS% activation is supported but failed to find the %KS% key." set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) if not defined skunotfound if not defined sppks ( @@ -12402,7 +10671,6 @@ call echo Checking Installed Product Key [Partial Key - %%_partial%%] [ ) if defined key ( -set generickey=1 call :dk_inskey "[%key%]" ) @@ -12412,7 +10680,7 @@ call :dk_inskey "[%key%]" if not %_actoff%==1 goto :ks_activate -call :oh_setspp +call :ks_setspp :: Check ohook install @@ -12457,7 +10725,7 @@ set ohub=1 :: Check supported office versions -call :oh_getpath +call :ks_getpath set o16uwp= set o16uwp_path= @@ -12497,7 +10765,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 +10857,6 @@ set error=1 goto :ks_starto16c2r ) -call :oh_expiredpreview 2013 if "%_actprojvis%"=="0" call :oh_fixprids call :ks_process @@ -12630,7 +10897,6 @@ set error=1 goto :ks_startmsi ) -call :oh_expiredpreview 2016 2019 2021 2024 if "%_actprojvis%"=="0" call :oh_fixprids call :ks_process @@ -12638,9 +10904,9 @@ call :ks_process :ks_startmsi -if defined o14msi call :oh_setspp 14 +if defined o14msi call :ks_setspp 14 if defined o14msi call :ks_processmsi 14 %o14msi_reg% -call :oh_setspp +call :ks_setspp if defined o15msi call :ks_processmsi 15 %o15msi_reg% if defined o16msi call :ks_processmsi 16 %o16msi_reg% @@ -12656,7 +10922,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 +10977,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 +10990,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." @@ -12779,7 +11045,34 @@ set _prids= set _config= set _version= set _License= -set _oMSI= +set _oBranding= +exit /b + +::======================================================================================================================================== + +:ks_getpath + +set o16c2r= +set o15c2r= +set o16msi= +set o15msi= +set o14msi= + +set _68=HKLM\SOFTWARE\Microsoft\Office +set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office + +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 o16c2r=1&set o16c2r_reg=%_86%\ClickToRun) +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 o16c2r=1&set o16c2r_reg=%_68%\ClickToRun) +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 o15c2r=1&set o15c2r_reg=%_86%\15.0\ClickToRun) +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 o15c2r=1&set o15c2r_reg=%_68%\15.0\ClickToRun) + +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=1&set o14msi_reg=%_86%\14.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=1&set o14msi_reg=%_68%\14.0) + exit /b ::======================================================================================================================================== @@ -12812,19 +11105,16 @@ exit /b ::======================================================================================================================================== -:oh_setspp +:ks_setspp -set isOspp= if %winbuild% GEQ 9200 ( set spp=SoftwareLicensingProduct set sps=SoftwareLicensingService ) else ( -set isOspp=1 set spp=OfficeSoftwareProtectionProduct set sps=OfficeSoftwareProtectionService ) if "%1"=="14" ( -set isOspp=1 set spp=OfficeSoftwareProtectionProduct set sps=OfficeSoftwareProtectionService ) @@ -12837,7 +11127,7 @@ exit /b for %%# in (%_oIds%) do ( set skipprocess= -if %_NoEditionChange%==1 if not defined _oMSI ( +if %_NoEditionChange%==1 if not defined _oBranding ( set foundprod= call :ksdata chkprod %%# if not defined foundprod ( @@ -12878,26 +11168,21 @@ 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 ) if not "!key!"=="" ( echo "!allapps!" | find /i "!_actid!" %nul1% || call :oh_installlic -set generickey=1 call :dk_inskey "[!key!] [!_prod!]" ) else ( -if not defined _oMSI ( +if not defined _oBranding ( set error=1 call :dk_color %Red% "Checking Product In Script [Office %oVer%.0 !_prod! not found in script]" call :dk_color %Blue% "Make sure you are using Latest MAS script." ) else ( call :dk_color %Red% "Checking Product In Script [!_prod! MSI Retail is not supported]" -call :dk_color %Blue% "Use Ohook option to activate it. To activate with %KS%, you need to install Volume version of Office." +call :dk_color %Blue% "Uninstall this and Install C2R or MSI VL version of Office." ) set fixes=%fixes% %mas%genuine-installation-media call :dk_color %_Yellow% "%mas%genuine-installation-media" @@ -12914,7 +11199,6 @@ exit /b :: Process Office MSI Version call :ks_reset -set _oMSI=1 if "%1"=="14" ( call :dk_actids 59a52881-a989-479d-af46-f275c6370663 @@ -12931,11 +11215,25 @@ echo "%2" | find /i "Wow6432Node" %nul1% && set _oArch=x86 if not "%osarch%"=="x86" if not defined _oArch set _oArch=x64 if "%osarch%"=="x86" set _oArch=x86 -call :msiofficedata %2 +set "_common=%CommonProgramFiles%" +if defined PROCESSOR_ARCHITEW6432 set "_common=%CommonProgramW6432%" +set "_common2=%CommonProgramFiles(x86)%" + +for /r "%_common%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" +if not defined _oBranding for /r "%_common2%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" + +call :ksdata getmsiprod %2 +call :ks_msiretaildata getmsiret %2 echo: echo Processing Office... [MSI ^| %_version% ^| %_oArch%] +if not defined _oBranding ( +set error=1 +call :dk_color %Red% "Checking BRANDING.XML [Not Found. Aborting activation...]" +exit /b +) + if not defined _oIds ( set error=1 call :dk_color %Red% "Checking Installed Products [Product IDs not found. Aborting activation...]" @@ -12978,9 +11276,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 +11291,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 +11347,8 @@ exit /b ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -13096,13 +11388,8 @@ 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" -set psc=powershell.exe -nop -c - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G +set psc=powershell.exe set run_once= set t_name=Renewal Task @@ -13115,7 +11402,6 @@ set _wmic=0 for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" 2>nul | find /i "computersystem" 1>nul && set _wmic=1 ) -if %winbuild% LSS 9200 set _wmic=1 setlocal EnableDelayedExpansion if exist "%ProgramFiles%\Activation-Renewal\" call :_taskstart>>"%ProgramFiles%\Activation-Renewal\Logs.txt" @@ -13168,7 +11454,7 @@ call :_taskclear-cache :: Check WMI and sppsvc Errors set applist= -net start %_slser% /y %nul% +net start sppsvc /y %nul% if %_wmic% EQU 1 set "chkapp=for /f "tokens=2 delims==" %%a in ('"wmic path %slp% where (ApplicationID='%_wApp%') get ID /VALUE" 2^>nul')" if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM %slp% WHERE ApplicationID=''%_wApp%''').Get()).ID ^| %% {echo ('ID='+$_)}" 2^>nul')" %chkapp% do (if defined applist (call set "applist=!applist! %%a") else (call set "applist=%%a")) @@ -13470,20 +11756,12 @@ exit /b :_taskclear-cache set w= -for %%# in (SppE%w%xtComObj.exe sppsvc.exe SLsvc.exe) do ( +for %%# in (SppE%w%xtComObj.exe sppsvc.exe) do ( reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul% ) 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" @@ -13549,8 +11827,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) @@ -13599,17 +11877,16 @@ for /f %%G in ('%psc% "[Guid]::NewGuid().Guid"') do set "randguid=%%G" set "_temp=%SystemRoot%\Temp\%Random%%randguid%" set nil= -if %winbuild% LSS 7600 (set _vista=_vista) if exist "%_temp%\.*" rmdir /s /q "%_temp%\" %nul% md "%_temp%\" %nul% -call :ks_RenExport renewal%_vista% "%_temp%\Renewal.xml" Unicode -if not defined _int (call :ks_RenExport run_once%_vista% "%_temp%\Run_Once.xml" Unicode) +call :ks_RenExport renewal "%_temp%\Renewal.xml" Unicode +if not defined _int (call :ks_RenExport run_once "%_temp%\Run_Once.xml" Unicode) s%nil%cht%nil%asks /cre%nil%ate /tn "Activation-Renewal" /ru "SYS%nil%TEM" /xml "%_temp%\Renewal.xml" %nul% if not defined _int (s%nil%cht%nil%asks /cre%nil%ate /tn "Activation-Run_Once" /ru "SYS%nil%TEM" /xml "%_temp%\Run_Once.xml" %nul%) 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 +11916,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 +11941,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 @@ -13791,350 +12069,136 @@ exit /b :run_once: -:renewal_vista: - - - - 1999-01-01T12:00:00.34375 - WindowsAddict - Online K-M-S Activation-Renewal - Weekly Task - - - - 1999-01-01T12:00:00.34375 - true - - - - - 1 - - - - - - S-1-5-18 - HighestAvailable - - - - - PT10M - PT1H - true - false - - IgnoreNew - false - true - true - true - true - - true - true - false - false - false - PT10M - 7 - - PT5M - 3 - - - - - %ProgramFiles%\Activation-Renewal\Activation_task.cmd - Task - - - -:renewal_vista: - -:run_once_vista: - - - - 1999-01-01T12:00:00.34375 - WindowsAddict - Online K-M-S Activation Run Once - Run and Delete itself on first Internet Contact - - - - true - - - - - S-1-5-18 - HighestAvailable - - - - - PT10M - PT1H - true - false - - IgnoreNew - false - true - true - true - true - - true - true - false - false - false - PT10M - 7 - - PT5M - 3 - - - - - %ProgramFiles%\Activation-Renewal\Activation_task.cmd - Task - - - -:run_once_vista: - -::======================================================================================================================================== - -:: 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 -:: 4th column = Edition -:: 5th column = Other Edition IDs if they are part of the same primary product (For reference only) +:: 3rd column = Edition +:: 4th column = Other Edition IDs if they are part of the same primary product (For reference only) :: Separator = "_" -:msiofficedata +:ks_msiretaildata for %%# in ( -14_4d463c2c-0505-4626-8cdb-a4da82e2d8ed_0015_AccessR -14_745fb377-0a59-4ca9-b9a9-c359557a2c4e_001C_AccessRuntimeR -14_95ab3ec8-4106-4f9d-b632-03c019d1d23f_0015_AccessVL -14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_0016_ExcelR_[HSExcelR] -14_71dc86ff-f056-40d0-8ffb-9592705c9b76_0016_ExcelVL -14_7004b7f0-6407-4f45-8eac-966e5f868bde_00BA_GrooveR -14_fdad0dfa-417d-4b4f-93e4-64ea8867b7fd_00BA_GrooveVL -14_7b7d1f17-fdcb-4820-9789-9bec6e377821_0013_HomeBusinessR_[HomeBusinessDemoR] -14_19316117-30a8-4773-8fd9-7f7231f4e060_011E_HomeBusinessSubR -14_09e2d37e-474b-4121-8626-58ad9be5776f_002F_HomeStudentR_[HomeStudentDemoR] -14_ef1da464-01c8-43a6-91af-e4e5713744f9_0044_InfoPathR -14_85e22450-b741-430c-a172-a37962c938af_0044_InfoPathVL -14_14f5946a-debc-4716-babc-7e2c240fec08_000F_MondoR -14_533b656a-4425-480b-8e30-1a2358898350_000F_MondoVL -14_c1ceda8b-c578-4d5d-a4aa-23626be4e234_003D_ProfessionalR_[OEM-SingleImage]Exception -14_3f7aa693-9a7e-44fc-9309-bb3d8e604925_00A1_OneNoteR_[HSOneNoteR] -14_6860b31f-6a67-48b8-84b9-e312b3485c4b_00A1_OneNoteVL -14_fbf4ac36-31c8-4340-8666-79873129cf40_001A_OutlookR -14_a9aeabd8-63b8-4079-a28e-f531807fd6b8_001A_OutlookVL -14_acb51361-c0db-4895-9497-1831c41f31a6_0033_PersonalR_[PersonalDemoR,PersonalPrepaidR] -14_133c8359-4e93-4241-8118-30bb18737ea0_0018_PowerPointR_[HSPowerPointR] -14_38252940-718c-4aa6-81a4-135398e53851_0018_PowerPointVL -14_8b559c37-0117-413e-921b-b853aeb6e210_0014_ProfessionalR_[ProfessionalAcadR,ProfessionalDemoR] -14_725714d7-d58f-4d12-9fa8-35873c6f7215_003B_ProjectProR_[ProjectProMSDNR] -14_4d06f72e-fd50-4bc2-a24b-d448d7f17ef2_011F_ProjectProSubR -14_1cf57a59-c532-4e56-9a7d-ffa2fe94b474_003B_ProjectProVL -14_688f6589-2bd9-424e-a152-b13f36aa6de1_003A_ProjectStdR -14_11b39439-6b93-4642-9570-f2eb81be2238_003A_ProjectStdVL -14_71af7e84-93e6-4363-9b69-699e04e74071_0011_ProPlusR_[ProPlusAcadR,ProPlusMSDNR,Sub4R] -14_e98ef0c0-71c4-42ce-8305-287d8721e26c_011D_ProPlusSubR -14_fdf3ecb9-b56f-43b2-a9b8-1b48b6bae1a7_0011_ProPlusVL_[ProPlusAcadVL] -14_98677603-a668-4fa4-9980-3f1f05f78f69_0019_PublisherR -14_3d014759-b128-4466-9018-e80f6320d9d0_0019_PublisherVL -14_dbe3aee0-5183-4ff7-8142-66050173cb01_008B_SmallBusBasicsR_[SmallBusBasicsMSDNR] -14_8090771e-d41a-4482-929e-de87f1f47e46_008B_SmallBusBasicsVL -14_b78df69e-0966-40b1-ae85-30a5134dedd0_0017_SPDR -14_d3422cfb-8d8b-4ead-99f9-eab0ccd990d7_0012_StandardR -14_1f76e346-e0be-49bc-9954-70ec53a4fcfe_0012_StandardVL_[StandardAcadVL] -14_2745e581-565a-4670-ae90-6bf7c57ffe43_0066_StarterR -14_66cad568-c2dc-459d-93ec-2f3cb967ee34_0057_VisioSIR_Prem[Pro,Std]Exception -14_36756cb8-8e69-4d11-9522-68899507cd6a_0057_VisioSIVL_Prem[Pro,Std]Exception -14_db3bbc9c-ce52-41d1-a46f-1a1d68059119_001B_WordR_[HSWordR] -14_98d4050e-9c98-49bf-9be1-85e12eb3ab13_001B_WordVL +:: Office 2010 +14_4d463c2c-0505-4626-8cdb-a4da82e2d8ed_AccessR +14_745fb377-0a59-4ca9-b9a9-c359557a2c4e_AccessRuntimeR +14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_ExcelR +14_7004b7f0-6407-4f45-8eac-966e5f868bde_GrooveR +14_7b7d1f17-fdcb-4820-9789-9bec6e377821_HomeBusinessR_[HomeBusinessDemoR] +14_19316117-30a8-4773-8fd9-7f7231f4e060_HomeBusinessSubR +14_09e2d37e-474b-4121-8626-58ad9be5776f_HomeStudentR_[HomeStudentDemoR] +14_c3ae020c-5a71-4cc5-a27a-2a97c2d46860_HSExcelR +14_25fe4611-b44d-49cc-ae87-2143d299194e_HSOneNoteR +14_d652ad8d-da5c-4358-b928-7fb1b4de7a7c_HSPowerPointR +14_a963d7ae-7a88-41a7-94da-8bb5635a8af9_HSWordR +14_ef1da464-01c8-43a6-91af-e4e5713744f9_InfoPathR +14_14f5946a-debc-4716-babc-7e2c240fec08_MondoR +14_c1ceda8b-c578-4d5d-a4aa-23626be4e234_OEM +14_3f7aa693-9a7e-44fc-9309-bb3d8e604925_OneNoteR +14_fbf4ac36-31c8-4340-8666-79873129cf40_OutlookR +14_acb51361-c0db-4895-9497-1831c41f31a6_PersonalR_[PersonalDemoR,PersonalPrepaidR] +14_133c8359-4e93-4241-8118-30bb18737ea0_PowerPointR +14_8b559c37-0117-413e-921b-b853aeb6e210_ProfessionalR_[ProfessionalAcadR,ProfessionalDemoR] +14_725714d7-d58f-4d12-9fa8-35873c6f7215_ProjectProR_[ProjectProMSDNR] +14_4d06f72e-fd50-4bc2-a24b-d448d7f17ef2_ProjectProSubR +14_688f6589-2bd9-424e-a152-b13f36aa6de1_ProjectStdR +14_71af7e84-93e6-4363-9b69-699e04e74071_ProPlusR_[ProPlusAcadR,ProPlusMSDNR,Sub4R] +14_e98ef0c0-71c4-42ce-8305-287d8721e26c_ProPlusSubR +14_98677603-a668-4fa4-9980-3f1f05f78f69_PublisherR +14_dbe3aee0-5183-4ff7-8142-66050173cb01_SmallBusBasicsR_[SmallBusBasicsMSDNR] +14_b78df69e-0966-40b1-ae85-30a5134dedd0_SPDR +14_d3422cfb-8d8b-4ead-99f9-eab0ccd990d7_StandardR +14_2745e581-565a-4670-ae90-6bf7c57ffe43_StarterR +14_66cad568-c2dc-459d-93ec-2f3cb967ee34_VisioSIR_Prem[Pro,Std] +14_db3bbc9c-ce52-41d1-a46f-1a1d68059119_WordR :: Office 2013 -15_ab4d047b-97cf-4126-a69f-34df08e2f254_0015_AccessRetail -15_259de5be-492b-44b3-9d78-9645f848f7b0_001C_AccessRuntimeRetail -15_4374022d-56b8-48c1-9bb7-d8f2fc726343_0015_AccessVolume -15_1b1d9bd5-12ea-4063-964c-16e7e87d6e08_0016_ExcelRetail -15_ac1ae7fd-b949-4e04-a330-849bc40638cf_0016_ExcelVolume -15_cfaf5356-49e3-48a8-ab3c-e729ab791250_00BA_GrooveRetail -15_4825ac28-ce41-45a7-9e6e-1fed74057601_00BA_GrooveVolume -15_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_00E7_HomeBusinessPipcRetail -15_cd256150-a898-441f-aac0-9f8f33390e45_0013_HomeBusinessRetail -15_1fdfb4e4-f9c9-41c4-b055-c80daf00697d_00CE_HomeStudentARMRetail -15_ebef9f05-5273-404a-9253-c5e252f50555_00DA_HomeStudentPlusARMRetail -15_98685d21-78bd-4c62-bc4f-653344a63035_002F_HomeStudentRetail -15_44984381-406e-4a35-b1c3-e54f499556e2_0044_InfoPathRetail -15_9e016989-4007-42a6-8051-64eb97110cf2_0044_InfoPathVolume -15_9103f3ce-1084-447a-827e-d6097f68c895_00EA_LyncAcademicRetail -15_ff693bf4-0276-4ddb-bb42-74ef1a0c9f4d_012D_LyncEntryRetail -15_fada6658-bfc6-4c4e-825a-59a89822cda8_012C_LyncRetail -15_e1264e10-afaf-4439-a98b-256df8bb156f_012C_LyncVolume -15_3169c8df-f659-4f95-9cc6-3115e6596e83_000F_MondoRetail -15_f33485a0-310b-4b72-9a0e-b1d605510dbd_000F_MondoVolume -15_3391e125-f6e4-4b1e-899c-a25e6092d40d_00A1_OneNoteFreeRetail -15_8b524bcc-67ea-4876-a509-45e46f6347e8_00A1_OneNoteRetail -15_b067e965-7521-455b-b9f7-c740204578a2_00A1_OneNoteVolume -15_12004b48-e6c8-4ffa-ad5a-ac8d4467765a_001A_OutlookRetail -15_8d577c50-ae5e-47fd-a240-24986f73d503_001A_OutlookVolume -15_5aab8561-1686-43f7-9ff5-2c861da58d17_00E6_PersonalPipcRetail -15_17e9df2d-ed91-4382-904b-4fed6a12caf0_0033_PersonalRetail -15_31743b82-bfbc-44b6-aa12-85d42e644d5b_0018_PowerPointRetail -15_e40dcb44-1d5c-4085-8e8f-943f33c4f004_0018_PowerPointVolume -15_4e26cac1-e15a-4467-9069-cb47b67fe191_00E8_ProfessionalPipcRetail -15_44bc70e2-fb83-4b09-9082-e5557e0c2ede_0014_ProfessionalRetail -15_f2435de4-5fc0-4e5b-ac97-34f515ec5ee7_003B_ProjectProRetail -15_ed34dc89-1c27-4ecd-8b2f-63d0f4cedc32_003B_ProjectProVolume -15_5517e6a2-739b-4822-946f-7f0f1c5934b1_003A_ProjectStdRetail -15_2b9e4a37-6230-4b42-bee2-e25ce86c8c7a_003A_ProjectStdVolume -15_064383fa-1538-491c-859b-0ecab169a0ab_0011_ProPlusRetail -15_2b88c4f2-ea8f-43cd-805e-4d41346e18a7_0011_ProPlusVolume -15_c3a0814a-70a4-471f-af37-2313a6331111_0019_PublisherRetail -15_38ea49f6-ad1d-43f1-9888-99a35d7c9409_0019_PublisherVolume -15_ba3e3833-6a7e-445a-89d0-7802a9a68588_0017_SPDRetail -15_32255c0a-16b4-4ce2-b388-8a4267e219eb_0012_StandardRetail -15_a24cca51-3d54-4c41-8a76-4031f5338cb2_0012_StandardVolume -15_15d12ad4-622d-4257-976c-5eb3282fb93d_0051_VisioProRetail -15_3e4294dd-a765-49bc-8dbd-cf8b62a4bd3d_0051_VisioProVolume -15_dae597ce-5823-4c77-9580-7268b93a4b23_0053_VisioStdRetail -15_44a1f6ff-0876-4edb-9169-dbb43101ee89_0053_VisioStdVolume -15_191509f2-6977-456f-ab30-cf0492b1e93a_001B_WordRetail -15_9cedef15-be37-4ff0-a08a-13a045540641_001B_WordVolume +15_ab4d047b-97cf-4126-a69f-34df08e2f254_AccessRetail +15_259de5be-492b-44b3-9d78-9645f848f7b0_AccessRuntimeRetail +15_1b1d9bd5-12ea-4063-964c-16e7e87d6e08_ExcelRetail +15_cfaf5356-49e3-48a8-ab3c-e729ab791250_GrooveRetail +15_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_HomeBusinessPipcRetail +15_a2b90e7a-a797-4713-af90-f0becf52a1dd_HomeBusinessRetail +15_1fdfb4e4-f9c9-41c4-b055-c80daf00697d_HomeStudentARMRetail +15_ebef9f05-5273-404a-9253-c5e252f50555_HomeStudentPlusARMRetail +15_f2de350d-3028-410a-bfae-283e00b44d0e_HomeStudentRetail +15_44984381-406e-4a35-b1c3-e54f499556e2_InfoPathRetail +15_9103f3ce-1084-447a-827e-d6097f68c895_LyncAcademicRetail +15_ff693bf4-0276-4ddb-bb42-74ef1a0c9f4d_LyncEntryRetail +15_fada6658-bfc6-4c4e-825a-59a89822cda8_LyncRetail +15_69ec9152-153b-471a-bf35-77ec88683eae_MondoRetail +15_3391e125-f6e4-4b1e-899c-a25e6092d40d_OneNoteFreeRetail +15_8b524bcc-67ea-4876-a509-45e46f6347e8_OneNoteRetail +15_12004b48-e6c8-4ffa-ad5a-ac8d4467765a_OutlookRetail +15_5aab8561-1686-43f7-9ff5-2c861da58d17_PersonalPipcRetail +15_17e9df2d-ed91-4382-904b-4fed6a12caf0_PersonalRetail +15_31743b82-bfbc-44b6-aa12-85d42e644d5b_PowerPointRetail +15_064383fa-1538-491c-859b-0ecab169a0ab_ProPlusRetail +15_4e26cac1-e15a-4467-9069-cb47b67fe191_ProfessionalPipcRetail +15_44bc70e2-fb83-4b09-9082-e5557e0c2ede_ProfessionalRetail +15_2f72340c-b555-418d-8b46-355944fe66b8_ProjectProRetail +15_58d95b09-6af6-453d-a976-8ef0ae0316b1_ProjectStdRetail +15_c3a0814a-70a4-471f-af37-2313a6331111_PublisherRetail +15_ba3e3833-6a7e-445a-89d0-7802a9a68588_SPDRetail +15_32255c0a-16b4-4ce2-b388-8a4267e219eb_StandardRetail +15_a56a3b37-3a35-4bbb-a036-eee5f1898eee_VisioProRetail +15_980f9e3e-f5a8-41c8-8596-61404addf677_VisioStdRetail +15_191509f2-6977-456f-ab30-cf0492b1e93a_WordRetail :: Office 365 - 15.0 version -15_befee371-a2f5-4648-85db-a2c55fdf324c_00E9_O365BusinessRetail -15_537ea5b5-7d50-4876-bd38-a53a77caca32_00D6_O365HomePremRetail -15_149dbce7-a48e-44db-8364-a53386cd4580_00D4_O365ProPlusRetail -15_bacd4614-5bef-4a5e-bafc-de4c788037a2_00D5_O365SmallBusPremRetail +15_6337137e-7c07-4197-8986-bece6a76fc33_O365BusinessRetail +15_537ea5b5-7d50-4876-bd38-a53a77caca32_O365HomePremRetail +15_149dbce7-a48e-44db-8364-a53386cd4580_O365ProPlusRetail +15_bacd4614-5bef-4a5e-bafc-de4c788037a2_O365SmallBusPremRetail :: Office 365 - 16.0 version -16_6337137e-7c07-4197-8986-bece6a76fc33_00E9_O365BusinessRetail -16_2f5c71b4-5b7a-4005-bb68-f9fac26f2ea3_00D6_O365EduCloudRetail -16_537ea5b5-7d50-4876-bd38-a53a77caca32_00D6_O365HomePremRetail -16_149dbce7-a48e-44db-8364-a53386cd4580_00D4_O365ProPlusRetail -16_bacd4614-5bef-4a5e-bafc-de4c788037a2_00D5_O365SmallBusPremRetail +16_6337137e-7c07-4197-8986-bece6a76fc33_O365BusinessRetail +16_2f5c71b4-5b7a-4005-bb68-f9fac26f2ea3_O365EduCloudRetail +16_537ea5b5-7d50-4876-bd38-a53a77caca32_O365HomePremRetail +16_149dbce7-a48e-44db-8364-a53386cd4580_O365ProPlusRetail +16_bacd4614-5bef-4a5e-bafc-de4c788037a2_O365SmallBusPremRetail :: Office 2016 -16_bfa358b0-98f1-4125-842e-585fa13032e6_0015_AccessRetail -16_9d9faf9e-d345-4b49-afce-68cb0a539c7c_001C_AccessRuntimeRetail -16_3b2fa33f-cd5a-43a5-bd95-f49f3f546b0b_0015_AccessVolume -16_424d52ff-7ad2-4bc7-8ac6-748d767b455d_0016_ExcelRetail -16_685062a7-6024-42e7-8c5f-6bb9e63e697f_0016_ExcelVolume -16_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_00E7_HomeBusinessPipcRetail -16_86834d00-7896-4a38-8fae-32f20b86fa2b_0013_HomeBusinessRetail -16_090896a0-ea98-48ac-b545-ba5da0eb0c9c_00CE_HomeStudentARMRetail -16_6bbe2077-01a4-4269-bf15-5bf4d8efc0b2_00DA_HomeStudentPlusARMRetail -16_c28acdb8-d8b3-4199-baa4-024d09e97c99_002F_HomeStudentRetail -16_e2127526-b60c-43e0-bed1-3c9dc3d5a468_002F_HomeStudentVNextRetail -16_b21367df-9545-4f02-9f24-240691da0e58_000F_MondoRetail -16_2cd0ea7e-749f-4288-a05e-567c573b2a6c_000F_MondoVolume -16_436366de-5579-4f24-96db-3893e4400030_00A3_OneNoteFreeRetail -16_83ac4dd9-1b93-40ed-aa55-ede25bb6af38_00A1_OneNoteRetail -16_23b672da-a456-4860-a8f3-e062a501d7e8_00A1_OneNoteVolume -16_5a670809-0983-4c2d-8aad-d3c2c5b7d5d1_001A_OutlookRetail -16_50059979-ac6f-4458-9e79-710bcb41721a_001A_OutlookVolume -16_5aab8561-1686-43f7-9ff5-2c861da58d17_00E6_PersonalPipcRetail -16_a9f645a1-0d6a-4978-926a-abcb363b72a6_0033_PersonalRetail -16_f32d1284-0792-49da-9ac6-deb2bc9c80b6_0018_PowerPointRetail -16_9b4060c9-a7f5-4a66-b732-faf248b7240f_0018_PowerPointVolume -16_4e26cac1-e15a-4467-9069-cb47b67fe191_00E8_ProfessionalPipcRetail -16_d64edc00-7453-4301-8428-197343fafb16_0014_ProfessionalRetail -16_0f42f316-00b1-48c5-ada4-2f52b5720ad0_003B_ProjectProRetail -16_82f502b5-b0b0-4349-bd2c-c560df85b248_003B_ProjectProVolume -16_16728639-a9ab-4994-b6d8-f81051e69833_003B_ProjectProXVolume -16_e9f0b3fc-962f-4944-ad06-05c10b6bcd5e_003A_ProjectStdRetail -16_82e6b314-2a62-4e51-9220-61358dd230e6_003A_ProjectStdVolume -16_431058f0-c059-44c5-b9e7-ed2dd46b6789_003A_ProjectStdXVolume -16_de52bd50-9564-4adc-8fcb-a345c17f84f9_0011_ProPlusRetail -16_c47456e3-265d-47b6-8ca0-c30abbd0ca36_0011_ProPlusVolume -16_6e0c1d99-c72e-4968-bcb7-ab79e03e201e_0019_PublisherRetail -16_fcc1757b-5d5f-486a-87cf-c4d6dedb6032_0019_PublisherVolume -16_971cd368-f2e1-49c1-aedd-330909ce18b6_012D_SkypeforBusinessEntryRetail -16_418d2b9f-b491-4d7f-84f1-49e27cc66597_012C_SkypeforBusinessRetail -16_03ca3b9a-0869-4749-8988-3cbc9d9f51bb_012C_SkypeforBusinessVolume -16_9103f3ce-1084-447a-827e-d6097f68c895_012C_SkypeServiceBypassRetail -16_4a31c291-3a12-4c64-b8ab-cd79212be45e_0012_StandardRetail -16_0ed94aac-2234-4309-ba29-74bdbb887083_0012_StandardVolume -16_2dfe2075-2d04-4e43-816a-eb60bbb77574_0051_VisioProRetail -16_295b2c03-4b1c-4221-b292-1411f468bd02_0051_VisioProVolume -16_0594dc12-8444-4912-936a-747ca742dbdb_0051_VisioProXVolume -16_c76dbcbc-d71b-4f45-b5b3-b7494cb4e23e_0053_VisioStdRetail -16_44151c2d-c398-471f-946f-7660542e3369_0053_VisioStdVolume -16_1d1c6879-39a3-47a5-9a6d-aceefa6a289d_0053_VisioStdXVolume -16_cacaa1bf-da53-4c3b-9700-11738ef1c2a5_001B_WordRetail -16_c3000759-551f-4f4a-bcac-a4b42cbf1de2_001B_WordVolume +16_bfa358b0-98f1-4125-842e-585fa13032e6_AccessRetail +16_9d9faf9e-d345-4b49-afce-68cb0a539c7c_AccessRuntimeRetail +16_424d52ff-7ad2-4bc7-8ac6-748d767b455d_ExcelRetail +16_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_HomeBusinessPipcRetail +16_86834d00-7896-4a38-8fae-32f20b86fa2b_HomeBusinessRetail +16_c28acdb8-d8b3-4199-baa4-024d09e97c99_HomeStudentRetail +16_090896a0-ea98-48ac-b545-ba5da0eb0c9c_HomeStudentARMRetail +16_6bbe2077-01a4-4269-bf15-5bf4d8efc0b2_HomeStudentPlusARMRetail +16_e2127526-b60c-43e0-bed1-3c9dc3d5a468_HomeStudentVNextRetail +16_69ec9152-153b-471a-bf35-77ec88683eae_MondoRetail +16_436366de-5579-4f24-96db-3893e4400030_OneNoteFreeRetail +16_83ac4dd9-1b93-40ed-aa55-ede25bb6af38_OneNoteRetail +16_5a670809-0983-4c2d-8aad-d3c2c5b7d5d1_OutlookRetail +16_5aab8561-1686-43f7-9ff5-2c861da58d17_PersonalPipcRetail +16_a9f645a1-0d6a-4978-926a-abcb363b72a6_PersonalRetail +16_f32d1284-0792-49da-9ac6-deb2bc9c80b6_PowerPointRetail +16_de52bd50-9564-4adc-8fcb-a345c17f84f9_ProPlusRetail +16_4e26cac1-e15a-4467-9069-cb47b67fe191_ProfessionalPipcRetail +16_d64edc00-7453-4301-8428-197343fafb16_ProfessionalRetail +16_2f72340c-b555-418d-8b46-355944fe66b8_ProjectProRetail +16_58d95b09-6af6-453d-a976-8ef0ae0316b1_ProjectStdRetail +16_6e0c1d99-c72e-4968-bcb7-ab79e03e201e_PublisherRetail +16_9103f3ce-1084-447a-827e-d6097f68c895_SkypeServiceBypassRetail +16_971cd368-f2e1-49c1-aedd-330909ce18b6_SkypeforBusinessEntryRetail +16_418d2b9f-b491-4d7f-84f1-49e27cc66597_SkypeforBusinessRetail +16_4a31c291-3a12-4c64-b8ab-cd79212be45e_StandardRetail +16_a56a3b37-3a35-4bbb-a036-eee5f1898eee_VisioProRetail +16_980f9e3e-f5a8-41c8-8596-61404addf677_VisioStdRetail +16_cacaa1bf-da53-4c3b-9700-11738ef1c2a5_WordRetail ) do ( for /f "tokens=1-5 delims=_" %%A in ("%%#") do ( -if "%oVer%"=="%%A" ( -reg query "%1\Registration\{%%B}" /v ProductCode %nul2% | find /i "-%%C-" %nul% && ( -reg query "%1\Common\InstalledPackages" %nul2% | find /i "-%%C-" %nul% && ( -if defined _oIds (set _oIds=!_oIds! %%D) else (set _oIds=%%D) -if /i 003D==%%C set SingleImage=1 +if %1==getmsiret if "%oVer%"=="%%A" ( +for /f "tokens=*" %%x in ('findstr /i /c:"%%B" "%_oBranding%"') do set "prodId=%%x" +set prodId=!prodId:"/>=! +set prodId=!prodId:~-4! +if "%oVer%"=="14" ( +REM Exception case for Visio because wrong primary product ID is mentioned in Branding.xml +echo %%C | find /i "Visio" %nul% && set prodId=0057 +) +reg query "%2\Registration\{%%B}" /v ProductCode %nul2% | find /i "-!prodId!-" %nul% && ( +reg query "%2\Common\InstalledPackages" %nul2% | find /i "-!prodId!-" %nul% && ( +if defined _oIds (set _oIds=!_oIds! %%C) else (set _oIds=%%C) ) ) ) @@ -14278,22 +12342,7 @@ a78b8bd9-8017-4df5-b86a-09f756affa7c_6TPJF-RBVHG-WBW2R-86QPH-6R%f%TM4__17_Server cda18cf3-c196-46ad-b289-60c072869994_TT8MH-CG224-D3D7Q-498W2-9Q%f%CTX__18_ServerHPC a78b8bd9-8017-4df5-b86a-09f756affa7c_6TPJF-RBVHG-WBW2R-86QPH-6R%f%TM4__29_ServerWebCore f772515c-0e87-48d5-a676-e6962c3e1195_736RG-XDKJK-V34PF-BHK87-J6%f%X3K__56_ServerEmbeddedSolution -:: Windows Vista -cfd8ff08-c0d7-452b-9f60-ef5c70c32094_VKK3X-68KWM-X2YGT-QR4M6-4B%f%WMV___4_Enterprise -4f3d1606-3fea-4c01-be3c-8d671c401e3b_YFKBB-PQJJV-G996G-VWGXY-2V%f%3X8___6_Business -2c682dc2-8b68-4f63-a165-ae291d4cf138_HMBQG-8H2RH-C77VX-27R82-VM%f%QBT__16_BusinessN -d4f54950-26f2-4fb4-ba21-ffab16afcade_VTC42-BM838-43QHV-84HX6-XJ%f%XKV__27_EnterpriseN -:: Windows Server 2008 -ad2542d4-9154-4c6d-8a44-30f11ee96989_TM24T-X9RMF-VWXK6-X8JC9-BF%f%GM2___7_ServerStandard -68b6e220-cf09-466b-92d3-45cd964b9509_7M67G-PC374-GR742-YH8V4-TC%f%BY3___8_ServerDatacenter -c1af4d90-d1bc-44ca-85d4-003ba33db3b9_YQGMW-MPWTJ-34KDK-48M3W-X4%f%Q6V__10_ServerEnterprise -01ef176b-3e0d-422a-b4f8-4ea880035e8f_4DWFP-JF3DJ-B7DTH-78FJB-PD%f%RHK__15_ServerEnterpriseIA64 -ddfa9f7c-f09e-40b9-8c1a-be877a9a7f4b_WYR28-R7TFJ-3X2YQ-YCY4H-M2%f%49D__17_ServerWeb -7afb1156-2c1d-40fc-b260-aab7442b62fe_RCTX3-KWVHP-BR6TB-RB6DM-6X%f%7HP__18_ServerComputeCluster -2401e3d0-c50a-4b58-87b2-7e794b7d2607_W7VD6-7JFBR-RX26B-YKQ3Y-6F%f%FFJ__36_ServerStandardV -fd09ef77-5647-4eff-809c-af2b64659a45_22XQ2-VRXRG-P8D42-K34TD-G3%f%QQC__37_ServerDatacenterV -8198490a-add0-47b2-b3ba-316b12d647b4_39BXF-X8Q23-P2WWT-38T2F-G3%f%FPG__38_ServerEnterpriseV -::======================================================================================================================================= +::======================================================================================================================================== :: Office 2010 8ce7e872-188c-4b98-9d90-f8f90b7aad02_V7Y44-9T38C-R2VJK-666HK-T7%f%DDX__14_AccessVL cee5d470-6e3b-4fcc-8c2b-d17428568a9f_H62QG-HXVKF-PP4HP-66KMR-CW%f%9BM__14_ExcelVL @@ -14340,7 +12389,7 @@ d9f5b1c6-5386-495a-88f9-9ad6b41ac9b3_6Q7VD-NX8JD-WJ2VH-88V73-4G%f%BJ7__15_WordVo 67c0fc0c-deba-401b-bf8b-9c8ad8395804_GNH9Y-D2J4T-FJHGG-QRVH7-QP%f%FDW__16_AccessVolume_-AccessRetail- c3e65d36-141f-4d2f-a303-a842ee756a29_9C2PK-NWTVB-JMPW8-BFT28-7F%f%TBF__16_ExcelVolume_-ExcelRetail- e914ea6e-a5fa-4439-a394-a9bb3293ca09_DMTCJ-KNRKX-26982-JYCKT-P7%f%KB6__16_MondoRetail -9caabccb-61b1-4b4b-8bec-d10a3c3ac2ce_HFTND-W9MK4-8B7MJ-B6C4G-XQ%f%BR2__16_MondoVolume_-O365AppsBasicRetail-O365BusinessRetail-O365EduCloudRetail-O365HomePremRetail-O365ProPlusRetail-O365SmallBusPremRetail- +9caabccb-61b1-4b4b-8bec-d10a3c3ac2ce_HFTND-W9MK4-8B7MJ-B6C4G-XQ%f%BR2__16_MondoVolume_-O365BusinessRetail-O365EduCloudRetail-O365HomePremRetail-O365ProPlusRetail-O365SmallBusPremRetail- 436366de-5579-4f24-96db-3893e4400030_XYNTG-R96FY-369HX-YFPHY-F9%f%CPM__16_OneNoteFreeRetail_[Bypass] d8cace59-33d2-4ac7-9b1b-9b72339c51c8_DR92N-9HTF2-97XKM-XW2WJ-XW%f%3J6__16_OneNoteVolume_-OneNoteRetail-OneNote2021Retail- ec9d9265-9d1e-4ed0-838a-cdc20f2551a1_R69KK-NTPKF-7M3Q4-QYBHW-6M%f%T9B__16_OutlookVolume_-OutlookRetail- @@ -14425,7 +12474,7 @@ if /i "%2"=="%%D" ( set key=%%B set _actid=%%A set _allactid=!_allactid! %%A -) else if not defined _oMSI if %_NoEditionChange%==0 ( +) else if not defined _oBranding if %_NoEditionChange%==0 ( echo: %%E | find /i "-%2-" %nul% && ( set key=%%B set _altoffid=%%D @@ -14435,44 +12484,21 @@ set _allactid=!_allactid! %%A ) ) +if %1==getmsiprod if "%oVer%"=="%%C" ( +for /f "tokens=*" %%x in ('findstr /i /c:"%%A" "%_oBranding%"') do set "prodId=%%x" +set prodId=!prodId:"/>=! +set prodId=!prodId:~-4! +if "%oVer%"=="14" ( +REM Exception case for Visio because wrong primary product ID is mentioned in Branding.xml +echo %%D | find /i "Visio" %nul% && set prodId=0057 +) +reg query "%2\Registration\{%%A}" /v ProductCode %nul2% | find /i "-!prodId!-" %nul% && ( +reg query "%2\Common\InstalledPackages" %nul2% | find /i "-!prodId!-" %nul% && ( +if defined _oIds (set _oIds=!_oIds! %%D) else (set _oIds=%%D) ) ) -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 @@ -14487,7 +12513,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: @@ -14562,7 +12588,6 @@ $IID = $IID.IsPresent -Or $Dlv.IsPresent $NT6 = $winbuild -GE 6000 $NT7 = $winbuild -GE 7600 -$NT8 = $winbuild -GE 9200 $NT9 = $winbuild -GE 9600 $Admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) @@ -14638,289 +12663,55 @@ function CheckOhook & $noAll } -#region SSSS -function BoolToWStr($bVal) { - ("TRUE", "FALSE")[!$bVal] -} - -function InitializePInvoke($LaDll, $bOffice) { - $LaName = [IO.Path]::GetFileNameWithoutExtension($LaDll) - $SLApp = $NT7 -Or $bOffice -Or ($LaName -EQ 'sppc' -And [Diagnostics.FileVersionInfo]::GetVersionInfo("$SysPath\sppc.dll").FilePrivatePart -GE 16501) - $Win32 = $null - - $Marshal = [System.Runtime.InteropServices.Marshal] - $Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly(($LaName+"_Assembly"), 'Run').DefineDynamicModule(($LaName+"_Module"), $False) - $Class = $Module.DefineType(($LaName+"_Methods"), 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0) - - $Class.DefinePInvokeMethod('SLClose', $LaDll, 22, 1, [Int32], @([IntPtr]), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLOpen', $LaDll, 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGenerateOfflineInstallationId', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetSLIDList', $LaDll, 22, 1, [Int32], @([IntPtr], [UInt32], [Guid].MakeByRefType(), [UInt32], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetLicensingStatusInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [Guid].MakeByRefType(), [IntPtr], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetPKeyInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetProductSkuInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetServiceInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - if ($SLApp) { - $Class.DefinePInvokeMethod('SLGetApplicationInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - } - if ($bOffice) { - $Win32 = $Class.CreateType() - return - } - if ($NT6) { - $Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLIsGenuineLocal', 'slwga.dll', 22, 1, [Int32], @([Guid].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr]), 1, 3).SetImplementationFlags(128) - } - if ($NT7) { - $Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig') - } - - if ($DllSubscription) { - $Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0) - [void]$Struct.DefineField('dwEnabled', [UInt32], 'Public') - [void]$Struct.DefineField('dwSku', [UInt32], 6) - [void]$Struct.DefineField('dwState', [UInt32], 6) - $SubStatus = $Struct.CreateType() - } - - $Win32 = $Class.CreateType() -} - -function SlGetInfoIID($SkuId) +#region WMI +function DetectID($strSLP, $strAppId) { - $bData = 0 - - if ($Win32::SLGenerateOfflineInstallationId( - $hSLC, - [ref][Guid]$SkuId, - [ref]$bData - )) - { - return $null - } - else - { - return $Marshal::PtrToStringUni($bData) - } + $ppk = (" AND PartialProductKey <> NULL)", ")")[$All.IsPresent] + $fltr = "SELECT ID FROM $strSLP WHERE (ApplicationID='$strAppId'" + $clause = $fltr + $ppk + $sWmi = [wmisearcher]$clause + $sWmi.Options.Rewindable = $false + return ($sWmi.Get().Count -GT 0) } -function SlReturnData($hrRet, $tData, $cData, $bData) { - if ($hrRet -NE 0 -Or $cData -EQ 0) - { - return $null - } - if ($tData -EQ 1) - { - return $Marshal::PtrToStringUni($bData) - } - elseif ($tData -EQ 4) - { - return $Marshal::ReadInt32($bData) - } - elseif ($tData -EQ 3 -And $cData -EQ 8) - { - return $Marshal::ReadInt64($bData) - } - else - { - return $null - } -} - -function SlGetInfoPKey($PkeyId, $Value) +function GetID($strSLP, $strAppId) { - $tData = 0 - $cData = 0 - $bData = 0 + $NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001) + $IDs = [Collections.ArrayList]@() + $isAdd = (" AND LicenseDependsOn <> NULL)", ")")[$NT5] + $noAdd = " AND LicenseDependsOn IS NULL)" + $query = "SELECT ID FROM $strSLP WHERE (ApplicationID='$strAppId' AND PartialProductKey" - $hrRet = $Win32::SLGetPKeyInformation( - $hSLC, - [ref][Guid]$PkeyId, - $Value, - [ref]$tData, - [ref]$cData, - [ref]$bData - ) - - return SlReturnData $hrRet $tData $cData $bData -} - -function SlGetInfoSku($SkuId, $Value) -{ - $tData = 0 - $cData = 0 - $bData = 0 - - $hrRet = $Win32::SLGetProductSkuInformation( - $hSLC, - [ref][Guid]$SkuId, - $Value, - [ref]$tData, - [ref]$cData, - [ref]$bData - ) - - return SlReturnData $hrRet $tData $cData $bData -} - -function SlGetInfoApp($AppId, $Value) -{ - $tData = 0 - $cData = 0 - $bData = 0 - - $hrRet = $Win32::SLGetApplicationInformation( - $hSLC, - [ref][Guid]$AppId, - $Value, - [ref]$tData, - [ref]$cData, - [ref]$bData - ) - - return SlReturnData $hrRet $tData $cData $bData -} - -function SlGetInfoService($Value) -{ - $tData = 0 - $cData = 0 - $bData = 0 - - $hrRet = $Win32::SLGetServiceInformation( - $hSLC, - $Value, - [ref]$tData, - [ref]$cData, - [ref]$bData - ) - - return SlReturnData $hrRet $tData $cData $bData -} - -function SlGetInfoSvcApp($strApp, $Value) -{ - if ($SLApp) - { - return SlGetInfoApp $strApp $Value - } - else - { - return SlGetInfoService $Value - } -} - -function SlGetInfoLicensing($AppId, $SkuId) -{ - $dwStatus = 0 - $dwGrace = 0 - $hrReason = 0 - $qwValidity = 0 - - $cStatus = 0 - $pStatus = 0 - - $hrRet = $Win32::SLGetLicensingStatusInformation( - $hSLC, - [ref][Guid]$AppId, - [ref][Guid]$SkuId, - 0, - [ref]$cStatus, - [ref]$pStatus - ) - - if ($hrRet -NE 0 -Or $cStatus -EQ 0) - { - return - } - - [IntPtr]$ppStatus = [Int64]$pStatus + [Int64]40 * ($cStatus - 1) - $dwStatus = $Marshal::ReadInt32($ppStatus, 16) - $dwGrace = $Marshal::ReadInt32($ppStatus, 20) - $hrReason = $Marshal::ReadInt32($ppStatus, 28) - $qwValidity = $Marshal::ReadInt64($ppStatus, 32) - - if ($dwStatus -EQ 3) - { - $dwStatus = 5 - } - if ($dwStatus -EQ 2) - { - if ($hrReason -EQ 0x4004F00D) - { - $dwStatus = 3 - } - elseif ($hrReason -EQ 0x4004F065) - { - $dwStatus = 4 - } - elseif ($hrReason -EQ 0x4004FC06) - { - $dwStatus = 6 + if ($All.IsPresent) { + $fltr = $query + " IS NULL" + $clause = $fltr + $isAdd + $sWmi = [wmisearcher]$clause + $sWmi.Options.Rewindable = $false + try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {} + if (-Not $NT5) { + $clause = $fltr + $noAdd + $sWmi = [wmisearcher]$clause + $sWmi.Options.Rewindable = $false + try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {} } } - return -} - -function SlGetInfoSLID($AppId) -{ - $cReturnIds = 0 - $pReturnIds = 0 - - $hrRet = $Win32::SLGetSLIDList( - $hSLC, - 0, - [ref][Guid]$AppId, - 1, - [ref]$cReturnIds, - [ref]$pReturnIds - ) - - if ($hrRet -NE 0 -Or $cReturnIds -EQ 0) - { - return + $fltr = $query + " <> NULL" + $clause = $fltr + $isAdd + $sWmi = [wmisearcher]$clause + $sWmi.Options.Rewindable = $false + try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {} + if (-Not $NT5) { + $clause = $fltr + $noAdd + $sWmi = [wmisearcher]$clause + $sWmi.Options.Rewindable = $false + try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {} } - $a1List = @() - $a2List = @() - $a3List = @() - $a4List = @() - - foreach ($i in 0..($cReturnIds - 1)) - { - $bytes = New-Object byte[] 16 - $Marshal::Copy([Int64]$pReturnIds + [Int64]16 * $i, $bytes, 0, 16) - $actid = ([Guid]$bytes).Guid - $gPPK = SlGetInfoSku $actid "pkeyId" - $gAdd = SlGetInfoSku $actid "DependsOn" - if ($All.IsPresent) { - if ($null -EQ $gPPK -And $null -NE $gAdd) { $a1List += @{id = $actid; pk = $null; ex = $true} } - if ($null -EQ $gPPK -And $null -EQ $gAdd) { $a2List += @{id = $actid; pk = $null; ex = $false} } - } - if ($null -NE $gPPK -And $null -NE $gAdd) { $a3List += @{id = $actid; pk = $gPPK; ex = $true} } - if ($null -NE $gPPK -And $null -EQ $gAdd) { $a4List += @{id = $actid; pk = $gPPK; ex = $false} } - } - - return ($a1List + $a2List + $a3List + $a4List) + return $IDs } function DetectSubscription { - try - { - $objSvc = New-Object PSObject - $wmiSvc = [wmisearcher]"SELECT SubscriptionType, SubscriptionStatus, SubscriptionEdition, SubscriptionExpiry FROM SoftwareLicensingService" - $wmiSvc.Options.Rewindable = $false - $wmiSvc.Get() | select -Expand Properties -EA 0 | foreach { $objSvc | Add-Member 8 $_.Name $_.Value } - $wmiSvc.Dispose() - } - catch - { - return - } - if ($null -EQ $objSvc.SubscriptionType -Or $objSvc.SubscriptionType -EQ 120) { return } @@ -14952,267 +12743,208 @@ function DetectSubscription { } CONOUT "`nSubscription information:" + CONOUT " Edition: $SubMsgEdition" CONOUT " Type : $SubMsgType" CONOUT " Status : $SubMsgStatus" - CONOUT " Edition: $SubMsgEdition" CONOUT " Expiry : $SubMsgExpiry" } function DetectAdbaClient { - $propADBA | foreach { set $_ (SlGetInfoSku $licID $_) } - DetectActType CONOUT "`nAD Activation client information:" CONOUT " Object Name: $ADActivationObjectName" CONOUT " Domain Name: $ADActivationObjectDN" - CONOUT " CSVLK Extended PID: $ADActivationCsvlkPID" - CONOUT " CSVLK Activation ID: $ADActivationCsvlkSkuID" + CONOUT " CSVLK Extended PID: $ADActivationCsvlkPid" + CONOUT " CSVLK Activation ID: $ADActivationCsvlkSkuId" } function DetectAvmClient { - $propAVMA | foreach { set $_ (SlGetInfoSku $licID $_) } CONOUT "`nAutomatic VM Activation client information:" - if (-Not [String]::IsNullOrEmpty($InheritedActivationId)) { - CONOUT " Guest IAID: $InheritedActivationId" + if (-Not [String]::IsNullOrEmpty($IAID)) { + CONOUT " Guest IAID: $IAID" } else { CONOUT " Guest IAID: Not Available" } - if (-Not [String]::IsNullOrEmpty($InheritedActivationHostMachineName)) { - CONOUT " Host machine name: $InheritedActivationHostMachineName" + if (-Not [String]::IsNullOrEmpty($AutomaticVMActivationHostMachineName)) { + CONOUT " Host machine name: $AutomaticVMActivationHostMachineName" } else { CONOUT " Host machine name: Not Available" } - if (-Not [String]::IsNullOrEmpty($InheritedActivationHostDigitalPid2)) { - CONOUT " Host Digital PID2: $InheritedActivationHostDigitalPid2" - } else { - CONOUT " Host Digital PID2: Not Available" - } - if ($InheritedActivationActivationTime) { - $IAAT = [DateTime]::FromFileTime($InheritedActivationActivationTime).ToString('yyyy-MM-dd hh:mm:ss tt') - CONOUT " Activation time: $IAAT" + if ($AutomaticVMActivationLastActivationTime.Substring(0,4) -NE "1601") { + $EED = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($AutomaticVMActivationLastActivationTime),$null,48).ToString('yyyy-MM-dd hh:mm:ss tt') + CONOUT " Activation time: $EED UTC" } else { CONOUT " Activation time: Not Available" } + if (-Not [String]::IsNullOrEmpty($AutomaticVMActivationHostDigitalPid2)) { + CONOUT " Host Digital PID2: $AutomaticVMActivationHostDigitalPid2" + } else { + CONOUT " Host Digital PID2: Not Available" + } } function DetectKmsHost { - $IsKeyManagementService = SlGetInfoSvcApp $strApp 'IsKeyManagementService' - if (-Not $IsKeyManagementService) { - return - } - if ($Vista -Or $NT5) { - $regk = $SLKeyPath - } elseif ($strSLP -EQ $oslp) { - $regk = $OPKeyPath + $KeyManagementServiceListeningPort = strGetRegistry $SLKeyPath "KeyManagementServiceListeningPort" + $KeyManagementServiceDnsPublishing = strGetRegistry $SLKeyPath "DisableDnsPublishing" + $KeyManagementServiceLowPriority = strGetRegistry $SLKeyPath "EnableKmsLowPriority" + if (-Not $KeyManagementServiceDnsPublishing) {$KeyManagementServiceDnsPublishing = "TRUE"} + if (-Not $KeyManagementServiceLowPriority) {$KeyManagementServiceLowPriority = "FALSE"} } else { - $regk = $SPKeyPath - } - $KMSListening = strGetRegistry $regk "KeyManagementServiceListeningPort" - $KMSPublishing = strGetRegistry $regk "DisableDnsPublishing" - $KMSPriority = strGetRegistry $regk "EnableKmsLowPriority" - - if (-Not $KMSListening) {$KMSListening = 1688} - if (-Not $KMSPublishing) {$KMSPublishing = "TRUE"} else {$KMSPublishing = BoolToWStr (!$KMSPublishing)} - if (-Not $KMSPriority) {$KMSPriority = "FALSE"} else {$KMSPriority = BoolToWStr $KMSPriority} - - if ($KMSPublishing -EQ "TRUE") {$KMSPublishing = "Enabled"} else {$KMSPublishing = "Disabled"} - if ($KMSPriority -EQ "TRUE") {$KMSPriority = "Low"} else {$KMSPriority = "Normal"} - - if ($SLApp) - { - $propKMSServer | foreach { set $_ (SlGetInfoApp $strApp $_) } - } - else - { - $propKMSServer | foreach { set $_ (SlGetInfoService $_) } + $KeyManagementServiceListeningPort = $objSvc.KeyManagementServiceListeningPort + $KeyManagementServiceDnsPublishing = $objSvc.KeyManagementServiceDnsPublishing + $KeyManagementServiceLowPriority = $objSvc.KeyManagementServiceLowPriority } - $KMSRequests = $KeyManagementServiceTotalRequests - $NoRequests = ($null -EQ $KMSRequests) -Or ($KMSRequests -EQ -1) -Or ($KMSRequests -EQ 4294967295) + if (-Not $KeyManagementServiceListeningPort) {$KeyManagementServiceListeningPort = 1688} + if ($KeyManagementServiceDnsPublishing -EQ "TRUE") { + $KeyManagementServiceDnsPublishing = "Enabled" + } else { + $KeyManagementServiceDnsPublishing = "Disabled" + } + if ($KeyManagementServiceLowPriority -EQ "TRUE") { + $KeyManagementServiceLowPriority = "Low" + } else { + $KeyManagementServiceLowPriority = "Normal" + } CONOUT "`nKey Management Service host information:" CONOUT " Current count: $KeyManagementServiceCurrentCount" - CONOUT " Listening on Port: $KMSListening" - CONOUT " DNS publishing: $KMSPublishing" - CONOUT " KMS priority: $KMSPriority" - if ($NoRequests) { - return + CONOUT " Listening on Port: $KeyManagementServiceListeningPort" + CONOUT " DNS publishing: $KeyManagementServiceDnsPublishing" + CONOUT " KMS priority: $KeyManagementServiceLowPriority" + if (-Not [String]::IsNullOrEmpty($KeyManagementServiceTotalRequests)) { + CONOUT "`nKey Management Service cumulative requests received from clients:" + CONOUT " Total: $KeyManagementServiceTotalRequests" + CONOUT " Failed: $KeyManagementServiceFailedRequests" + CONOUT " Unlicensed: $KeyManagementServiceUnlicensedRequests" + CONOUT " Licensed: $KeyManagementServiceLicensedRequests" + CONOUT " Initial grace period: $KeyManagementServiceOOBGraceRequests" + CONOUT " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests" + CONOUT " Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests" + if ($null -NE $KeyManagementServiceNotificationRequests) {CONOUT " Notification: $KeyManagementServiceNotificationRequests"} } - CONOUT "`nKey Management Service cumulative requests received from clients:" - CONOUT " Total: $KeyManagementServiceTotalRequests" - CONOUT " Failed: $KeyManagementServiceFailedRequests" - CONOUT " Unlicensed: $KeyManagementServiceUnlicensedRequests" - CONOUT " Licensed: $KeyManagementServiceLicensedRequests" - CONOUT " Initial grace period: $KeyManagementServiceOOBGraceRequests" - CONOUT " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests" - CONOUT " Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests" - 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 ($null -NE $VLActivationTypeEnabled) {CONOUT "Configured Activation Type: $($VLActTypes[$VLActivationTypeEnabled])"} CONOUT "`r" if ($LicenseStatus -NE 1) { CONOUT "Please activate the product in order to update KMS client information values." return } - if ($NT7 -Or $strSLP -EQ $oslp) { - $propKMSClient | foreach { set $_ (SlGetInfoSku $licID $_) } - if ($strSLP -EQ $oslp) {$regk = $OPKeyPath} else {$regk = $SPKeyPath} - $KMSCaching = strGetRegistry $regk "DisableKeyManagementServiceHostCaching" - if (-Not $KMSCaching) {$KMSCaching = "TRUE"} else {$KMSCaching = BoolToWStr (!$KMSCaching)} - } - - "ClientMachineID" | foreach { set $_ (SlGetInfoService $_) } - if ($Vista) { - $propKMSVista | foreach { set $_ (SlGetInfoService $_) } $KeyManagementServicePort = strGetRegistry $SLKeyPath "KeyManagementServicePort" - $DiscoveredKeyManagementServiceName = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServiceName" - $DiscoveredKeyManagementServicePort = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServicePort" + $DiscoveredKeyManagementServiceMachineName = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServiceName" + $DiscoveredKeyManagementServiceMachinePort = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServicePort" } - if ([String]::IsNullOrEmpty($KeyManagementServiceName)) { + if ([String]::IsNullOrEmpty($KeyManagementServiceMachine)) { $KmsReg = $null } else { if (-Not $KeyManagementServicePort) {$KeyManagementServicePort = 1688} - $KmsReg = "Registered KMS machine name: ${KeyManagementServiceName}:${KeyManagementServicePort}" + $KmsReg = "Registered KMS machine name: ${KeyManagementServiceMachine}:${KeyManagementServicePort}" } - if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceName)) { + if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceMachineName)) { $KmsDns = "DNS auto-discovery: KMS name not available" if ($Vista -And -Not $Admin) {$KmsDns = "DNS auto-discovery: Run the script as administrator to retrieve info"} } else { - if (-Not $DiscoveredKeyManagementServicePort) {$DiscoveredKeyManagementServicePort = 1688} - $KmsDns = "KMS machine name from DNS: ${DiscoveredKeyManagementServiceName}:${DiscoveredKeyManagementServicePort}" + if (-Not $DiscoveredKeyManagementServiceMachinePort) {$DiscoveredKeyManagementServiceMachinePort = 1688} + $KmsDns = "KMS machine name from DNS: ${DiscoveredKeyManagementServiceMachineName}:${DiscoveredKeyManagementServiceMachinePort}" } - if ($null -NE $KMSCaching) { - if ($KMSCaching -EQ "TRUE") {$KMSCaching = "Enabled"} else {$KMSCaching = "Disabled"} - } - - if ($strSLP -EQ $wslp -And $NT9) { - if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceIpAddress)) { - $DiscoveredKeyManagementServiceIpAddress = "not available" + if ($null -NE $objSvc.KeyManagementServiceHostCaching) { + if ($objSvc.KeyManagementServiceHostCaching -EQ "TRUE") { + $KeyManagementServiceHostCaching = "Enabled" + } else { + $KeyManagementServiceHostCaching = "Disabled" } } CONOUT "Key Management Service client information:" - CONOUT " Client Machine ID (CMID): $ClientMachineID" + CONOUT " Client Machine ID (CMID): $($objSvc.ClientMachineID)" if ($null -EQ $KmsReg) { CONOUT " $KmsDns" CONOUT " Registered KMS machine name: KMS name not available" } else { CONOUT " $KmsReg" } - if ($null -NE $DiscoveredKeyManagementServiceIpAddress) {CONOUT " KMS machine IP address: $DiscoveredKeyManagementServiceIpAddress"} - CONOUT " KMS machine extended PID: $CustomerPID" + if ($null -NE $DiscoveredKeyManagementServiceMachineIpAddress) {CONOUT " KMS machine IP address: $DiscoveredKeyManagementServiceMachineIpAddress"} + CONOUT " KMS machine extended PID: $KeyManagementServiceProductKeyID" CONOUT " Activation interval: $VLActivationInterval minutes" CONOUT " Renewal interval: $VLRenewalInterval minutes" - if ($null -NE $KMSCaching) {CONOUT " KMS host caching: $KMSCaching"} + if ($null -NE $KeyManagementServiceHostCaching) {CONOUT " KMS host caching: $KeyManagementServiceHostCaching"} if (-Not [String]::IsNullOrEmpty($KeyManagementServiceLookupDomain)) {CONOUT " KMS SRV record lookup domain: $KeyManagementServiceLookupDomain"} } -function GetResult($strSLP, $strApp, $entry) +function GetResult($strSLP, $strSLS, $strID) { - $licID = $entry.id - $propPrd | foreach { set $_ (SlGetInfoSku $licID $_) } - . SlGetInfoLicensing $strApp $licID - $LicenseStatus = $dwStatus - $LicReason = $hrReason - $EvaluationEndDate = $qwValidity - $gprMnt = $dwGrace - - $pkid = $entry.pk - $isPPK = $null -NE $pkid - - $add_on = $Name.IndexOf("add-on for", 5) - if ($add_on -NE -1) { - $Name = $Name.Substring(0, $add_on + 7) + try + { + $objPrd = [wmisearcher]"SELECT * FROM $strSLP WHERE ID='$strID'" + $objPrd.Options.Rewindable = $false + $objPrd.Get() | select -Expand Properties -EA 0 | foreach { if (-Not [String]::IsNullOrEmpty($_.Value)) {set $_.Name $_.Value} } + $objPrd.Dispose() } - - $licPHN = "empty" - if ($Dlv -Or $All.IsPresent) { - $licPHN = SlGetInfoSku $licID "msft:sl/EUL/PHONE/PUBLIC" - } - - if ($LicenseStatus -EQ 0 -And !$isPPK) { - & $isAll - CONOUT "Name: $Name" - CONOUT "Description: $Description" - CONOUT "Activation ID: $licID" - CONOUT "License Status: Unlicensed" - if ($licPHN -NE "empty") { - $gPHN = [String]::IsNullOrEmpty($licPHN) -NE $true - CONOUT "Phone activatable: $($gPHN.ToString())" - } + catch + { return } - $winID = ($strApp -EQ $winApp) - $winPR = ($winID -And -Not $entry.ex) + $winID = ($ApplicationID -EQ $winApp) + $winPR = ($winID -And -Not $LicenseIsAddon) $Vista = ($winID -And $NT6 -And -Not $NT7) $NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001) - $win8 = ($strSLP -EQ $wslp -And $NT8) $reapp = ("Windows", "App")[!$winID] $prmnt = ("machine", "product")[!$winPR] - if ($Description.Contains("VOLUME_KMSCLIENT")) {$cKmsClient = 1; $actTag = "Volume"} - if ($Description.Contains("TIMEBASED_")) {$cTblClient = 1; $actTag = "Timebased"} - if ($Description.Contains("VIRTUAL_MACHINE_ACTIVATION")) {$cAvmClient = 1; $actTag = "Automatic VM"} - if ($null -EQ $cKmsClient -And $Description.Contains("VOLUME_KMS")) {$cKmsServer = 1} - - $gprDay = [Math]::Round($gprMnt/1440) - $_xpr = "" - $inGrace = $false - if ($gprMnt -GT 0) { - $_xpr = [DateTime]::Now.AddMinutes($gprMnt).ToString('yyyy-MM-dd hh:mm:ss tt') - $inGrace = $true + if ($Description | Select-String "VOLUME_KMSCLIENT") {$cKmsClient = 1; $_mTag = "Volume"} + if ($Description | Select-String "TIMEBASED_") {$cTblClient = 1; $_mTag = "Timebased"} + if ($Description | Select-String "VIRTUAL_MACHINE_ACTIVATION") {$cAvmClient = 1; $_mTag = "Automatic VM"} + if ($null -EQ $cKmsClient) { + if ($Description | Select-String "VOLUME_KMS") {$cKmsHost = 1} } - $LicenseMsg = "Time remaining: $gprMnt minute(s) ($gprDay day(s))" + $_gpr = [Math]::Round($GracePeriodRemaining/1440) + if ($_gpr -GT 0) { + $_xpr = [DateTime]::Now.addMinutes($GracePeriodRemaining).ToString('yyyy-MM-dd hh:mm:ss tt') + } + + if ($null -EQ $LicenseStatusReason) {$LicenseStatusReason = -1} + $LicenseReason = '0x{0:X}' -f $LicenseStatusReason + $LicenseMsg = "Time remaining: $GracePeriodRemaining minute(s) ($_gpr day(s))" if ($LicenseStatus -EQ 0) { $LicenseInf = "Unlicensed" $LicenseMsg = $null } if ($LicenseStatus -EQ 1) { $LicenseInf = "Licensed" - if ($gprMnt -EQ 0) { - $LicenseMsg = $null + $LicenseMsg = $null + if ($GracePeriodRemaining -EQ 0) { $ExpireMsg = "The $prmnt is permanently activated." } else { - $LicenseMsg = "$actTag activation expiration: $gprMnt minute(s) ($gprDay day(s))" - if ($inGrace) {$ExpireMsg = "$actTag activation will expire $_xpr"} + $LicenseMsg = "$_mTag activation expiration: $GracePeriodRemaining minute(s) ($_gpr day(s))" + if ($null -NE $_xpr) {$ExpireMsg = "$_mTag activation will expire $_xpr"} } } if ($LicenseStatus -EQ 2) { $LicenseInf = "Initial grace period" - if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"} + if ($null -NE $_xpr) {$ExpireMsg = "Initial grace period ends $_xpr"} } if ($LicenseStatus -EQ 3) { $LicenseInf = "Additional grace period (KMS license expired or hardware out of tolerance)" - if ($inGrace) {$ExpireMsg = "Additional grace period ends $_xpr"} + if ($null -NE $_xpr) {$ExpireMsg = "Additional grace period ends $_xpr"} } if ($LicenseStatus -EQ 4) { $LicenseInf = "Non-genuine grace period" - if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"} + if ($null -NE $_xpr) {$ExpireMsg = "Non-genuine grace period ends $_xpr"} } if ($LicenseStatus -EQ 5 -And -Not $NT5) { - $LicenseReason = '0x{0:X}' -f $LicReason $LicenseInf = "Notification" $LicenseMsg = "Notification Reason: $LicenseReason" if ($LicenseReason -EQ "0xC004F00F") {if ($null -NE $cKmsClient) {$LicenseMsg = $LicenseMsg + " (KMS license expired)."} else {$LicenseMsg = $LicenseMsg + " (hardware out of tolerance)."}} @@ -15225,116 +12957,110 @@ function GetResult($strSLP, $strApp, $entry) } if ($LicenseStatus -EQ 6 -And -Not $Vista -And -Not $NT5) { $LicenseInf = "Extended grace period" - if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"} + if ($null -NE $_xpr) {$ExpireMsg = "Extended grace period ends $_xpr"} } - if ($isPPK) { - $propPkey | foreach { set $_ (SlGetInfoPKey $pkid $_) } - } - - if ($winPR -And $isPPK -And -Not $NT8) { - $uxd = SlGetInfoSku $licID 'UXDifferentiator' - $script:primary += @{ - aid = $licID; - ppk = $PartialProductKey; - chn = $Channel; - lst = $LicenseStatus; - lcr = $LicReason; - ged = $gprMnt; - evl = $EvaluationEndDate; - dff = $uxd + if ($winPR -And $PartialProductKey -And -Not $NT9) { + $dp4 = strGetRegistry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" "DigitalProductId4" + if ($null -NE $dp4) { + $ProductKeyChannel = ([System.Text.Encoding]::Unicode.GetString($dp4, 1016, 128)).Trim([char]$null) } } - if ($IID -And $isPPK) { - $OfflineInstallationId = SlGetInfoIID $licID - } - - if ($Dlv) { - if ($win8) + if ($winPR -And $Dlv -And $NT7 -And $null -EQ $RemainingAppReArmCount) { + try { - $RemainingSkuReArmCount = SlGetInfoSku $licID 'RemainingRearmCount' - $RemainingAppReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount' + $tmp = [wmisearcher]"SELECT RemainingWindowsReArmCount FROM $strSLS" + $tmp.Options.Rewindable = $false + $tmp.Get() | select -Expand Properties -EA 0 | foreach {set $_.Name $_.Value} + $tmp.Dispose() } - else + catch { - if (($winID -And $NT7) -Or $strSLP -EQ $oslp) - { - $RemainingSLReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount' - } - else - { - $RemainingSLReArmCount = SlGetInfoService 'RearmCount' - } - } - if ($null -EQ $TrustedTime) - { - $TrustedTime = SlGetInfoSvcApp $strApp 'TrustedTime' } } + $add_on = $Name.IndexOf("add-on for", 5) + & $isAll - CONOUT "Name: $Name" + if ($add_on -EQ -1) {CONOUT "Name: $Name"} else {CONOUT "Name: $($Name.Substring(0, $add_on + 7))"} CONOUT "Description: $Description" - CONOUT "Activation ID: $licID" - if ($null -NE $DigitalPID) {CONOUT "Extended PID: $DigitalPID"} - if ($null -NE $DigitalPID2 -And $Dlv) {CONOUT "Product ID: $DigitalPID2"} + CONOUT "Activation ID: $ID" + if ($null -NE $ProductKeyID) {CONOUT "Extended PID: $ProductKeyID"} + if ($null -NE $ProductKeyID2 -And $Dlv) {CONOUT "Product ID: $ProductKeyID2"} if ($null -NE $OfflineInstallationId -And $IID) {CONOUT "Installation ID: $OfflineInstallationId"} - if ($null -NE $Channel) {CONOUT "Product Key Channel: $Channel"} + if ($null -NE $ProductKeyChannel) {CONOUT "Product Key Channel: $ProductKeyChannel"} if ($null -NE $PartialProductKey) {CONOUT "Partial Product Key: $PartialProductKey"} CONOUT "License Status: $LicenseInf" if ($null -NE $LicenseMsg) {CONOUT "$LicenseMsg"} - if ($LicenseStatus -NE 0 -And $EvaluationEndDate) { - $EED = [DateTime]::FromFileTimeUtc($EvaluationEndDate).ToString('yyyy-MM-dd hh:mm:ss tt') + if ($LicenseStatus -NE 0 -And $EvaluationEndDate.Substring(0,4) -NE "1601") { + $EED = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($EvaluationEndDate),$null,48).ToString('yyyy-MM-dd hh:mm:ss tt') CONOUT "Evaluation End Date: $EED UTC" } - if ($LicenseStatus -NE 1 -And $licPHN -NE "empty") { - $gPHN = [String]::IsNullOrEmpty($licPHN) -NE $true - CONOUT "Phone activatable: $($gPHN.ToString())" - } if ($Dlv) { - if ($null -NE $RemainingSLReArmCount) { - CONOUT "Remaining $reapp rearm count: $RemainingSLReArmCount" + if ($null -NE $RemainingWindowsReArmCount) { + CONOUT "Remaining Windows rearm count: $RemainingWindowsReArmCount" } - if ($null -NE $RemainingSkuReArmCount) { + if ($null -NE $RemainingSkuReArmCount -And $RemainingSkuReArmCount -NE 4294967295) { CONOUT "Remaining $reapp rearm count: $RemainingAppReArmCount" CONOUT "Remaining SKU rearm count: $RemainingSkuReArmCount" } - if ($LicenseStatus -NE 0 -And $TrustedTime) { - $TTD = [DateTime]::FromFileTime($TrustedTime).ToString('yyyy-MM-dd hh:mm:ss tt') + if ($null -NE $TrustedTime -And $LicenseStatus -NE 0) { + $TTD = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($TrustedTime),$null,32).ToString('yyyy-MM-dd hh:mm:ss tt') CONOUT "Trusted time: $TTD" } } - if (!$isPPK) { + if ($LicenseStatus -EQ 0) { return } - if ($win8 -And $VLActivationType -EQ 1) { + if ($strSLP -EQ $wslp -And $null -NE $PartialProductKey -And $null -NE $ADActivationObjectName -And $VLActivationType -EQ 1) { DetectAdbaClient - $cKmsClient = $null } - if ($winID -And $null -NE $cAvmClient) { + if ($winID -And $null -NE $cAvmClient -And $null -NE $PartialProductKey) { DetectAvmClient } - $chkSub = ($winPR -And $isSub) + $chkSub = ($winPR -And $cSub) - $chkSLS = ($null -NE $cKmsClient -Or $null -NE $cKmsServer -Or $chkSub) + $chkSLS = ($null -NE $PartialProductKey) -And ($null -NE $cKmsClient -Or $null -NE $cKmsHost -Or $chkSub) if (!$chkSLS) { if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} return } + try + { + $objSvc = New-Object PSObject + $wmiSvc = [wmisearcher]"SELECT * FROM $strSLS" + $wmiSvc.Options.Rewindable = $false + $wmiSvc.Get() | select -Expand Properties -EA 0 | foreach { if (-Not [String]::IsNullOrEmpty($_.Value)) {$objSvc | Add-Member 8 $_.Name $_.Value} } + $wmiSvc.Dispose() + if ($null -EQ $IsKeyManagementServiceMachine) {$objSvc.PSObject.Properties | foreach {set $_.Name $_.Value}} + } + catch + { + return + } + + if ($strSLS -EQ $wsls -And $NT9) { + if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceMachineIpAddress)) { + $DiscoveredKeyManagementServiceMachineIpAddress = "not available" + } + } + + if ($null -NE $cKmsHost -And $IsKeyManagementServiceMachine -GT 0) { + if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} + DetectKmsHost + } + if ($null -NE $cKmsClient) { DetectKmsClient } - if ($null -NE $cKmsServer) { - if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} - DetectKmsHost - } else { + if ($null -EQ $cKmsHost) { if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} } @@ -15343,16 +13069,6 @@ function GetResult($strSLP, $strApp, $entry) } } - -function ParseList($strSLP, $strApp, $arrList) -{ - foreach ($entry in $arrList) - { - GetResult $strSLP $strApp $entry - CONOUT "$line3" - & $noAll - } -} #endregion #region vNextDiag @@ -15518,8 +13234,8 @@ function PrintLicensesInformation function vNextDiagRun { - $fNUL = ([IO.Directory]::Exists("${env:LOCALAPPDATA}\Microsoft\Office\Licenses")) -and ([IO.Directory]::GetFiles("${env:LOCALAPPDATA}\Microsoft\Office\Licenses", "*", 1).Length -GT 0) - $fDev = ([IO.Directory]::Exists("${env:PROGRAMDATA}\Microsoft\Office\Licenses")) -and ([IO.Directory]::GetFiles("${env:PROGRAMDATA}\Microsoft\Office\Licenses", "*", 1).Length -GT 0) + $fNUL = ([IO.Directory]::Exists("${env:LOCALAPPDATA}\Microsoft\Office\Licenses")) -and ([IO.Directory]::GetFiles("${env:LOCALAPPDATA}\Microsoft\Office\Licenses", "*", 1).Length -GE 0) + $fDev = ([IO.Directory]::Exists("${env:PROGRAMDATA}\Microsoft\Office\Licenses")) -and ([IO.Directory]::GetFiles("${env:PROGRAMDATA}\Microsoft\Office\Licenses", "*", 1).Length -GE 0) $rPID = $null -NE (GP "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext" -EA 0 | select -Expand 'property' -EA 0 | where -Filter {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume"}) $rSCA = $null -NE (GP "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" -EA 0 | select -Expand "SharedComputerLicensing" -EA 0) $rSCL = $null -NE (GP "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing" -EA 0 | select -Expand "SharedComputerLicensing" -EA 0) @@ -15571,6 +13287,31 @@ 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. #> +function BoolToWStr($bVal) { + ("TRUE", "FALSE")[!$bVal] +} + +function InitializePInvoke { + $Marshal = [System.Runtime.InteropServices.Marshal] + $Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly((Get-Random), 'Run').DefineDynamicModule((Get-Random)) + + $Class = $Module.DefineType('NativeMethods', 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0) + $Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig') + $Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128) + $Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) + + if ($DllSubscription) { + $Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) + $Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0) + [void]$Struct.DefineField('dwEnabled', [UInt32], 'Public') + [void]$Struct.DefineField('dwSku', [UInt32], 6) + [void]$Struct.DefineField('dwState', [UInt32], 6) + $SubStatus = $Struct.CreateType() + } + + $Win32 = $Class.CreateType() +} + function InitializeDigitalLicenseCheck { $CAB = [System.Reflection.Emit.CustomAttributeBuilder] @@ -15625,29 +13366,36 @@ function PrintLastActivationHResult { } function PrintLastActivationTime { - $pqwLastTime = 0 + $pdwLastTime = 0 $cbSize = 0 if ($Win32::SLGetWindowsInformation( "Security-SPP-LastWindowsActivationTime", [ref]$null, [ref]$cbSize, - [ref]$pqwLastTime + [ref]$pdwLastTime )) { return $FALSE } - $actTime = $Marshal::ReadInt64($pqwLastTime) + $actTime = $Marshal::ReadInt64($pdwLastTime) if ($actTime -ne 0) { CONOUT (" LastActivationTime={0}" -f [DateTime]::FromFileTimeUtc($actTime).ToString("yyyy/MM/dd:HH:mm:ss")) } - $Marshal::FreeHGlobal($pqwLastTime) + $Marshal::FreeHGlobal($pdwLastTime) return $TRUE } function PrintIsWindowsGenuine { $dwGenuine = 0 + $ppwszGenuineStates = @( + "SL_GEN_STATE_IS_GENUINE", + "SL_GEN_STATE_INVALID_LICENSE", + "SL_GEN_STATE_TAMPERED", + "SL_GEN_STATE_OFFLINE", + "SL_GEN_STATE_LAST" + ) if ($Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine)) { return $FALSE @@ -15744,126 +13492,6 @@ function ClicRun } #endregion -#region clc -function clcGetExpireKrn -{ - $tData = 0 - $cData = 0 - $bData = 0 - - $hrRet = $Win32::SLGetWindowsInformation( - "Kernel-ExpirationDate", - [ref]$tData, - [ref]$cData, - [ref]$bData - ) - - if ($hrRet -Or !$cData -Or $tData -NE 3) - { - return $null - } - - $year = $Marshal::ReadInt16($bData, 0) - if ($year -EQ 0 -Or $year -EQ 1601) - { - $rData = $null - } - else - { - $rData = '{0}/{1}/{2}:{3}:{4}:{5}' -f $year, $Marshal::ReadInt16($bData, 2), $Marshal::ReadInt16($bData, 4), $Marshal::ReadInt16($bData, 6), $Marshal::ReadInt16($bData, 8), $Marshal::ReadInt16($bData, 10) - } - - #$Marshal::FreeHGlobal($bData) - return $rData -} - -function clcGetExpireSys -{ - $kuser = $Marshal::ReadInt64((New-Object IntPtr(0x7FFE02C8))) - - if ($kuser -EQ 0) - { - return $null - } - - $rData = [DateTime]::FromFileTimeUtc($kuser).ToString('yyyy/MM/dd:HH:mm:ss') - return $rData -} - -function clcGetLicensingState($dwState) -{ - if ($dwState -EQ 5) { - $dwState = 3 - } elseif ($dwState -EQ 3 -Or $dwState -EQ 4 -Or $dwState -EQ 6) { - $dwState = 2 - } elseif ($dwState -GT 6) { - $dwState = 4 - } - - $rData = '{0}' -f $ppwszLicensingStates[$dwState] - return $rData -} - -function clcGetGenuineState($AppId) -{ - $dwGenuine = 0 - - if ($NT7) { - $hrRet = $Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine) - } else { - $hrRet = $Win32::SLIsGenuineLocal([ref][Guid]$AppId, [ref]$dwGenuine, 0) - } - - if ($hrRet) - { - $dwGenuine = 4 - } - - if ($dwGenuine -LT 5) { - $rData = '{0}' -f $ppwszGenuineStates[$dwGenuine] - } else { - $rData = $dwGenuine - } - return $rData -} - -function ClcRun -{ - $prs = $script:primary[0] - if ($null -EQ $prs) { - return - } - - $lState = clcGetLicensingState $prs.lst - $uState = clcGetGenuineState $winApp - $TbbKrn = clcGetExpireKrn - $TbbSys = clcGetExpireSys - if ($null -NE $TbbKrn) { - $ked = $TbbKrn - } elseif ($null -NE $TbbSys) { - $ked = $TbbSys - } - - & $isAll - CONOUT "Client Licensing Check information:" - - CONOUT (" AppId={0}" -f $winApp) - if ($prs.ged) { CONOUT (" GraceEndDate={0}" -f ([DateTime]::UtcNow.AddMinutes($prs.ged).ToString('yyyy/MM/dd:HH:mm:ss'))) } - if ($null -NE $ked) { CONOUT (" KernelTimebombDate={0}" -f $ked) } - CONOUT (" LastConsumptionReason=0x{0:x8}" -f $prs.lcr) - if ($prs.evl) { CONOUT (" LicenseExpirationDate={0}" -f ([DateTime]::FromFileTimeUtc($prs.evl).ToString('yyyy/MM/dd:HH:mm:ss'))) } - CONOUT (" LicenseState={0}" -f $lState) - CONOUT (" PartialProductKey={0}" -f $prs.ppk) - CONOUT (" ProductKeyType={0}" -f $prs.chn) - CONOUT (" SkuId={0}" -f $prs.aid) - CONOUT (" uxDifferentiator={0}" -f $prs.dff) - CONOUT (" IsWindowsGenuine={0}" -f $uState) - - CONOUT "$line3" - & $noAll -} -#endregion - $Host.UI.RawUI.WindowTitle = "Check Activation Status" if ($All.IsPresent) { $B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B; @@ -15882,38 +13510,14 @@ $osls = "OfficeSoftwareProtectionService" $winApp = "55c92734-d682-4d71-983e-d6ec3f16059f" $o14App = "59a52881-a989-479d-af46-f275c6370663" $o15App = "0ff1ce15-a989-479d-af46-f275c6370663" -$isSub = ($winbuild -GE 26000) -And (Select-String -Path "$SysPath\wbem\sppwmi.mof" -Encoding unicode -Pattern "SubscriptionType") +$cSub = ($winbuild -GE 19041) -And (Select-String -Path "$SysPath\wbem\sppwmi.mof" -Encoding unicode -Pattern "SubscriptionType") $DllDigital = ($winbuild -GE 14393) -And (Test-Path "$SysPath\EditionUpgradeManagerObj.dll") $DllSubscription = ($winbuild -GE 14393) -And (Test-Path "$SysPath\Clipc.dll") $VLActTypes = @("All", "AD", "KMS", "Token") -$OPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" -$SPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" $SLKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL" $NSKeyPath = "HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL" -$propPrd = 'Name', 'Description', 'TrustedTime', 'VLActivationType' -$propPkey = 'PartialProductKey', 'Channel', 'DigitalPID', 'DigitalPID2' -$propKMSServer = 'KeyManagementServiceCurrentCount', 'KeyManagementServiceTotalRequests', 'KeyManagementServiceFailedRequests', 'KeyManagementServiceUnlicensedRequests', 'KeyManagementServiceLicensedRequests', 'KeyManagementServiceOOBGraceRequests', 'KeyManagementServiceOOTGraceRequests', 'KeyManagementServiceNonGenuineGraceRequests', 'KeyManagementServiceNotificationRequests' -$propKMSClient = 'CustomerPID', 'KeyManagementServiceName', 'KeyManagementServicePort', 'DiscoveredKeyManagementServiceName', 'DiscoveredKeyManagementServicePort', 'DiscoveredKeyManagementServiceIpAddress', 'VLActivationInterval', 'VLRenewalInterval', 'KeyManagementServiceLookupDomain' -$propKMSVista = 'CustomerPID', 'KeyManagementServiceName', 'VLActivationInterval', 'VLRenewalInterval' -$propADBA = 'ADActivationObjectName', 'ADActivationObjectDN', 'ADActivationCsvlkPID', 'ADActivationCsvlkSkuID' -$propAVMA = 'InheritedActivationId', 'InheritedActivationHostMachineName', 'InheritedActivationHostDigitalPid2', 'InheritedActivationActivationTime' -$primary = @() -$ppwszGenuineStates = @( - "SL_GEN_STATE_IS_GENUINE", - "SL_GEN_STATE_INVALID_LICENSE", - "SL_GEN_STATE_TAMPERED", - "SL_GEN_STATE_OFFLINE", - "SL_GEN_STATE_LAST" -) -$ppwszLicensingStates = @( - "SL_LICENSING_STATUS_UNLICENSED", - "SL_LICENSING_STATUS_LICENSED", - "SL_LICENSING_STATUS_IN_GRACE_PERIOD", - "SL_LICENSING_STATUS_NOTIFICATION", - "SL_LICENSING_STATUS_LAST" -) -'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ @()} +'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ $false} $offsvc = "osppsvc" if ($NT7 -Or -Not $NT6) {$winsvc = "sppsvc"} else {$winsvc = "slsvc"} @@ -15921,102 +13525,83 @@ if ($NT7 -Or -Not $NT6) {$winsvc = "sppsvc"} else {$winsvc = "slsvc"} try {gsv $winsvc -EA 1 | Out-Null; $WsppHook = 1} catch {$WsppHook = 0} try {gsv $offsvc -EA 1 | Out-Null; $OsppHook = 1} catch {$OsppHook = 0} -if (Test-Path "$SysPath\sppc.dll") { - $SLdll = 'sppc.dll' -} elseif (Test-Path "$SysPath\slc.dll") { - $SLdll = 'slc.dll' -} else { - $WsppHook = 0 +if ($WsppHook -NE 0) { + try {sasv $winsvc -EA 1} catch {} + $cW1nd0ws = DetectID $wslp $winApp + $c0ff1ce15 = DetectID $wslp $o15App + $c0ff1ce14 = DetectID $wslp $o14App } if ($OsppHook -NE 0) { - $OLdll = (strGetRegistry $OPKeyPath "Path") + 'osppc.dll' - if (!(Test-Path "$OLdll")) {$OsppHook = 0} + try {sasv $offsvc -EA 1} catch {} + $ospp15 = DetectID $oslp $o15App + $ospp14 = DetectID $oslp $o14App } -if ($WsppHook -NE 0) { - if ($NT6 -And -Not $NT7 -And -Not $Admin) { - if ($null -EQ [Diagnostics.Process]::GetProcessesByName("$winsvc")[0].ProcessName) {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"} - } else { - try {sasv $winsvc -EA 1} catch {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"} - } -} - -if ($WsppHook -NE 0) { - . InitializePInvoke $SLdll $false - $hSLC = 0 - [void]$Win32::SLOpen([ref]$hSLC) - - $cW1nd0ws = SlGetInfoSLID $winApp - $c0ff1ce15 = SlGetInfoSLID $o15App - $c0ff1ce14 = SlGetInfoSLID $o14App -} - -if ($cW1nd0ws.Count -GT 0) +if ($cW1nd0ws) { echoWindows - ParseList $wslp $winApp $cW1nd0ws + GetID $wslp $winApp | foreach -EA 1 { + GetResult $wslp $wsls $_ + CONOUT "$line3" + & $noAll + } } elseif ($NT6) { echoWindows - CONOUT "Error: product key not found.`n" + CONOUT "`nError: product key not found." } -if ($NT6 -And -Not $NT8) { - ClcRun -} - -if ($NT8) { +if ($winbuild -GE 9200) { + . InitializePInvoke ClicRun } +if ($c0ff1ce15 -Or $ospp15) { + CheckOhook +} + $doMSG = 1 -if ($c0ff1ce15.Count -GT 0) -{ - CheckOhook - echoOffice - ParseList $wslp $o15App $c0ff1ce15 -} - -if ($c0ff1ce14.Count -GT 0) +if ($c0ff1ce15) { echoOffice - ParseList $wslp $o14App $c0ff1ce14 + GetID $wslp $o15App | foreach -EA 1 { + GetResult $wslp $wsls $_ + CONOUT "$line3" + & $noAll + } } -if ($hSLC) { - [void]$Win32::SLClose($hSLC) -} - -if ($OsppHook -NE 0) { - try {sasv $offsvc -EA 1} catch {$OsppHook = 0; CONOUT "`nError: failed to start $offsvc Service.`n"} -} - -if ($OsppHook -NE 0) { - . InitializePInvoke "$OLdll" $true - $hSLC = 0 - [void]$Win32::SLOpen([ref]$hSLC) - - $ospp15 = SlGetInfoSLID $o15App - $ospp14 = SlGetInfoSLID $o14App -} - -if ($ospp15.Count -GT 0) +if ($c0ff1ce14) { echoOffice - ParseList $oslp $o15App $ospp15 + GetID $wslp $o14App | foreach -EA 1 { + GetResult $wslp $wsls $_ + CONOUT "$line3" + & $noAll + } } -if ($ospp14.Count -GT 0) +if ($ospp15) { echoOffice - ParseList $oslp $o14App $ospp14 + GetID $oslp $o15App | foreach -EA 1 { + GetResult $oslp $osls $_ + CONOUT "$line3" + & $noAll + } } -if ($hSLC) { - [void]$Win32::SLClose($hSLC) +if ($ospp14) +{ + echoOffice + GetID $oslp $o14App | foreach -EA 1 { + GetResult $oslp $osls $_ + CONOUT "$line3" + & $noAll + } } if ($NT7) { @@ -16068,7 +13653,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 ::======================================================================================================================================== @@ -16213,13 +13798,6 @@ mode 125, 32 ) title Fix Licensing ^(ClipSVC ^+ SPP ^+ OSPP^) -if %winbuild% EQU 6001 ( -%eline% -echo This option is not supported on Windows Vista SP1. -echo Upgrade to Windows Vista SP2. -goto :at_back -) - echo: echo %line% echo: @@ -16236,7 +13814,7 @@ echo - Clear ClipSVC, SPP and OSPP licenses. echo - Fix permissions of SPP tokens folder and registries. echo - Trigger the repair option for Office. echo: -call :dk_color2 %_White% " - " %Blue% "Apply this option only when it is necessary." +call :dk_color2 %_White% " - " %Red% "Apply this option only when it is necessary." echo: echo %line% echo: @@ -16257,7 +13835,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 +13846,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 +13940,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 +13965,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]" @@ -16453,21 +13978,21 @@ echo [No Error Found] ) echo: -echo Stopping %_slser% service... -%psc% Stop-Service %_slser% -force %nul% +echo Stopping sppsvc service... +%psc% Stop-Service sppsvc -force %nul% set w= set _sppint= -for %%# in (SppEx%w%tComObj.exe %_slexe%) do (reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (set _sppint=1)) +for %%# in (SppEx%w%tComObj.exe sppsvc.exe) do (reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (set _sppint=1)) if defined _sppint ( echo: echo Removing SPP IFEO registry keys... -for %%# in (SppE%w%xtComObj.exe %_slexe%) do (reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul%) +for %%# in (SppE%w%xtComObj.exe sppsvc.exe) do (reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul%) ) -if %winbuild% LSS 9200 if not defined _vis ( +if %winbuild% LSS 9200 ( REM Fix issues caused by Update KB971033 in Windows 7 -REM 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% @@ -16484,7 +14009,6 @@ del /f /q %SysPath%\7B296FB0-376B-497e-B012-9C450E1B7327-*.C7483456-A289-439d-81 :: Delete registry keys that are not deleted by activation scripts -if not defined _vis ( echo: echo Cleaning some licensing-related registry keys... %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "ServiceSessionId" /f @@ -16492,7 +14016,6 @@ echo Cleaning some licensing-related registry keys... %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "PolicyValuesArray" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform\data" /f -) echo: call :scandat delete @@ -16504,14 +14027,10 @@ call :dk_color %Red% "Failed to delete .dat files." echo: ) -if defined _vis ( -%psc% Start-Service %_slser% %nul% -) - 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% "Stop-Service sppsvc -force; $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% +if %errorlevel% NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% if %errorlevel% EQU 0 ( echo [Successful] ) else ( @@ -16527,7 +14046,7 @@ call :dk_color %Red% "Failed to rebuild tokens.dat file." echo tokens.dat file was rebuilt successfully. ) -if %winbuild% LSS 9200 if not defined _vis ( +if %winbuild% LSS 9200 ( sc config sppuinotify start= demand ) @@ -16608,17 +14127,17 @@ set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office reg query %_68%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_68=Office 14.0 C2R x86/x64" & set "c2r14repair68=") reg query %_86%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_86=Office 14.0 C2R x86" & set "c2r14repair86=") -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi14_86=Office 14.0 MSI x86" & call :getrepairsetup msi14repair86 14) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi14_68=Office 14.0 MSI x86/x64" & call :getrepairsetup msi14repair68 14) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi15_86=Office 15.0 MSI x86" & call :getrepairsetup msi15repair86 15) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi15_68=Office 15.0 MSI x86/x64" & call :getrepairsetup msi15repair68 15) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi16_86=Office 16.0 MSI x86" & call :getrepairsetup msi16repair86 16) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi16_68=Office 16.0 MSI x86/x64" & call :getrepairsetup msi16repair68 16) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_86=Office 14.0 MSI x86" & call :getrepairsetup msi14repair86 14) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_68=Office 14.0 MSI x86/x64" & call :getrepairsetup msi14repair68 14) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi15_86=Office 15.0 MSI x86" & call :getrepairsetup msi15repair86 15) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi15_68=Office 15.0 MSI x86/x64" & call :getrepairsetup msi15repair68 15) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi16_86=Office 16.0 MSI x86" & call :getrepairsetup msi16repair86 16) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi16_68=Office 16.0 MSI x86/x64" & call :getrepairsetup msi16repair68 16) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (set "c2r15_86=Office 15.0 C2R x86" & call :getc2rrepair c2r15repair86 integratedoffice.exe) for /f "skip=2 tokens=2*" %%a in ('"reg query %_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 +14179,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 +14212,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 +14241,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 +14431,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 +14483,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 +14529,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 @@ -17091,7 +14605,6 @@ for %%# in ( %SysPath%\spp\store\ %SysPath%\spp\store\2.0\ %Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\ -%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareLicensing\ ) do ( if %1==check ( @@ -17135,7 +14648,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 +14678,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 @@ -17208,13 +14691,6 @@ cls if not defined terminal mode 98, 30 title Change Windows Edition %masver% -if %winbuild% LSS 7600 ( -%eline% -echo Unsupported OS version detected [%winbuild%]. -echo This option is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. -goto dk_done -) - echo: echo Initializing... echo: @@ -17227,11 +14703,8 @@ if not exist %SysPath%\%%# ( %eline% echo [%SysPath%\%%#] file is missing, aborting... 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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) ) @@ -17263,7 +14736,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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -17285,7 +14759,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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -17308,7 +14783,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 +14852,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 +14905,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 @@ -17451,7 +14922,7 @@ echo [%targetedition% ^| %winbuild%] echo Failed to get product key from pkeyhelper.dll. echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -17506,7 +14977,7 @@ call :dk_color %Gray% "Reboot is required to fully change the edition." call :dk_color %Red% "[Unsuccessful] [Error Code: !keyerror!]" echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) ) @@ -17518,7 +14989,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 +15027,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% @@ -17587,7 +15058,7 @@ echo [%targetedition% ^| %winbuild%] echo Failed to get product key from pkeyhelper.dll. echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -17663,7 +15134,7 @@ echo: call :dk_color %Blue% "In case there are errors, you should restart the system before trying again." echo: set fixes=%fixes% %mas%change_edition_issues -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%change_edition_issues" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%change_edition_issues" exit /b ::======================================================================================================================================== @@ -18003,55 +15474,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 ( @@ -18077,17 +15548,19 @@ cls if not defined terminal mode 98, 30 title Change Office Edition %masver% -if %winbuild% LSS 7600 ( -%eline% -echo Unsupported OS version detected [%winbuild%]. -echo This option is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. -goto dk_done -) - 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% "Help - " %_Yellow% " %mas%troubleshoot" +goto dk_done +) + ::======================================================================================================================================== set spp=SoftwareLicensingProduct @@ -18121,7 +15594,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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -18170,7 +15644,6 @@ _updch _lang _clversion _version -_AudienceData _oIds _c2rXml _c2rExe @@ -18195,7 +15668,7 @@ echo which is not officially supported on your Windows build version %winbuild%. echo Aborting... echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -18209,7 +15682,7 @@ echo Unsupported Office %verchk% is installed on your Windows build version %win echo Aborting... echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -18298,10 +15771,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 @@ -18316,7 +15788,7 @@ if not exist %SystemRoot%\Temp\%list%.txt ( echo Failed to generate available editions list. echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto :oe_goback ) @@ -18375,13 +15847,13 @@ 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. echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto :oe_goback ) ) @@ -18417,8 +15889,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 +16016,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,43 +16031,11 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) call :oe_tempcleanup @@ -18619,7 +16056,6 @@ goto :oe_goback ) set change=0 -set editedition=1 call :ch_getinfo cls @@ -18725,8 +16161,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... @@ -18737,7 +16178,7 @@ echo %c2rcommand% if %errorlevel% NEQ 0 ( echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) goto :oe_goback @@ -18768,12 +16209,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 +16217,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 +16273,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 +16287,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 +16315,42 @@ 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 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!==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 +16373,6 @@ set _oRoot= set _oArch= set _updch= set _oIds= -set _firstoId= set _lang= set _cfolder= set _version= @@ -19066,13 +16403,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 +16421,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 +16438,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..6b960f8 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.0 @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 @@ -111,7 +109,7 @@ echo: echo Null service is not running, script may crash... echo: echo: -echo Check this webpage for help - %mas%fix_service +echo Help - %mas%fix_service echo: echo: ping 127.0.0.1 -n 20 @@ -126,7 +124,7 @@ 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 Help - %mas%troubleshoot echo: echo: ping 127.0.0.1 -n 20 >nul @@ -169,20 +167,10 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" 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%]. @@ -231,6 +219,33 @@ goto dk_done ::======================================================================================================================================== +:: Check PowerShell + +REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +echo: +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% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto dk_done +) + +::======================================================================================================================================== + :: Elevate script as admin and pass arguments and preventing loop %nul1% fltmc || ( @@ -243,86 +258,6 @@ goto dk_done ::======================================================================================================================================== -:: Check PowerShell - -::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) - -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: - -REM check LanguageMode - -echo: !tstresult2! | 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... -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 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 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 ', '))}""" -) - -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 ( @@ -333,35 +268,34 @@ set terminal= :: Check if script is running in Terminal app +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + if defined terminal ( -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 -) -if !lines! GEQ 100 set terminal= +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= ) +if defined ps32onArm goto :skipQE 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 +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" ) +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) :skipQE ::======================================================================================================================================== @@ -370,18 +304,12 @@ exit /b 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= -) +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 activ%-%ated.win') do ( +if not "%%#"=="" set old=1 +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck%upver%.activ%-%ated.win') do ( +if not "%%#"=="" set old= ) ) @@ -398,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) ) ) @@ -423,13 +351,8 @@ if not exist %SysPath%\%%# ( %eline% echo [%SysPath%\%%#] 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%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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) ) @@ -475,7 +398,7 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" goto dk_done ) ) @@ -537,7 +460,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 ) @@ -562,7 +485,7 @@ echo %mas% ) else ( echo 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) echo: goto dk_done @@ -585,7 +508,6 @@ call :dk_color %Blue% "Windows Subscription [SKU ID-%slcSKU%] detected. Script w echo: ) -set generickey=1 call :dk_inskey "[%key%]" ::======================================================================================================================================== @@ -595,15 +517,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 +593,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 +663,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: +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%licensing-servers-issue" ) ::========================================================================================================================================== @@ -762,17 +677,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 +700,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: +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware" ) 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 +712,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 +725,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: +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%licensing-servers-issue" ) ) ) @@ -841,7 +744,7 @@ call :dk_color %Blue% "Use TSforge activation option from the main menu instead. ) else ( 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) ) @@ -875,15 +778,9 @@ goto :dk_done :dk_setvar -set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe -set psc=%ps% -nop -c +set psc=powershell.exe 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" - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set _NCS=1 if %winbuild% LSS 10586 set _NCS=0 @@ -967,7 +864,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% @@ -1024,23 +921,19 @@ 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] +echo Installing Generic Product Key %~1 [Successful] ) else ( -call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" -if not defined showfix ( +call :dk_color %Red% "Installing Generic Product Key %~1 [Failed] %keyerror%" +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 ) -set generickey= exit /b :: Activation command @@ -1079,8 +972,6 @@ exit /b :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" @@ -1126,13 +1017,13 @@ function InstallLicenseArr($Str) { ForEach ($x in $a) {InstallLicenseFile "$x"} } function InstallLicenseDir($Loc) { - Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName} + dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} } function ReinstallLicenses() { - $Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens") - foreach ($Path in $Paths) { - if (Test-Path $Path) { InstallLicenseDir "$Path" } - } + $Oem = "$env:SysPath\oem" + $Spp = "$env:SysPath\spp\tokens" + InstallLicenseDir "$Spp" + If (Test-Path $Oem) {InstallLicenseDir "$Oem"} } :xrm: @@ -1140,7 +1031,6 @@ function ReinstallLicenses() { :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 @@ -1151,21 +1041,16 @@ exit /b :dk_sppissue -sc start %_slser% %nul% +sc start sppsvc %nul% 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 sc start sppsvc [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'}" +%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}" exit /b :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) @@ -1173,7 +1058,7 @@ exit /b :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 d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') set winos= for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) @@ -1229,20 +1114,19 @@ 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% +sc start sppsvc %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 exist %SysPath%\sppsvc.exe 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 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware" echo: ) @@ -1261,118 +1145,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 @@ -1392,7 +1198,6 @@ for %%# in (%serv_ste%) do ( if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%) if /i %%#==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% @@ -1407,26 +1212,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 +1238,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% "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 +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" ) ) -::============================== - -:: 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,21 +1326,42 @@ 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" ( + +if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( set 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%]" ) ) ) + + +%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%" ) -::============================== -:: Check SKU value to find if there is any difference +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,76 +1379,191 @@ 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 ( + +for %%# in (SppEx%w%tComObj.exe sppsvc.exe sppsvc.exe\PerfOptions) do ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#")) ) 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 ( +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 +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. Help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" +set error=1 +set showfix=1 +) + + +set tokenstore= +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% "Help - " %_Yellow% " %mas%troubleshoot" +) + + +:: This code creates token folder only if it's missing and sets default permission for it + +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% "Start-Job { Stop-Service sppsvc -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 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 @@ -1894,7 +1573,7 @@ exit /b $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.*') { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { $count++ } } @@ -1903,7 +1582,7 @@ $minBuildNumber = 14393 if ($osVersion.Build -ge $minBuildNumber) { $subkeyHashTable = @{} foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { - if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { $keyNumber = $subkeyName -replace '.*-', '' $subkeyHashTable[$keyNumber] = $true } @@ -1917,7 +1596,7 @@ if ($osVersion.Build -ge $minBuildNumber) { } } $wpaKey.GetSubKeyNames() | ForEach-Object { - if ($_ -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($_ -match '.*-.*-.*-.*-.*-') { if ($PSVersionTable.PSVersion.Major -lt 3) { cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1" if ($LASTEXITCODE -ne 0) { @@ -1946,10 +1625,8 @@ $wpaKey.Close() if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -) else if not exist %ps% ( -echo %~3 ) exit /b @@ -1957,10 +1634,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' -) else if not exist %ps% ( -echo %~3 %~6 ) exit /b @@ -1975,8 +1650,7 @@ 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 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -1995,10 +1669,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 +1681,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 +1721,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 +1729,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 +1742,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..7ae669d --- /dev/null +++ b/MAS/Separate-Files-Version/Activators/KMS38_Activation.cmd @@ -0,0 +1,1932 @@ +@set masver=3.0 +@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 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 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% "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 +) +) + +::======================================================================================================================================== + +:: Check PowerShell + +REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +echo: +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% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto dk_done +) + +::======================================================================================================================================== + +:: Elevate script as admin and pass arguments and preventing loop + +%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 +) + +::======================================================================================================================================== + +:: 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 + +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + +if defined terminal ( +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= +) + +if defined ps32onArm goto :skipQE +if %_unattended%==1 goto :skipQE +for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) + +if defined terminal ( +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" +) + +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) +:skipQE + +::======================================================================================================================================== + +:: Check for updates + +set -= +set old= +set upver=%masver:.=% + +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 activ%-%ated.win') do ( +if not "%%#"=="" set old=1 +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck%upver%.activ%-%ated.win') do ( +if not "%%#"=="" 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: +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "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% "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% "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% "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% "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% "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 ( +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% "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" + +sc query sppsvc | find /i "STOPPED" %nul% && ( +echo Stopping sppsvc Service [Successful] +) || ( +call :dk_color %Gray% "Stopping sppsvc Service [Failed]" +) + +%_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% "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 psc=powershell.exe +set winbuild=1 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G + +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 %keyerror% EQU 0 ( +if %sps%==SoftwareLicensingService call :dk_refresh +echo Installing Generic Product Key %~1 [Successful] +) else ( +call :dk_color %Red% "Installing Generic Product Key %~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 +) + +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 + +:: 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) { + dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} +} +function ReinstallLicenses() { + $Oem = "$env:SysPath\oem" + $Spp = "$env:SysPath\spp\tokens" + InstallLicenseDir "$Spp" + If (Test-Path $Oem) {InstallLicenseDir "$Oem"} +} +:xrm: + +:: Check wmic.exe + +:dk_ckeckwmic + +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 sppsvc %nul% +set spperror=%errorlevel% + +if %spperror% NEQ 1056 if %spperror% NEQ 0 ( +%eline% +echo sc start sppsvc [Error Code: %spperror%] +) + +echo: +%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc is not working correctly. 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%%') + +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 sppsvc %nul% +echo "%errorlevel%" | findstr "577 225" %nul% && ( +set "results=%results%[Likely File Infector]" +) || ( +if not exist %SysPath%\sppsvc.exe if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]") +) + +if not "%results%%pupfound%"=="" ( +if 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% "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 %%#==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% "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% "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" ( +set skunotfound=1 +call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]" +) + +if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" ( +call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" +) +) +) + + +%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 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%] +) +) + + +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" +) + + +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. Help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" +set error=1 +set showfix=1 +) + + +set tokenstore= +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% "Help - " %_Yellow% " %mas%troubleshoot" +) + + +:: This code creates token folder only if it's missing and sets default permission for it + +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% "Start-Job { Stop-Service sppsvc -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 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 '.*-.*-.*-.*-.*-') { + $count++ + } +} +$osVersion = [System.Environment]::OSVersion.Version +$minBuildNumber = 14393 +if ($osVersion.Build -ge $minBuildNumber) { + $subkeyHashTable = @{} + foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { + $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 '.*-.*-.*-.*-.*-') { + 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 ( +%psc% write-host -back '%1' -fore '%2' '%3' +) +exit /b + +:dk_color2 + +if %_NCS% EQU 1 ( +echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m +) else ( +%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' +) +exit /b + +::======================================================================================================================================== + +: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!==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..454644c 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.0 @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 @@ -111,7 +109,7 @@ echo: echo Null service is not running, script may crash... echo: echo: -echo Check this webpage for help - %mas%fix_service +echo Help - %mas%fix_service echo: echo: ping 127.0.0.1 -n 20 @@ -126,7 +124,7 @@ 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 Help - %mas%troubleshoot echo: echo: ping 127.0.0.1 -n 20 >nul @@ -169,41 +167,16 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) -if exist "%Systemdrive%\Users\WDAGUtilityAccount" ( -sc query gcs | find /i "RUNNING" %nul% && ( +if %winbuild% LSS 9200 ( %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%]. -echo MAS only supports Windows Vista/7/8/8.1/10/11 and their Server equivalents. -if %winbuild% EQU 6000 ( +echo Ohook Activation is supported only on Windows 8/10/11 and their server equivalents. echo: -echo Windows Vista RTM is not supported because Powershell cannot be installed. -echo Upgrade to Windows Vista SP1 or SP2. -) -goto dk_done -) - -if %winbuild% LSS 7600 if not exist "%SysPath%\WindowsPowerShell\v1.0\Modules" ( -%nceline% -if not exist %ps% ( -echo PowerShell is not installed in your system. -) -echo Install PowerShell 2.0 using the following URL. -echo: -echo https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 -if %_unattended%==0 start https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 +call :dk_color %Blue% "Use Online KMS activation option instead." goto dk_done ) @@ -239,6 +212,33 @@ goto dk_done ::======================================================================================================================================== +:: Check PowerShell + +REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +echo: +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% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto dk_done +) + +::======================================================================================================================================== + :: Elevate script as admin and pass arguments and preventing loop %nul1% fltmc || ( @@ -251,86 +251,6 @@ goto dk_done ::======================================================================================================================================== -:: Check PowerShell - -::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) - -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: - -REM check LanguageMode - -echo: !tstresult2! | 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... -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 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 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 ', '))}""" -) - -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 ( @@ -341,35 +261,34 @@ set terminal= :: Check if script is running in Terminal app +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + if defined terminal ( -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 -) -if !lines! GEQ 100 set terminal= +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= ) +if defined ps32onArm goto :skipQE 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 +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" ) +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) :skipQE ::======================================================================================================================================== @@ -378,18 +297,12 @@ exit /b 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= -) +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 activ%-%ated.win') do ( +if not "%%#"=="" set old=1 +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck%upver%.activ%-%ated.win') do ( +if not "%%#"=="" set old= ) ) @@ -406,7 +319,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 @@ -455,8 +368,8 @@ goto :oh_menu cls if not defined terminal ( -mode 140, 32 -if exist "%SysPath%\spp\store_test\" mode 140, 32 +mode 130, 32 +if exist "%SysPath%\spp\store_test\" mode 134, 32 %psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=32;$B.Height=300;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}" %nul% ) title Ohook Activation %masver% @@ -465,17 +378,12 @@ echo: echo Initializing... call :dk_chkmal -if not exist %SysPath%\%_slexe% ( +if not exist %SysPath%\sppsvc.exe ( %eline% -echo [%SysPath%\%_slexe%] file is missing, aborting... +echo [%SysPath%\sppsvc.exe] 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%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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -501,7 +409,7 @@ call :dk_showosinfo echo Initiating Diagnostic Tests... -set "_serv=%_slser% Winmgmt" +set "_serv=sppsvc Winmgmt" :: Software Protection :: Windows Management Instrumentation @@ -510,15 +418,16 @@ set notwinact=1 set ohookact=1 call :dk_errorcheck -call :oh_setspp - :: Check unsupported office versions +set o14msi= set o14c2r= set o16uwp= set _68=HKLM\SOFTWARE\Microsoft\Office set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=Office 2010 MSI ) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=Office 2010 MSI ) %nul% reg query %_68%\14.0\CVH /f Click2run /k && set o14c2r=Office 2010 C2R %nul% reg query %_86%\14.0\CVH /f Click2run /k && set o14c2r=Office 2010 C2R @@ -526,10 +435,10 @@ if %winbuild% GEQ 10240 ( for /f "delims=" %%a in ('%psc% "(Get-AppxPackage -name 'Microsoft.Office.Desktop' | Select-Object -ExpandProperty InstallLocation)" %nul6%') do (if exist "%%a\Integration\Integrator.exe" set o16uwp=Office UWP ) ) -if not "%o14c2r%%o16uwp%"=="" ( +if not "%o14msi%%o14c2r%%o16uwp%"=="" ( echo: -call :dk_color %Red% "Checking Unsupported Office Install [ %o14c2r%%o16uwp%]" -if not "%o16uwp%"=="" call :dk_color %Blue% "Use TSforge option to activate it." +call :dk_color %Red% "Checking Unsupported Office Install [ %o14msi%%o14c2r%%o16uwp%]" +if not "%o14msi%%o16uwp%"=="" call :dk_color %Blue% "Use Online KMS option to activate it." ) if %winbuild% GEQ 10240 %psc% "Get-AppxPackage -name "Microsoft.MicrosoftOfficeHub"" | find /i "Office" %nul1% && ( @@ -560,10 +469,10 @@ set o15c2r= set error=1 ) -if "%o16c2r%%o15c2r%%o16msi%%o15msi%%o14msi%"=="" ( +if "%o16c2r%%o15c2r%%o16msi%%o15msi%"=="" ( set error=1 echo: -if not "%o14c2r%%o16uwp%"=="" ( +if not "%o14msi%%o14c2r%%o16uwp%"=="" ( call :dk_color %Red% "Checking Supported Office Install [Not Found]" ) else ( call :dk_color %Red% "Checking Installed Office [Not Found]" @@ -571,7 +480,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." @@ -582,8 +491,8 @@ goto dk_done ) set multioffice= -if not "%o16c2r%%o15c2r%%o16msi%%o15msi%%o14msi%"=="1" set multioffice=1 -if not "%o14c2r%%o16uwp%"=="" set multioffice=1 +if not "%o16c2r%%o15c2r%%o16msi%%o15msi%"=="1" set multioffice=1 +if not "%o14msi%%o14c2r%%o16uwp%"=="" set multioffice=1 if defined multioffice ( call :dk_color %Gray% "Checking Multiple Office Install [Found, its recommended to install only one version]" @@ -627,8 +536,12 @@ set "_oIntegrator=%_oRoot%\integration\integrator.exe" if /i "%_oArch%"=="x64" (set "_hookPath=%_oRoot%\vfs\System" & set "_hook=sppc64.dll") if /i "%_oArch%"=="x86" (set "_hookPath=%_oRoot%\vfs\SystemX86" & set "_hook=sppc32.dll") - -call :oh_ppcpath +if not "%osarch%"=="x86" ( +if /i "%_oArch%"=="x64" set "_sppcPath=%SystemRoot%\System32\sppc.dll" +if /i "%_oArch%"=="x86" set "_sppcPath=%SystemRoot%\SysWOW64\sppc.dll" +) else ( +set "_sppcPath=%SystemRoot%\System32\sppc.dll" +) echo: echo Activating Office... [C2R ^| %_version% ^| %_oArch%] @@ -639,21 +552,9 @@ set error=1 goto :starto16c2r ) -if defined noOsppc ( -call :dk_color %Red% "Checking OSPPC.DLL [Not found. Aborting activation...]" -call :dk_color %Blue% "%_fixmsg%" -set error=1 -goto :starto16c2r -) - -call :oh_expiredpreview 2013 call :oh_fixprids call :oh_process -if defined isOspp ( -call :oh_hookinstall_ospp -) else ( call :oh_hookinstall -) ::======================================================================================================================================== @@ -685,8 +586,12 @@ set "_oIntegrator=%_oRoot%\integration\integrator.exe" if /i "%_oArch%"=="x64" (set "_hookPath=%_oRoot%\vfs\System" & set "_hook=sppc64.dll") if /i "%_oArch%"=="x86" (set "_hookPath=%_oRoot%\vfs\SystemX86" & set "_hook=sppc32.dll") - -call :oh_ppcpath +if not "%osarch%"=="x86" ( +if /i "%_oArch%"=="x64" set "_sppcPath=%SystemRoot%\System32\sppc.dll" +if /i "%_oArch%"=="x86" set "_sppcPath=%SystemRoot%\SysWOW64\sppc.dll" +) else ( +set "_sppcPath=%SystemRoot%\System32\sppc.dll" +) echo: echo Activating Office... [C2R ^| %_version% %_AudienceData%^| %_oArch%] @@ -697,37 +602,25 @@ set error=1 goto :startmsi ) -if defined noOsppc ( -call :dk_color %Red% "Checking OSPPC.DLL [Not found. Aborting activation...]" -call :dk_color %Blue% "%_fixmsg%" -set error=1 -goto :startmsi -) - -call :oh_expiredpreview 2016 2019 2021 2024 call :oh_fixprids call :oh_process -if defined isOspp ( -call :oh_hookinstall_ospp -) else ( 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 @@ -748,9 +641,6 @@ echo Adding a Registry to Prevent Banner [Successful] :startmsi -if defined o14msi call :oh_setspp 14 -if defined o14msi call :oh_processmsi 14 %o14msi_reg% -call :oh_setspp if defined o15msi call :oh_processmsi 15 %o15msi_reg% if defined o16msi call :oh_processmsi 16 %o16msi_reg% @@ -769,10 +659,10 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) goto :dk_done @@ -782,7 +672,7 @@ goto :dk_done :oh_uninstall cls -if not defined terminal mode 145, 32 +if not defined terminal mode 99, 32 title Uninstall Ohook Activation %masver% set _present= @@ -798,7 +688,6 @@ if defined o16c2r_reg (for /f "skip=2 tokens=2*" %%a in ('"reg query %o16c2r_reg if defined o15c2r_reg (for /f "skip=2 tokens=2*" %%a in ('"reg query %o15c2r_reg% /v InstallPath" %nul6%') do (set "_15CHook=%%b\root\vfs")) if defined o16msi_reg (for /f "skip=2 tokens=2*" %%a in ('"reg query %o16msi_reg%\Common\InstallRoot /v Path" %nul6%') do (set "_16MHook=%%b")) if defined o15msi_reg (for /f "skip=2 tokens=2*" %%a in ('"reg query %o15msi_reg%\Common\InstallRoot /v Path" %nul6%') do (set "_15MHook=%%b")) -if defined o14msi_reg (for /f "skip=2 tokens=2*" %%a in ('"reg query %o14msi_reg%\Common\InstallRoot /v Path" %nul6%') do (set "_14MHook=%%b")) if defined _16CHook (if exist "%_16CHook%\System\sppc*dll" (set _present=1& del /s /f /q "%_16CHook%\System\sppc*dll" & if exist "%_16CHook%\System\sppc*dll" set _unerror=1)) if defined _16CHook (if exist "%_16CHook%\SystemX86\sppc*dll" (set _present=1& del /s /f /q "%_16CHook%\SystemX86\sppc*dll" & if exist "%_16CHook%\SystemX86\sppc*dll" set _unerror=1)) @@ -806,9 +695,8 @@ if defined _15CHook (if exist "%_15CHook%\System\sppc*dll" (set _present=1& d if defined _15CHook (if exist "%_15CHook%\SystemX86\sppc*dll" (set _present=1& del /s /f /q "%_15CHook%\SystemX86\sppc*dll" & if exist "%_15CHook%\SystemX86\sppc*dll" set _unerror=1)) if defined _16MHook (if exist "%_16MHook%sppc*dll" (set _present=1& del /s /f /q "%_16MHook%sppc*dll" & if exist "%_16MHook%sppc*dll" set _unerror=1)) if defined _15MHook (if exist "%_15MHook%sppc*dll" (set _present=1& del /s /f /q "%_15MHook%sppc*dll" & if exist "%_15MHook%sppc*dll" set _unerror=1)) -if defined _14MHook (if exist "%_14MHook%sppc*dll" (set _present=1& del /s /f /q "%_14MHook%sppc*dll" & if exist "%_14MHook%sppc*dll" set _unerror=1)) -for %%# in (14 15 16) do ( +for %%# in (15 16) do ( for %%A in ("%ProgramFiles%" "%ProgramW6432%" "%ProgramFiles(x86)%") do ( if exist "%%~A\Microsoft Office\Office%%#\sppc*dll" (set _present=1& del /s /f /q "%%~A\Microsoft Office\Office%%#\sppc*dll" & if exist "%%~A\Microsoft Office\Office%%#\sppc*dll" set _unerror=1) ) @@ -822,31 +710,6 @@ if exist "%%~A\Microsoft %%~G\root\vfs\%%#\sppc*dll" (set _present=1& del /s /f ) ) -::================================== - -for %%# in (OSPPC.DLL sppcs.dll) do ( -for %%A in ("%CommonProgramFiles%" "%CommonProgramW6432%" "%CommonProgramFiles(x86)%") do ( -for %%G in ("%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\%%#") do ( -set size=0 -set size=%%~zG -if !size! GEQ 1 if !size! LSS 100000 ( -set _present=1 -del /f /q "%%~G" -if exist "%%~G" (move /y "%%~G" "!_ttemp!\needsToBeDeleted%random%" %nul%) -if exist "%%~G" (set _unerror=1) else (echo Deleted file - %%~G) -) -if /i sppcs.dll==%%# if !size! GEQ 100000 ( -move /y "%%~G" "%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPC.DLL" %nul% -if exist "%%~G" (move /y "%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPC.DLL" "!_ttemp!\needsToBeDeleted%random%" %nul%) -move /y "%%~G" "%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPC.DLL" %nul% -if exist "%%~G" (set _unerror=1&echo Failed to rename sppcs.dll back to "%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPC.DLL") else (echo Renamed sppcs.dll back to "%%~A\Microsoft Shared\OfficeSoftwareProtectionPlatform\OSPPC.DLL") -) -) -) -) - -::================================== - reg query HKCU\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency %nul% && ( echo: echo Deleting - Registry keys for skipping license check @@ -876,8 +739,6 @@ reg unload HKU\%%# %nul% ) ) -::================================== - set "kmskey=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\0ff1ce15-a989-479d-af46-f275c6370663" reg query "%kmskey%" %nul% && ( echo: @@ -924,7 +785,6 @@ set _oLPath= set _hookPath= set _hook= set _sppcPath= -set _osppPath= set _actid= set _prod= set _lic= @@ -933,6 +793,7 @@ set _prids= set _config= set _version= set _License= +set _oBranding= exit /b ::======================================================================================================================================== @@ -943,7 +804,6 @@ set o16c2r= set o15c2r= set o16msi= set o15msi= -set o14msi= set _68=HKLM\SOFTWARE\Microsoft\Office set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office @@ -953,78 +813,10 @@ for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\ClickToRun /v InstallPath" % 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 o15c2r=1&set o15c2r_reg=%_86%\15.0\ClickToRun) 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 o15c2r=1&set o15c2r_reg=%_68%\15.0\ClickToRun) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=1&set o14msi_reg=%_86%\14.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=1&set o14msi_reg=%_68%\14.0) - -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 ( -if not "%osarch%"=="x86" ( -if /i "%_oArch%"=="x64" set "_sppcPath=%SystemRoot%\System32\sppc.dll" -if /i "%_oArch%"=="x86" set "_sppcPath=%SystemRoot%\SysWOW64\sppc.dll" -) else ( -set "_sppcPath=%SystemRoot%\System32\sppc.dll" -) -) - -set noOsppc= -set _hook68= -set _hook86= -set _osppPath68= -set _osppPath86= - -if defined isOspp ( -if not "%osarch%"=="x86" ( -if /i "%_oArch%"=="x64" ( -for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /v Path" %nul6%') do (set "_osppPath68=%%b") -if not exist "!_osppPath68!OSPPC.DLL" set noOsppc=1 -) -if /i "%_oArch%"=="x86" ( -for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /v Path" %nul6%') do (set "_osppPath68=%%b") -for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\OfficeSoftwareProtectionPlatform /v Path" %nul6%') do (set "_osppPath86=%%b") -if not exist "!_osppPath68!OSPPC.DLL" set noOsppc=1 -if not exist "!_osppPath86!OSPPC.DLL" set noOsppc=1 -) -) else ( -for /f "skip=2 tokens=2*" %%a in ('"reg query HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /v Path" %nul6%') do (set "_osppPath86=%%b") -if not exist "!_osppPath86!OSPPC.DLL" set noOsppc=1 -) -if "!_osppPath68:~-1!"=="\" set "_osppPath68=!_osppPath68:~0,-1!" -if "!_osppPath86:~-1!"=="\" set "_osppPath86=!_osppPath86:~0,-1!" -) - -if defined _osppPath68 set _hook68=sppc64.dll -if defined _osppPath86 set _hook86=sppc32.dll +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) exit /b @@ -1100,7 +892,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% || ( @@ -1120,24 +912,15 @@ set hasherror= if %_hook%==sppc32.dll set offset=2564 if %_hook%==sppc64.dll set offset=3076 -::====================================== +del /s /q "%_hookPath%\sppcs.dll" %nul% +del /s /q "%_hookPath%\sppc.dll" %nul% -:: Remove previous Install - -for %%# in (sppcs.dll sppc.dll) do ( -del /f /q "%_hookPath%\%%#" %nul% -if exist "%_hookPath%\%%#" (move /y "%_hookPath%\%%#" "!_ttemp!\needsToBeDeleted%random%" %nul%) -if exist "%_hookPath%\%%#" (set "ierror=Remove Previous Ohook Install [%%#]") -) - -if defined ierror goto :oh_hookinstall_error - -::====================================== +if exist "%_hookPath%\sppcs.dll" set "ierror=Remove Previous Ohook Install" +if exist "%_hookPath%\sppc.dll" set "ierror=Remove Previous Ohook Install" mklink "%_hookPath%\sppcs.dll" "%_sppcPath%" %nul% -if not exist "%_hookPath%\sppcs.dll" ( -set ierror=mklink sppcs.dll -goto :oh_hookinstall_error +if not %errorlevel%==0 ( +if not defined ierror set ierror=mklink ) set exhook= @@ -1152,122 +935,17 @@ popd call :oh_extractdll "%_hookPath%\sppc.dll" "%offset%" ) ) -if not exist "%_hookPath%\sppc.dll" ( -set ierror=Copy -goto :oh_hookinstall_error -) +if not exist "%_hookPath%\sppc.dll" (if not defined ierror set ierror=Copy) echo: -echo Symlinking System's sppc.dll ["%_hookPath%\sppcs.dll"] [Successful] +if not defined ierror ( +echo Symlinking System's sppc.dll to ["%_hookPath%\sppcs.dll"] [Successful] if defined exhook ( echo Copying Custom %_hook% to ["%_hookPath%\sppc.dll"] [Successful] ) else ( echo Extracting Custom %_hook% to ["%_hookPath%\sppc.dll"] [Successful] ) - -goto :oh_hookinstall_error - -::======================================================================================================================================== - -:oh_hookinstall_ospp - -set ierror= -set hasherror= - -if defined _hook86 set offset86=2564 -if defined _hook68 set offset68=3076 - -::====================================== - -:: Remove previous Install - -for %%# in (OSPPC.DLL sppcs.dll) do ( -for %%A in ("%_osppPath68%\%%#" "%_osppPath86%\%%#") do ( -set size=0 -set size=%%~zA -if !size! GEQ 1 if !size! LSS 100000 ( -del /f /q "%%~A" %nul% -if exist "%%~A" (move /y "%%~A" "!_ttemp!\needsToBeDeleted%random%" %nul%) -if exist "%%~A" (set "ierror=Remove Previous Ohook Install [%%#]") -) -) -) - -if defined ierror goto :oh_hookinstall_error - -for %%A in ("%_osppPath68%" "%_osppPath86%") do ( -if exist "%%~A\sppcs.dll" (move /y "%%~A\sppcs.dll" "%%~A\OSPPC.DLL" %nul%) -if exist "%%~A\sppcs.dll" ( -move /y "%%~A\OSPPC.DLL" "!_ttemp!\needsToBeDeleted%random%" %nul% -move /y "%%~A\sppcs.dll" "%%~A\OSPPC.DLL" %nul% -) -if exist "%%~A\sppcs.dll" (set "ierror=Move sppcs.dll back to OSPPC.DLL") -) - -del /f /q "%_hookPath%\sppcs.dll" %nul% -if exist "%_hookPath%\sppcs.dll" (move /y "%_hookPath%\sppcs.dll" "!_ttemp!\needsToBeDeleted%random%" %nul%) -if exist "%_hookPath%\sppcs.dll" (set "ierror=Remove Previous Ohook mklink sppcs.dll") - -if defined ierror goto :oh_hookinstall_error - -::====================================== - -if defined _osppPath68 (move /y "%_osppPath68%\OSPPC.DLL" "%_osppPath68%\sppcs.dll" %nul% & if not exist "%_osppPath68%\sppcs.dll" set ierror=1) -if defined _osppPath86 (move /y "%_osppPath86%\OSPPC.DLL" "%_osppPath86%\sppcs.dll" %nul% & if not exist "%_osppPath86%\sppcs.dll" set ierror=1) - -if defined ierror ( -set "ierror=Rename OSPPC.DLL" -goto :oh_hookinstall_error -) - -if defined _osppPath68 if defined _osppPath86 (mklink "%_hookPath%\sppcs.dll" "%_osppPath86%\sppcs.dll" %nul%) -if defined _osppPath68 if not defined _osppPath86 (mklink "%_hookPath%\sppcs.dll" "%_osppPath68%\sppcs.dll" %nul%) -if defined _osppPath86 if not defined _osppPath68 (mklink "%_hookPath%\sppcs.dll" "%_osppPath86%\sppcs.dll" %nul%) - -if not exist "%_hookPath%\sppcs.dll" ( -set ierror=mklink sppcs.dll -goto :oh_hookinstall_error -) - -set exhook= -if exist "!_work!\BIN\%_hook68%" if exist "!_work!\BIN\%_hook86%" set exhook=1 - -if defined exhook ( -pushd "!_work!\BIN\" -if defined _osppPath68 (copy /y /b "%_hook68%" "%_osppPath68%\OSPPC.DLL" %nul%) -if defined _osppPath86 (copy /y /b "%_hook86%" "%_osppPath86%\OSPPC.DLL" %nul%) -popd ) else ( -if defined _osppPath68 (set _hook=%_hook68%&call :oh_extractdll "%_osppPath68%\OSPPC.DLL" "%offset68%") -if defined _osppPath86 (set _hook=%_hook86%&call :oh_extractdll "%_osppPath86%\OSPPC.DLL" "%offset86%") -) - -if defined _osppPath68 (if not exist "%_osppPath68%\OSPPC.DLL" set ierror=1) -if defined _osppPath86 (if not exist "%_osppPath86%\OSPPC.DLL" set ierror=1) - -if defined ierror ( -set ierror=Copy -goto :oh_hookinstall_error -) - -echo: -if defined _osppPath68 (echo Renaming OSPPC.DLL to sppcs.dll ["%_osppPath68%\sppcs.dll"]) -if defined _osppPath86 (echo Renaming OSPPC.DLL to sppcs.dll ["%_osppPath86%\sppcs.dll"]) -if defined exhook ( -if defined _osppPath68 (echo Copying Custom %_hook68% to ["%_osppPath68%\OSPPC.DLL"]) -if defined _osppPath86 (echo Copying Custom %_hook86% to ["%_osppPath86%\OSPPC.DLL"]) -) else ( -if defined _osppPath68 (echo Extracting Custom %_hook68% to ["%_osppPath68%\OSPPC.DLL"]) -if defined _osppPath86 (echo Extracting Custom %_hook86% to ["%_osppPath86%\OSPPC.DLL"]) -) - -echo Symlinking Renamed sppcs.dll ["%_hookPath%\sppcs.dll"] - -::======================================================================================================================================== - -:oh_hookinstall_error - -if defined ierror ( set error=1 call :dk_color %Red% "Installing Ohook [Failed to %ierror%]" echo: @@ -1286,9 +964,9 @@ if not defined exhook if not defined ierror ( if defined hasherror ( set error=1 set ierror=1 -call :dk_color %Red% "Modifying Hash of Custom sppcs.dll [Failed]" +call :dk_color %Red% "Modifying Hash of Custom %_hook% [Failed]" ) else ( -echo Modifying Hash of Custom sppcs.dll [Successful] +echo Modifying Hash of Custom %_hook% [Successful] ) ) @@ -1296,26 +974,6 @@ exit /b ::======================================================================================================================================== -:oh_setspp - -set isOspp= -if %winbuild% GEQ 9200 ( -set spp=SoftwareLicensingProduct -set sps=SoftwareLicensingService -) else ( -set isOspp=1 -set spp=OfficeSoftwareProtectionProduct -set sps=OfficeSoftwareProtectionService -) -if "%1"=="14" ( -set isOspp=1 -set spp=OfficeSoftwareProtectionProduct -set sps=OfficeSoftwareProtectionService -) -exit /b - -::======================================================================================================================================== - :oh_process for %%# in (%_oIds%) do ( @@ -1335,11 +993,10 @@ call :ohookdata getinfo !_prod! if not "!key!"=="" ( echo "!allapps!" | find /i "!_actid!" %nul1% || call :oh_installlic -if not %oVer%==14 set generickey=1 call :dk_inskey "[!key!] [!_prod!] [!_lic!]" ) else ( set error=1 -call :dk_color %Red% "Checking Product In Script [Office %oVer%.0 !_prod! key not found in script]" +call :dk_color %Red% "Checking Product In Script [Office %oVer%.0 !_prod! not found in script]" call :dk_color %Blue% "Make sure you are using the latest version of MAS." set fixes=%fixes% %mas% call :dk_color %_Yellow% "%mas%" @@ -1349,7 +1006,7 @@ call :dk_color %_Yellow% "%mas%" :: 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 defined winserver if defined _config if exist "%_oLPath%\Word2019VL_KMS_Client_AE*.xrm-ms" ( +if defined winserver if defined _config ( echo %_oIds% | find /i "Retail" %nul1% && ( set scaIsNeeded=1 reg add %_config% /v SharedComputerLicensing /t REG_SZ /d "1" /f %nul1% @@ -1366,11 +1023,7 @@ exit /b :: Process Office MSI Version call :oh_reset -if "%1"=="14" ( -call :dk_actids 59a52881-a989-479d-af46-f275c6370663 -) else ( call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 -) set oVer=%1 for /f "skip=2 tokens=2*" %%a in ('"reg query %2\Common\InstallRoot /v Path" %nul6%') do (set "_oRoot=%%b") @@ -1383,37 +1036,39 @@ if "%osarch%"=="x86" set _oArch=x86 if /i "%_oArch%"=="x64" (set "_hookPath=%_oRoot%" & set "_hook=sppc64.dll") if /i "%_oArch%"=="x86" (set "_hookPath=%_oRoot%" & set "_hook=sppc32.dll") +if not "%osarch%"=="x86" ( +if /i "%_oArch%"=="x64" set "_sppcPath=%SystemRoot%\System32\sppc.dll" +if /i "%_oArch%"=="x86" set "_sppcPath=%SystemRoot%\SysWOW64\sppc.dll" +) else ( +set "_sppcPath=%SystemRoot%\System32\sppc.dll" +) -call :oh_ppcpath +set "_common=%CommonProgramFiles%" +if defined PROCESSOR_ARCHITEW6432 set "_common=%CommonProgramW6432%" +set "_common2=%CommonProgramFiles(x86)%" -call :msiofficedata %2 +for /r "%_common%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" +if not defined _oBranding for /r "%_common2%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" + +call :ohookdata getmsiprod %2 echo: echo Activating Office... [MSI ^| %_version% ^| %_oArch%] +if not defined _oBranding ( +set error=1 +call :dk_color %Red% "Checking BRANDING.XML [Not Found, aborting activation...]" +exit /b +) + if not defined _oIds ( set error=1 call :dk_color %Red% "Checking Installed Products [Product IDs not found, aborting activation...]" exit /b ) -if defined noOsppc ( -call :dk_color %Red% "Checking OSPPC.DLL [Not found. Aborting activation...]" -call :dk_color %Blue% "%_fixmsg%" -set error=1 -exit /b -) - -if %oVer%==14 if defined SingleImage ( -echo Checking Installed Products [SingleImage product found, Professional Retail key will be used for activation] -) - call :oh_process -if defined isOspp ( -call :oh_hookinstall_ospp -) else ( call :oh_hookinstall -) exit /b @@ -1422,7 +1077,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 +1129,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 +1155,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 +1162,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 +1173,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 +1256,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 +1267,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 @@ -1671,15 +1306,9 @@ exit /b :dk_setvar -set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe -set psc=%ps% -nop -c +set psc=powershell.exe 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" - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set _NCS=1 if %winbuild% LSS 10586 set _NCS=0 @@ -1757,23 +1386,19 @@ 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] +echo Installing Generic Product Key %~1 [Successful] ) else ( -call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" -if not defined showfix ( +call :dk_color %Red% "Installing Generic Product Key %~1 [Failed] %keyerror%" +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 ) -set generickey= exit /b :: Get all products Activation IDs @@ -1789,9 +1414,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% @@ -1827,7 +1452,7 @@ function InstallLicenseArr($Str) { ForEach ($x in $a) {InstallLicenseFile "$x"} } function InstallLicenseDir($Loc) { - Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName} + dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} } function ReinstallLicenses() { $Oem = "$env:SysPath\oem" @@ -1841,7 +1466,6 @@ function ReinstallLicenses() { :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 @@ -1852,21 +1476,16 @@ exit /b :dk_sppissue -sc start %_slser% %nul% +sc start sppsvc %nul% 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 sc start sppsvc [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'}" +%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}" exit /b :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) @@ -1874,7 +1493,7 @@ exit /b :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 d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') set winos= for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) @@ -1884,7 +1503,6 @@ if %winbuild% GEQ 22000 ( set winos=!winos:Windows 10=Windows 11! ) ) - exit /b :: Common lines used in PowerShell reflection code @@ -1915,20 +1533,19 @@ 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% +sc start sppsvc %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 exist %SysPath%\sppsvc.exe 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 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware" echo: ) @@ -1947,118 +1564,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 @@ -2078,7 +1617,6 @@ for %%# in (%serv_ste%) do ( if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%) if /i %%#==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% @@ -2093,26 +1631,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 +1657,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% "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 +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" ) ) -::============================== - -:: 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,21 +1745,42 @@ 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" ( + +if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( set 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%]" ) ) ) + + +%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%" ) -::============================== -:: Check SKU value to find if there is any difference +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,76 +1798,191 @@ 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 ( + +for %%# in (SppEx%w%tComObj.exe sppsvc.exe sppsvc.exe\PerfOptions) do ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#")) ) 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 ( +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 +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. Help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" +set error=1 +set showfix=1 +) + + +set tokenstore= +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% "Help - " %_Yellow% " %mas%troubleshoot" +) + + +:: This code creates token folder only if it's missing and sets default permission for it + +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% "Start-Job { Stop-Service sppsvc -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 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 @@ -2580,7 +1992,7 @@ exit /b $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.*') { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { $count++ } } @@ -2589,7 +2001,7 @@ $minBuildNumber = 14393 if ($osVersion.Build -ge $minBuildNumber) { $subkeyHashTable = @{} foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { - if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { $keyNumber = $subkeyName -replace '.*-', '' $subkeyHashTable[$keyNumber] = $true } @@ -2603,7 +2015,7 @@ if ($osVersion.Build -ge $minBuildNumber) { } } $wpaKey.GetSubKeyNames() | ForEach-Object { - if ($_ -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($_ -match '.*-.*-.*-.*-.*-') { if ($PSVersionTable.PSVersion.Major -lt 3) { cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1" if ($LASTEXITCODE -ne 0) { @@ -2632,10 +2044,8 @@ $wpaKey.Close() if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -) else if not exist %ps% ( -echo %~3 ) exit /b @@ -2643,10 +2053,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' -) else if not exist %ps% ( -echo %~3 %~6 ) exit /b @@ -2661,8 +2069,7 @@ 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 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -2679,69 +2086,15 @@ exit /b :: 1st column = Office version number :: 2nd column = Activation ID -:: 3rd column = For Office 2013 and later, the generated keys are listed. For Office 2010, the blocked keys sourced from the Internet are listed. -:: For Office 2013 and later, key preference is given in this order, Retail:TB:Sub > Retail > OEM:NONSLP > Volume:MAK > Volume:GVLK -:: For Office 2010, key preference is given in this order, Retail > Volume:MAK +:: 3rd column = Generic key. Preference is given in this order, Retail:TB:Sub > Retail > OEM:NONSLP > Volume:MAK > Volume:GVLK :: 4th column = Last part of license description :: 5th column = Edition -:: 6th column = Other Edition IDs if they are part of the same primary product (For reference only) :: Separator = "_" -::=============== - -:: We couldn't find any keys (blocked/generic doesn't matter) for these Office 2010 products. If you have them, please share with us. - -14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_Retail________ExcelR_[HSExcelR] -14_7004b7f0-6407-4f45-8eac-966e5f868bde_Retail________GrooveR -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] - -:: These installers are not publicly available, so it doesn't matter if we don't have their keys. - -14_19316117-30a8-4773-8fd9-7f7231f4e060_SubPrepid_____HomeBusinessSubR -14_4d06f72e-fd50-4bc2-a24b-d448d7f17ef2_SubPrepid_____ProjectProSubR -14_e98ef0c0-71c4-42ce-8305-287d8721e26c_SubPrepid_____ProPlusSubR -14_14f5946a-debc-4716-babc-7e2c240fec08_Retail________MondoR -14_533b656a-4425-480b-8e30-1a2358898350_MAK___________MondoVL - :ohookdata set f= for %%# in ( -:: Office 2010 -14_4d463c2c-0505-4626-8cdb-a4da82e2d8ed_7KTYC-XR43P-C3MRW-BJKFD-XB%f%YPG_Retail________AccessR -14_745fb377-0a59-4ca9-b9a9-c359557a2c4e_7XHPQ-BQMYG-YBP49-CY8B2-T8%f%CGQ_ByPass________AccessRuntimeR -14_95ab3ec8-4106-4f9d-b632-03c019d1d23f_89RTQ-MT4GK-6CPTX-WWP7C-J9%f%KXR_MAK___________AccessVL -14_71dc86ff-f056-40d0-8ffb-9592705c9b76_39TRR-C2F37-9WYJ2-MJQXH-B9%f%38K_MAK___________ExcelVL -14_fdad0dfa-417d-4b4f-93e4-64ea8867b7fd_RCGT3-FPQDV-H49CD-PPDBF-TH%f%47G_MAK___________GrooveVL -14_7b7d1f17-fdcb-4820-9789-9bec6e377821_3YR9B-D9W79-BY66R-R8XYP-QY%f%YYY_Retail________HomeBusinessR_[HomeBusinessDemoR] -14_09e2d37e-474b-4121-8626-58ad9be5776f_3X43R-HHHXX-FRHRW-2M2WJ-8V%f%PHD_Retail________HomeStudentR_[HomeStudentDemoR] -14_ef1da464-01c8-43a6-91af-e4e5713744f9_XDGJY-KFHW9-JWX9X-YM4GW-GC%f%8WR_Retail________InfoPathR -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 -14_8b559c37-0117-413e-921b-b853aeb6e210_367X9-9HP9R-TKHY6-DH4QH-K9%f%PY7_Retail________ProfessionalR_[ProfessionalAcadR,ProfessionalDemoR,OEM-SingleImage] -14_725714d7-d58f-4d12-9fa8-35873c6f7215_6JD4G-KRW3J-48MGV-DM6FC-T9%f%WKR_Retail________ProjectProR_[ProjectProMSDNR] -14_1cf57a59-c532-4e56-9a7d-ffa2fe94b474_3XDTH-MMGJ6-F9MKX-THP8D-G9%f%BP7_MAK___________ProjectProVL -14_688f6589-2bd9-424e-a152-b13f36aa6de1_2W96V-RTQ9R-2BPVT-PT8H9-MV%f%68T_Retail________ProjectStdR -14_11b39439-6b93-4642-9570-f2eb81be2238_4DTT4-D4MKX-23KFH-JKR6T-YK%f%G2J_MAK___________ProjectStdVL -14_71af7e84-93e6-4363-9b69-699e04e74071_2J9H6-H4D3G-PCXD2-96XVM-TR%f%R73_Retail________ProPlusR_[ProPlusAcadR,ProPlusMSDNR,Sub4R] -14_fdf3ecb9-b56f-43b2-a9b8-1b48b6bae1a7_6CD6C-9R8PB-T2D9Y-8RKKX-W7%f%DFK_MAK___________ProPlusVL_[ProPlusAcadVL] -14_98677603-a668-4fa4-9980-3f1f05f78f69_CTRJP-P72VV-JBF8Y-4W6WW-HX%f%HVG_Retail________PublisherR -14_3d014759-b128-4466-9018-e80f6320d9d0_32YG9-3VX77-YXJVV-PRVFW-TT%f%8BV_MAK___________PublisherVL -14_8090771e-d41a-4482-929e-de87f1f47e46_7VKXH-9BWCG-RPTBB-JBRV3-GR%f%HYC_MAK___________SmallBusBasicsVL -14_b78df69e-0966-40b1-ae85-30a5134dedd0_H48K6-FB4Y6-P83GH-9J7XG-HD%f%KKX_ByPass________SPDR -14_b6d2565c-341d-4768-ad7d-addbe00bb5ce_W3BTX-H6BW7-Q6DFW-BXFFY-8R%f%VJP_Retail________StandardR_[StandardMSDNR][KeyisforMSDNR] -14_1f76e346-e0be-49bc-9954-70ec53a4fcfe_2XTQP-GDR7C-GTXPC-6W6PV-4R%f%XGC_MAK___________StandardVL_[StandardAcadVL] -14_2745e581-565a-4670-ae90-6bf7c57ffe43_VXHHB-W7HBD-7M342-RJ7P8-CH%f%BD6_ByPass________StarterR -14_66cad568-c2dc-459d-93ec-2f3cb967ee34_2RDPT-WPYQM-C2WXF-BTPDW-2J%f%2HM_Retail________VisioSIR_Prem[Pro,Std] -14_36756cb8-8e69-4d11-9522-68899507cd6a_7PKFT-X2MKQ-GT6X2-8CB2W-CH%f%C9K_MAK___________VisioSIVL_Prem[Pro,Std] -14_98d4050e-9c98-49bf-9be1-85e12eb3ab13_6J3XK-DFKGK-X373V-QJHYM-V3%f%FC2_MAK___________WordVL :: Office 2013 15_ab4d047b-97cf-4126-a69f-34df08e2f254_B7RFY-7NXPK-Q4342-Y9X2H-3J%f%X4X_Retail________AccessRetail 15_259de5be-492b-44b3-9d78-9645f848f7b0_X3XNB-HJB7K-66THH-8DWQ3-XH%f%GJP_Bypass________AccessRuntimeRetail @@ -2797,7 +2150,6 @@ for %%# in ( 15_e3dacc06-3bc2-4e13-8e59-8e05f3232325_H8DN8-Y2YP3-CR9JT-DHDR9-C7%f%GP3_Subscription2_O365ProPlusRetail 15_0bc1dae4-6158-4a1c-a893-807665b934b2_2QCNB-RMDKJ-GC8PB-7QGQV-7Q%f%TQJ_Subscription2_O365SmallBusPremRetail :: Office 365 - 16.0 version -16_dabaa1f2-109b-496d-bf49-1536cc862900_3HYJN-9KG99-F8VG9-V3DT8-JF%f%MHV_Subscription__O365AppsBasicRetail 16_742178ed-6b28-42dd-b3d7-b7c0ea78741b_Y9NF9-M2QWD-FF6RJ-QJW36-RR%f%F2T_SubTest_______O365BusinessRetail 16_2f5c71b4-5b7a-4005-bb68-f9fac26f2ea3_W62NQ-267QR-RTF74-PF2MH-JQ%f%MTH_Subscription__O365EduCloudRetail 16_a96f8dae-da54-4fad-bdc6-108da592707a_3NMDC-G7C3W-68RGP-CB4MH-4C%f%XCH_SubTest1______O365HomePremRetail @@ -2965,182 +2317,13 @@ if %oVer%==16 (echo "%%D" | find /i "Subscription" %nul% && set _sublic=1) ) ) -) -) -exit /b - -::======================================================================================================================================== - -:: 1st column = Office version number -:: 2nd column = Activation ID -:: 3rd column = Product ID from branding.xml -:: 4th column = Edition -:: 5th column = Other Edition IDs if they are part of the same primary product (For reference only) -:: Separator = "_" - -:msiofficedata - -for %%# in ( -14_4d463c2c-0505-4626-8cdb-a4da82e2d8ed_0015_AccessR -14_745fb377-0a59-4ca9-b9a9-c359557a2c4e_001C_AccessRuntimeR -14_95ab3ec8-4106-4f9d-b632-03c019d1d23f_0015_AccessVL -14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_0016_ExcelR_[HSExcelR] -14_71dc86ff-f056-40d0-8ffb-9592705c9b76_0016_ExcelVL -14_7004b7f0-6407-4f45-8eac-966e5f868bde_00BA_GrooveR -14_fdad0dfa-417d-4b4f-93e4-64ea8867b7fd_00BA_GrooveVL -14_7b7d1f17-fdcb-4820-9789-9bec6e377821_0013_HomeBusinessR_[HomeBusinessDemoR] -14_19316117-30a8-4773-8fd9-7f7231f4e060_011E_HomeBusinessSubR -14_09e2d37e-474b-4121-8626-58ad9be5776f_002F_HomeStudentR_[HomeStudentDemoR] -14_ef1da464-01c8-43a6-91af-e4e5713744f9_0044_InfoPathR -14_85e22450-b741-430c-a172-a37962c938af_0044_InfoPathVL -14_14f5946a-debc-4716-babc-7e2c240fec08_000F_MondoR -14_533b656a-4425-480b-8e30-1a2358898350_000F_MondoVL -14_c1ceda8b-c578-4d5d-a4aa-23626be4e234_003D_ProfessionalR_[OEM-SingleImage]Exception -14_3f7aa693-9a7e-44fc-9309-bb3d8e604925_00A1_OneNoteR_[HSOneNoteR] -14_6860b31f-6a67-48b8-84b9-e312b3485c4b_00A1_OneNoteVL -14_fbf4ac36-31c8-4340-8666-79873129cf40_001A_OutlookR -14_a9aeabd8-63b8-4079-a28e-f531807fd6b8_001A_OutlookVL -14_acb51361-c0db-4895-9497-1831c41f31a6_0033_PersonalR_[PersonalDemoR,PersonalPrepaidR] -14_133c8359-4e93-4241-8118-30bb18737ea0_0018_PowerPointR_[HSPowerPointR] -14_38252940-718c-4aa6-81a4-135398e53851_0018_PowerPointVL -14_8b559c37-0117-413e-921b-b853aeb6e210_0014_ProfessionalR_[ProfessionalAcadR,ProfessionalDemoR] -14_725714d7-d58f-4d12-9fa8-35873c6f7215_003B_ProjectProR_[ProjectProMSDNR] -14_4d06f72e-fd50-4bc2-a24b-d448d7f17ef2_011F_ProjectProSubR -14_1cf57a59-c532-4e56-9a7d-ffa2fe94b474_003B_ProjectProVL -14_688f6589-2bd9-424e-a152-b13f36aa6de1_003A_ProjectStdR -14_11b39439-6b93-4642-9570-f2eb81be2238_003A_ProjectStdVL -14_71af7e84-93e6-4363-9b69-699e04e74071_0011_ProPlusR_[ProPlusAcadR,ProPlusMSDNR,Sub4R] -14_e98ef0c0-71c4-42ce-8305-287d8721e26c_011D_ProPlusSubR -14_fdf3ecb9-b56f-43b2-a9b8-1b48b6bae1a7_0011_ProPlusVL_[ProPlusAcadVL] -14_98677603-a668-4fa4-9980-3f1f05f78f69_0019_PublisherR -14_3d014759-b128-4466-9018-e80f6320d9d0_0019_PublisherVL -14_dbe3aee0-5183-4ff7-8142-66050173cb01_008B_SmallBusBasicsR_[SmallBusBasicsMSDNR] -14_8090771e-d41a-4482-929e-de87f1f47e46_008B_SmallBusBasicsVL -14_b78df69e-0966-40b1-ae85-30a5134dedd0_0017_SPDR -14_d3422cfb-8d8b-4ead-99f9-eab0ccd990d7_0012_StandardR -14_1f76e346-e0be-49bc-9954-70ec53a4fcfe_0012_StandardVL_[StandardAcadVL] -14_2745e581-565a-4670-ae90-6bf7c57ffe43_0066_StarterR -14_66cad568-c2dc-459d-93ec-2f3cb967ee34_0057_VisioSIR_Prem[Pro,Std]Exception -14_36756cb8-8e69-4d11-9522-68899507cd6a_0057_VisioSIVL_Prem[Pro,Std]Exception -14_db3bbc9c-ce52-41d1-a46f-1a1d68059119_001B_WordR_[HSWordR] -14_98d4050e-9c98-49bf-9be1-85e12eb3ab13_001B_WordVL -:: Office 2013 -15_ab4d047b-97cf-4126-a69f-34df08e2f254_0015_AccessRetail -15_259de5be-492b-44b3-9d78-9645f848f7b0_001C_AccessRuntimeRetail -15_4374022d-56b8-48c1-9bb7-d8f2fc726343_0015_AccessVolume -15_1b1d9bd5-12ea-4063-964c-16e7e87d6e08_0016_ExcelRetail -15_ac1ae7fd-b949-4e04-a330-849bc40638cf_0016_ExcelVolume -15_cfaf5356-49e3-48a8-ab3c-e729ab791250_00BA_GrooveRetail -15_4825ac28-ce41-45a7-9e6e-1fed74057601_00BA_GrooveVolume -15_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_00E7_HomeBusinessPipcRetail -15_cd256150-a898-441f-aac0-9f8f33390e45_0013_HomeBusinessRetail -15_1fdfb4e4-f9c9-41c4-b055-c80daf00697d_00CE_HomeStudentARMRetail -15_ebef9f05-5273-404a-9253-c5e252f50555_00DA_HomeStudentPlusARMRetail -15_98685d21-78bd-4c62-bc4f-653344a63035_002F_HomeStudentRetail -15_44984381-406e-4a35-b1c3-e54f499556e2_0044_InfoPathRetail -15_9e016989-4007-42a6-8051-64eb97110cf2_0044_InfoPathVolume -15_9103f3ce-1084-447a-827e-d6097f68c895_00EA_LyncAcademicRetail -15_ff693bf4-0276-4ddb-bb42-74ef1a0c9f4d_012D_LyncEntryRetail -15_fada6658-bfc6-4c4e-825a-59a89822cda8_012C_LyncRetail -15_e1264e10-afaf-4439-a98b-256df8bb156f_012C_LyncVolume -15_3169c8df-f659-4f95-9cc6-3115e6596e83_000F_MondoRetail -15_f33485a0-310b-4b72-9a0e-b1d605510dbd_000F_MondoVolume -15_3391e125-f6e4-4b1e-899c-a25e6092d40d_00A1_OneNoteFreeRetail -15_8b524bcc-67ea-4876-a509-45e46f6347e8_00A1_OneNoteRetail -15_b067e965-7521-455b-b9f7-c740204578a2_00A1_OneNoteVolume -15_12004b48-e6c8-4ffa-ad5a-ac8d4467765a_001A_OutlookRetail -15_8d577c50-ae5e-47fd-a240-24986f73d503_001A_OutlookVolume -15_5aab8561-1686-43f7-9ff5-2c861da58d17_00E6_PersonalPipcRetail -15_17e9df2d-ed91-4382-904b-4fed6a12caf0_0033_PersonalRetail -15_31743b82-bfbc-44b6-aa12-85d42e644d5b_0018_PowerPointRetail -15_e40dcb44-1d5c-4085-8e8f-943f33c4f004_0018_PowerPointVolume -15_4e26cac1-e15a-4467-9069-cb47b67fe191_00E8_ProfessionalPipcRetail -15_44bc70e2-fb83-4b09-9082-e5557e0c2ede_0014_ProfessionalRetail -15_f2435de4-5fc0-4e5b-ac97-34f515ec5ee7_003B_ProjectProRetail -15_ed34dc89-1c27-4ecd-8b2f-63d0f4cedc32_003B_ProjectProVolume -15_5517e6a2-739b-4822-946f-7f0f1c5934b1_003A_ProjectStdRetail -15_2b9e4a37-6230-4b42-bee2-e25ce86c8c7a_003A_ProjectStdVolume -15_064383fa-1538-491c-859b-0ecab169a0ab_0011_ProPlusRetail -15_2b88c4f2-ea8f-43cd-805e-4d41346e18a7_0011_ProPlusVolume -15_c3a0814a-70a4-471f-af37-2313a6331111_0019_PublisherRetail -15_38ea49f6-ad1d-43f1-9888-99a35d7c9409_0019_PublisherVolume -15_ba3e3833-6a7e-445a-89d0-7802a9a68588_0017_SPDRetail -15_32255c0a-16b4-4ce2-b388-8a4267e219eb_0012_StandardRetail -15_a24cca51-3d54-4c41-8a76-4031f5338cb2_0012_StandardVolume -15_15d12ad4-622d-4257-976c-5eb3282fb93d_0051_VisioProRetail -15_3e4294dd-a765-49bc-8dbd-cf8b62a4bd3d_0051_VisioProVolume -15_dae597ce-5823-4c77-9580-7268b93a4b23_0053_VisioStdRetail -15_44a1f6ff-0876-4edb-9169-dbb43101ee89_0053_VisioStdVolume -15_191509f2-6977-456f-ab30-cf0492b1e93a_001B_WordRetail -15_9cedef15-be37-4ff0-a08a-13a045540641_001B_WordVolume -:: Office 365 - 15.0 version -15_befee371-a2f5-4648-85db-a2c55fdf324c_00E9_O365BusinessRetail -15_537ea5b5-7d50-4876-bd38-a53a77caca32_00D6_O365HomePremRetail -15_149dbce7-a48e-44db-8364-a53386cd4580_00D4_O365ProPlusRetail -15_bacd4614-5bef-4a5e-bafc-de4c788037a2_00D5_O365SmallBusPremRetail -:: Office 365 - 16.0 version -16_6337137e-7c07-4197-8986-bece6a76fc33_00E9_O365BusinessRetail -16_2f5c71b4-5b7a-4005-bb68-f9fac26f2ea3_00D6_O365EduCloudRetail -16_537ea5b5-7d50-4876-bd38-a53a77caca32_00D6_O365HomePremRetail -16_149dbce7-a48e-44db-8364-a53386cd4580_00D4_O365ProPlusRetail -16_bacd4614-5bef-4a5e-bafc-de4c788037a2_00D5_O365SmallBusPremRetail -:: Office 2016 -16_bfa358b0-98f1-4125-842e-585fa13032e6_0015_AccessRetail -16_9d9faf9e-d345-4b49-afce-68cb0a539c7c_001C_AccessRuntimeRetail -16_3b2fa33f-cd5a-43a5-bd95-f49f3f546b0b_0015_AccessVolume -16_424d52ff-7ad2-4bc7-8ac6-748d767b455d_0016_ExcelRetail -16_685062a7-6024-42e7-8c5f-6bb9e63e697f_0016_ExcelVolume -16_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_00E7_HomeBusinessPipcRetail -16_86834d00-7896-4a38-8fae-32f20b86fa2b_0013_HomeBusinessRetail -16_090896a0-ea98-48ac-b545-ba5da0eb0c9c_00CE_HomeStudentARMRetail -16_6bbe2077-01a4-4269-bf15-5bf4d8efc0b2_00DA_HomeStudentPlusARMRetail -16_c28acdb8-d8b3-4199-baa4-024d09e97c99_002F_HomeStudentRetail -16_e2127526-b60c-43e0-bed1-3c9dc3d5a468_002F_HomeStudentVNextRetail -16_b21367df-9545-4f02-9f24-240691da0e58_000F_MondoRetail -16_2cd0ea7e-749f-4288-a05e-567c573b2a6c_000F_MondoVolume -16_436366de-5579-4f24-96db-3893e4400030_00A3_OneNoteFreeRetail -16_83ac4dd9-1b93-40ed-aa55-ede25bb6af38_00A1_OneNoteRetail -16_23b672da-a456-4860-a8f3-e062a501d7e8_00A1_OneNoteVolume -16_5a670809-0983-4c2d-8aad-d3c2c5b7d5d1_001A_OutlookRetail -16_50059979-ac6f-4458-9e79-710bcb41721a_001A_OutlookVolume -16_5aab8561-1686-43f7-9ff5-2c861da58d17_00E6_PersonalPipcRetail -16_a9f645a1-0d6a-4978-926a-abcb363b72a6_0033_PersonalRetail -16_f32d1284-0792-49da-9ac6-deb2bc9c80b6_0018_PowerPointRetail -16_9b4060c9-a7f5-4a66-b732-faf248b7240f_0018_PowerPointVolume -16_4e26cac1-e15a-4467-9069-cb47b67fe191_00E8_ProfessionalPipcRetail -16_d64edc00-7453-4301-8428-197343fafb16_0014_ProfessionalRetail -16_0f42f316-00b1-48c5-ada4-2f52b5720ad0_003B_ProjectProRetail -16_82f502b5-b0b0-4349-bd2c-c560df85b248_003B_ProjectProVolume -16_16728639-a9ab-4994-b6d8-f81051e69833_003B_ProjectProXVolume -16_e9f0b3fc-962f-4944-ad06-05c10b6bcd5e_003A_ProjectStdRetail -16_82e6b314-2a62-4e51-9220-61358dd230e6_003A_ProjectStdVolume -16_431058f0-c059-44c5-b9e7-ed2dd46b6789_003A_ProjectStdXVolume -16_de52bd50-9564-4adc-8fcb-a345c17f84f9_0011_ProPlusRetail -16_c47456e3-265d-47b6-8ca0-c30abbd0ca36_0011_ProPlusVolume -16_6e0c1d99-c72e-4968-bcb7-ab79e03e201e_0019_PublisherRetail -16_fcc1757b-5d5f-486a-87cf-c4d6dedb6032_0019_PublisherVolume -16_971cd368-f2e1-49c1-aedd-330909ce18b6_012D_SkypeforBusinessEntryRetail -16_418d2b9f-b491-4d7f-84f1-49e27cc66597_012C_SkypeforBusinessRetail -16_03ca3b9a-0869-4749-8988-3cbc9d9f51bb_012C_SkypeforBusinessVolume -16_9103f3ce-1084-447a-827e-d6097f68c895_012C_SkypeServiceBypassRetail -16_4a31c291-3a12-4c64-b8ab-cd79212be45e_0012_StandardRetail -16_0ed94aac-2234-4309-ba29-74bdbb887083_0012_StandardVolume -16_2dfe2075-2d04-4e43-816a-eb60bbb77574_0051_VisioProRetail -16_295b2c03-4b1c-4221-b292-1411f468bd02_0051_VisioProVolume -16_0594dc12-8444-4912-936a-747ca742dbdb_0051_VisioProXVolume -16_c76dbcbc-d71b-4f45-b5b3-b7494cb4e23e_0053_VisioStdRetail -16_44151c2d-c398-471f-946f-7660542e3369_0053_VisioStdVolume -16_1d1c6879-39a3-47a5-9a6d-aceefa6a289d_0053_VisioStdXVolume -16_cacaa1bf-da53-4c3b-9700-11738ef1c2a5_001B_WordRetail -16_c3000759-551f-4f4a-bcac-a4b42cbf1de2_001B_WordVolume -) do ( -for /f "tokens=1-5 delims=_" %%A in ("%%#") do ( - -if "%oVer%"=="%%A" ( -reg query "%1\Registration\{%%B}" /v ProductCode %nul2% | find /i "-%%C-" %nul% && ( -reg query "%1\Common\InstalledPackages" %nul2% | find /i "-%%C-" %nul% && ( -if defined _oIds (set _oIds=!_oIds! %%D) else (set _oIds=%%D) -if /i 003D==%%C set SingleImage=1 +if %1==getmsiprod if %oVer%==%%A ( +for /f "tokens=*" %%x in ('findstr /i /c:"%%B" "%_oBranding%"') do set "prodId=%%x" +set prodId=!prodId:"/>=! +set prodId=!prodId:~-4! +reg query "%2\Registration\{%%B}" /v ProductCode %nul2% | find /i "-!prodId!-" %nul% && ( +reg query "%2\Common\InstalledPackages" %nul2% | find /i "-!prodId!-" %nul% && ( +if defined _oIds (set _oIds=!_oIds! %%E) else (set _oIds=%%E) ) ) ) @@ -3157,7 +2340,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: @@ -3196,7 +2379,7 @@ $Writer.Write($unixTimestamp) $Writer.Flush() # Write the current state of the MemoryStream to a temporary file -$tempFilePath = "$env:windir\Temp\$([System.IO.Path]::GetRandomFileName())" +$tempFilePath = [System.IO.Path]::Combine($env:windir, "Temp", [System.IO.Path]::GetRandomFileName()) [System.IO.File]::WriteAllBytes($tempFilePath, $MemoryStream.ToArray()) # Update hash using the temporary file @@ -3240,13 +2423,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..519c1bd 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.0 @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 @@ -136,7 +134,7 @@ echo: echo Null service is not running, script may crash... echo: echo: -echo Check this webpage for help - %mas%fix_service +echo Help - %mas%fix_service echo: echo: ping 127.0.0.1 -n 20 @@ -151,7 +149,7 @@ 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 Help - %mas%troubleshoot echo: echo: ping 127.0.0.1 -n 20 >nul @@ -200,41 +198,14 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" 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 ( +if %winbuild% LSS 7600 ( %nceline% echo Unsupported OS version detected [%winbuild%]. -echo MAS only supports Windows Vista/7/8/8.1/10/11 and their Server equivalents. -if %winbuild% EQU 6000 ( -echo: -echo Windows Vista RTM is not supported because Powershell cannot be installed. -echo Upgrade to Windows Vista SP1 or SP2. -) -goto dk_done -) - -if %winbuild% LSS 7600 if not exist "%SysPath%\WindowsPowerShell\v1.0\Modules" ( -%nceline% -if not exist %ps% ( -echo PowerShell is not installed in your system. -) -echo Install PowerShell 2.0 using the following URL. -echo: -echo https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 -if %_unattended%==0 start https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 +echo MAS only supports Windows 7/8/8.1/10/11 and their Server equivalents. goto dk_done ) @@ -270,6 +241,33 @@ goto dk_done ::======================================================================================================================================== +:: Check PowerShell + +REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +echo: +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% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto dk_done +) + +::======================================================================================================================================== + :: Elevate script as admin and pass arguments and preventing loop %nul1% fltmc || ( @@ -282,86 +280,6 @@ goto dk_done ::======================================================================================================================================== -:: Check PowerShell - -::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) - -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: - -REM check LanguageMode - -echo: !tstresult2! | 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... -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 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 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 ', '))}""" -) - -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 ( @@ -372,35 +290,34 @@ set terminal= :: Check if script is running in Terminal app +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + if defined terminal ( -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 -) -if !lines! GEQ 100 set terminal= +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= ) +if defined ps32onArm goto :skipQE 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 +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" ) +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) :skipQE ::======================================================================================================================================== @@ -409,18 +326,12 @@ exit /b 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= -) +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 activ%-%ated.win') do ( +if not "%%#"=="" set old=1 +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck%upver%.activ%-%ated.win') do ( +if not "%%#"=="" set old= ) ) @@ -437,7 +348,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) ) ) @@ -527,17 +438,12 @@ echo: echo Initializing... call :dk_chkmal -if not exist %SysPath%\%_slexe% ( +if not exist %SysPath%\sppsvc.exe ( %eline% -echo [%SysPath%\%_slexe%] file is missing, aborting... +echo [%SysPath%\sppsvc.exe] 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%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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -586,7 +492,7 @@ call :dk_color %Blue% "Internet is required for Online %KS% Activation." echo Initiating Diagnostic Tests... -set "_serv=%_slser% Winmgmt" +set "_serv=sppsvc Winmgmt" :: Software Protection :: Windows Management Instrumentation @@ -630,7 +536,7 @@ call :dk_color %Blue% "Go back to main menu and use [Change Edition] option." ) else ( call :dk_color %Blue% "Use TSforge activation option from the main menu to reset evaluation period." set fixes=%fixes% %mas%evaluation_editions -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" ) goto :ks_office @@ -654,7 +560,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) @@ -676,19 +582,17 @@ echo [%winos% ^| %winbuild% ^| SKU:%osSKU%] if %winbuild% GEQ 9200 if exist "%SysPath%\spp\tokens\skus\%osedition%\*GVLK*.xrm-ms" set sppks=1 if %winbuild% LSS 9200 if exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*VLKMS*.xrm-ms" set sppks=1 if %winbuild% LSS 9200 if exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*VL-BYPASS*.xrm-ms" set sppks=1 -if %winbuild% LSS 7600 if exist "%SysPath%\licensing\skus\Security-Licensing-SLC-Component-SKU-%osedition%\*KMS*.xrm-ms" set sppks=1 -if %winbuild% LSS 7600 if exist "%SysPath%\licensing\skus\Security-Licensing-SLC-Component-SKU-%osedition%\*VL-BYPASS*.xrm-ms" set sppks=1 if defined skunotfound ( -call :dk_color %Red% "Required license files not found." +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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) if defined sppks ( call :dk_color %Red% "%KS% activation is supported but failed to find the %KS% key." set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) if not defined skunotfound if not defined sppks ( @@ -721,7 +625,6 @@ call echo Checking Installed Product Key [Partial Key - %%_partial%%] [ ) if defined key ( -set generickey=1 call :dk_inskey "[%key%]" ) @@ -731,7 +634,7 @@ call :dk_inskey "[%key%]" if not %_actoff%==1 goto :ks_activate -call :oh_setspp +call :ks_setspp :: Check ohook install @@ -776,7 +679,7 @@ set ohub=1 :: Check supported office versions -call :oh_getpath +call :ks_getpath set o16uwp= set o16uwp_path= @@ -816,7 +719,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 +811,6 @@ set error=1 goto :ks_starto16c2r ) -call :oh_expiredpreview 2013 if "%_actprojvis%"=="0" call :oh_fixprids call :ks_process @@ -949,7 +851,6 @@ set error=1 goto :ks_startmsi ) -call :oh_expiredpreview 2016 2019 2021 2024 if "%_actprojvis%"=="0" call :oh_fixprids call :ks_process @@ -957,9 +858,9 @@ call :ks_process :ks_startmsi -if defined o14msi call :oh_setspp 14 +if defined o14msi call :ks_setspp 14 if defined o14msi call :ks_processmsi 14 %o14msi_reg% -call :oh_setspp +call :ks_setspp if defined o15msi call :ks_processmsi 15 %o15msi_reg% if defined o16msi call :ks_processmsi 16 %o16msi_reg% @@ -975,7 +876,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 +931,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 +944,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." @@ -1098,12 +999,12 @@ set _prids= set _config= set _version= set _License= -set _oMSI= +set _oBranding= exit /b ::======================================================================================================================================== -:oh_getpath +:ks_getpath set o16c2r= set o15c2r= @@ -1119,34 +1020,12 @@ for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\ClickToRun /v InstallPath" % 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 o15c2r=1&set o15c2r_reg=%_86%\15.0\ClickToRun) 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 o15c2r=1&set o15c2r_reg=%_68%\15.0\ClickToRun) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=1&set o14msi_reg=%_86%\14.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=1&set o14msi_reg=%_68%\14.0) - -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." -) -) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=1&set o14msi_reg=%_86%\14.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=1&set o14msi_reg=%_68%\14.0) exit /b @@ -1212,19 +1091,16 @@ exit /b ::======================================================================================================================================== -:oh_setspp +:ks_setspp -set isOspp= if %winbuild% GEQ 9200 ( set spp=SoftwareLicensingProduct set sps=SoftwareLicensingService ) else ( -set isOspp=1 set spp=OfficeSoftwareProtectionProduct set sps=OfficeSoftwareProtectionService ) if "%1"=="14" ( -set isOspp=1 set spp=OfficeSoftwareProtectionProduct set sps=OfficeSoftwareProtectionService ) @@ -1237,7 +1113,7 @@ exit /b for %%# in (%_oIds%) do ( set skipprocess= -if %_NoEditionChange%==1 if not defined _oMSI ( +if %_NoEditionChange%==1 if not defined _oBranding ( set foundprod= call :ksdata chkprod %%# if not defined foundprod ( @@ -1278,26 +1154,21 @@ 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 ) if not "!key!"=="" ( echo "!allapps!" | find /i "!_actid!" %nul1% || call :oh_installlic -set generickey=1 call :dk_inskey "[!key!] [!_prod!]" ) else ( -if not defined _oMSI ( +if not defined _oBranding ( set error=1 call :dk_color %Red% "Checking Product In Script [Office %oVer%.0 !_prod! not found in script]" call :dk_color %Blue% "Make sure you are using Latest MAS script." ) else ( call :dk_color %Red% "Checking Product In Script [!_prod! MSI Retail is not supported]" -call :dk_color %Blue% "Use Ohook option to activate it. To activate with %KS%, you need to install Volume version of Office." +call :dk_color %Blue% "Uninstall this and Install C2R or MSI VL version of Office." ) set fixes=%fixes% %mas%genuine-installation-media call :dk_color %_Yellow% "%mas%genuine-installation-media" @@ -1314,7 +1185,6 @@ exit /b :: Process Office MSI Version call :ks_reset -set _oMSI=1 if "%1"=="14" ( call :dk_actids 59a52881-a989-479d-af46-f275c6370663 @@ -1331,11 +1201,25 @@ echo "%2" | find /i "Wow6432Node" %nul1% && set _oArch=x86 if not "%osarch%"=="x86" if not defined _oArch set _oArch=x64 if "%osarch%"=="x86" set _oArch=x86 -call :msiofficedata %2 +set "_common=%CommonProgramFiles%" +if defined PROCESSOR_ARCHITEW6432 set "_common=%CommonProgramW6432%" +set "_common2=%CommonProgramFiles(x86)%" + +for /r "%_common%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" +if not defined _oBranding for /r "%_common2%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" + +call :ksdata getmsiprod %2 +call :ks_msiretaildata getmsiret %2 echo: echo Processing Office... [MSI ^| %_version% ^| %_oArch%] +if not defined _oBranding ( +set error=1 +call :dk_color %Red% "Checking BRANDING.XML [Not Found. Aborting activation...]" +exit /b +) + if not defined _oIds ( set error=1 call :dk_color %Red% "Checking Installed Products [Product IDs not found. Aborting activation...]" @@ -1385,7 +1269,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 +1284,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 +1336,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 +1362,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 +1369,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 +1380,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 +1463,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 +1474,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 +1512,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 +1527,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 +1583,8 @@ exit /b ::============================================================================ :: -:: Homepage: mass{}grave{dot}dev +:: Homepage: mass grave[.]dev +:: Email: mas.help@outlook.com :: ::============================================================================ @@ -1766,13 +1624,8 @@ 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" -set psc=powershell.exe -nop -c - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G +set psc=powershell.exe set run_once= set t_name=Renewal Task @@ -1785,7 +1638,6 @@ set _wmic=0 for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" 2>nul | find /i "computersystem" 1>nul && set _wmic=1 ) -if %winbuild% LSS 9200 set _wmic=1 setlocal EnableDelayedExpansion if exist "%ProgramFiles%\Activation-Renewal\" call :_taskstart>>"%ProgramFiles%\Activation-Renewal\Logs.txt" @@ -1838,7 +1690,7 @@ call :_taskclear-cache :: Check WMI and sppsvc Errors set applist= -net start %_slser% /y %nul% +net start sppsvc /y %nul% if %_wmic% EQU 1 set "chkapp=for /f "tokens=2 delims==" %%a in ('"wmic path %slp% where (ApplicationID='%_wApp%') get ID /VALUE" 2^>nul')" if %_wmic% EQU 0 set "chkapp=for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELECT ID FROM %slp% WHERE ApplicationID=''%_wApp%''').Get()).ID ^| %% {echo ('ID='+$_)}" 2^>nul')" %chkapp% do (if defined applist (call set "applist=!applist! %%a") else (call set "applist=%%a")) @@ -2140,20 +1992,12 @@ exit /b :_taskclear-cache set w= -for %%# in (SppE%w%xtComObj.exe sppsvc.exe SLsvc.exe) do ( +for %%# in (SppE%w%xtComObj.exe sppsvc.exe) do ( reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul% ) 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" @@ -2219,8 +2063,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) @@ -2269,17 +2113,16 @@ for /f %%G in ('%psc% "[Guid]::NewGuid().Guid"') do set "randguid=%%G" set "_temp=%SystemRoot%\Temp\%Random%%randguid%" set nil= -if %winbuild% LSS 7600 (set _vista=_vista) if exist "%_temp%\.*" rmdir /s /q "%_temp%\" %nul% md "%_temp%\" %nul% -call :ks_RenExport renewal%_vista% "%_temp%\Renewal.xml" Unicode -if not defined _int (call :ks_RenExport run_once%_vista% "%_temp%\Run_Once.xml" Unicode) +call :ks_RenExport renewal "%_temp%\Renewal.xml" Unicode +if not defined _int (call :ks_RenExport run_once "%_temp%\Run_Once.xml" Unicode) s%nil%cht%nil%asks /cre%nil%ate /tn "Activation-Renewal" /ru "SYS%nil%TEM" /xml "%_temp%\Renewal.xml" %nul% if not defined _int (s%nil%cht%nil%asks /cre%nil%ate /tn "Activation-Run_Once" /ru "SYS%nil%TEM" /xml "%_temp%\Run_Once.xml" %nul%) 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 +2152,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 +2177,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 @@ -2461,136 +2305,15 @@ exit /b :run_once: -:renewal_vista: - - - - 1999-01-01T12:00:00.34375 - WindowsAddict - Online K-M-S Activation-Renewal - Weekly Task - - - - 1999-01-01T12:00:00.34375 - true - - - - - 1 - - - - - - S-1-5-18 - HighestAvailable - - - - - PT10M - PT1H - true - false - - IgnoreNew - false - true - true - true - true - - true - true - false - false - false - PT10M - 7 - - PT5M - 3 - - - - - %ProgramFiles%\Activation-Renewal\Activation_task.cmd - Task - - - -:renewal_vista: - -:run_once_vista: - - - - 1999-01-01T12:00:00.34375 - WindowsAddict - Online K-M-S Activation Run Once - Run and Delete itself on first Internet Contact - - - - true - - - - - S-1-5-18 - HighestAvailable - - - - - PT10M - PT1H - true - false - - IgnoreNew - false - true - true - true - true - - true - true - false - false - false - PT10M - 7 - - PT5M - 3 - - - - - %ProgramFiles%\Activation-Renewal\Activation_task.cmd - Task - - - -:run_once_vista: - ::======================================================================================================================================== :: Set variables :dk_setvar -set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe -set psc=%ps% -nop -c +set psc=powershell.exe 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" - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set _NCS=1 if %winbuild% LSS 10586 set _NCS=0 @@ -2674,7 +2397,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% @@ -2731,23 +2454,19 @@ 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] +echo Installing Generic Product Key %~1 [Successful] ) else ( -call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%" -if not defined showfix ( +call :dk_color %Red% "Installing Generic Product Key %~1 [Failed] %keyerror%" +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 ) -set generickey= exit /b :: Get Windows installed key channel @@ -2772,9 +2491,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% @@ -2799,8 +2518,6 @@ exit /b :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" @@ -2828,13 +2545,13 @@ function InstallLicenseArr($Str) { ForEach ($x in $a) {InstallLicenseFile "$x"} } function InstallLicenseDir($Loc) { - Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName} + dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} } function ReinstallLicenses() { - $Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens") - foreach ($Path in $Paths) { - if (Test-Path $Path) { InstallLicenseDir "$Path" } - } + $Oem = "$env:SysPath\oem" + $Spp = "$env:SysPath\spp\tokens" + InstallLicenseDir "$Spp" + If (Test-Path $Oem) {InstallLicenseDir "$Oem"} } :xrm: @@ -2842,7 +2559,6 @@ function ReinstallLicenses() { :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 @@ -2853,21 +2569,16 @@ exit /b :dk_sppissue -sc start %_slser% %nul% +sc start sppsvc %nul% 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 sc start sppsvc [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'}" +%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}" exit /b :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) @@ -2875,7 +2586,7 @@ exit /b :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 d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') set winos= for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) @@ -2976,20 +2687,19 @@ 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% +sc start sppsvc %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 exist %SysPath%\sppsvc.exe 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 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware" echo: ) @@ -3008,118 +2718,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 @@ -3139,7 +2771,6 @@ for %%# in (%serv_ste%) do ( if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%) if /i %%#==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% @@ -3154,26 +2785,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 +2811,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% "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 +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" ) ) -::============================== - -:: 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,21 +2899,42 @@ 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" ( + +if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( set 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%]" ) ) ) + + +%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%" ) -::============================== -:: Check SKU value to find if there is any difference +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,76 +2952,191 @@ 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 ( + +for %%# in (SppEx%w%tComObj.exe sppsvc.exe sppsvc.exe\PerfOptions) do ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#")) ) 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 ( +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 +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. Help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" +set error=1 +set showfix=1 +) + + +set tokenstore= +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% "Help - " %_Yellow% " %mas%troubleshoot" +) + + +:: This code creates token folder only if it's missing and sets default permission for it + +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% "Start-Job { Stop-Service sppsvc -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 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 @@ -3641,7 +3146,7 @@ exit /b $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.*') { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { $count++ } } @@ -3650,7 +3155,7 @@ $minBuildNumber = 14393 if ($osVersion.Build -ge $minBuildNumber) { $subkeyHashTable = @{} foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { - if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { $keyNumber = $subkeyName -replace '.*-', '' $subkeyHashTable[$keyNumber] = $true } @@ -3664,7 +3169,7 @@ if ($osVersion.Build -ge $minBuildNumber) { } } $wpaKey.GetSubKeyNames() | ForEach-Object { - if ($_ -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($_ -match '.*-.*-.*-.*-.*-') { if ($PSVersionTable.PSVersion.Major -lt 3) { cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1" if ($LASTEXITCODE -ne 0) { @@ -3693,10 +3198,8 @@ $wpaKey.Close() if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -) else if not exist %ps% ( -echo %~3 ) exit /b @@ -3704,10 +3207,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' -) else if not exist %ps% ( -echo %~3 %~6 ) exit /b @@ -3722,8 +3223,7 @@ 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 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -3740,174 +3240,132 @@ exit /b :: 1st column = Office version number :: 2nd column = Activation ID -:: 3rd column = Product ID from branding.xml -:: 4th column = Edition -:: 5th column = Other Edition IDs if they are part of the same primary product (For reference only) +:: 3rd column = Edition +:: 4th column = Other Edition IDs if they are part of the same primary product (For reference only) :: Separator = "_" -:msiofficedata +:ks_msiretaildata for %%# in ( -14_4d463c2c-0505-4626-8cdb-a4da82e2d8ed_0015_AccessR -14_745fb377-0a59-4ca9-b9a9-c359557a2c4e_001C_AccessRuntimeR -14_95ab3ec8-4106-4f9d-b632-03c019d1d23f_0015_AccessVL -14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_0016_ExcelR_[HSExcelR] -14_71dc86ff-f056-40d0-8ffb-9592705c9b76_0016_ExcelVL -14_7004b7f0-6407-4f45-8eac-966e5f868bde_00BA_GrooveR -14_fdad0dfa-417d-4b4f-93e4-64ea8867b7fd_00BA_GrooveVL -14_7b7d1f17-fdcb-4820-9789-9bec6e377821_0013_HomeBusinessR_[HomeBusinessDemoR] -14_19316117-30a8-4773-8fd9-7f7231f4e060_011E_HomeBusinessSubR -14_09e2d37e-474b-4121-8626-58ad9be5776f_002F_HomeStudentR_[HomeStudentDemoR] -14_ef1da464-01c8-43a6-91af-e4e5713744f9_0044_InfoPathR -14_85e22450-b741-430c-a172-a37962c938af_0044_InfoPathVL -14_14f5946a-debc-4716-babc-7e2c240fec08_000F_MondoR -14_533b656a-4425-480b-8e30-1a2358898350_000F_MondoVL -14_c1ceda8b-c578-4d5d-a4aa-23626be4e234_003D_ProfessionalR_[OEM-SingleImage]Exception -14_3f7aa693-9a7e-44fc-9309-bb3d8e604925_00A1_OneNoteR_[HSOneNoteR] -14_6860b31f-6a67-48b8-84b9-e312b3485c4b_00A1_OneNoteVL -14_fbf4ac36-31c8-4340-8666-79873129cf40_001A_OutlookR -14_a9aeabd8-63b8-4079-a28e-f531807fd6b8_001A_OutlookVL -14_acb51361-c0db-4895-9497-1831c41f31a6_0033_PersonalR_[PersonalDemoR,PersonalPrepaidR] -14_133c8359-4e93-4241-8118-30bb18737ea0_0018_PowerPointR_[HSPowerPointR] -14_38252940-718c-4aa6-81a4-135398e53851_0018_PowerPointVL -14_8b559c37-0117-413e-921b-b853aeb6e210_0014_ProfessionalR_[ProfessionalAcadR,ProfessionalDemoR] -14_725714d7-d58f-4d12-9fa8-35873c6f7215_003B_ProjectProR_[ProjectProMSDNR] -14_4d06f72e-fd50-4bc2-a24b-d448d7f17ef2_011F_ProjectProSubR -14_1cf57a59-c532-4e56-9a7d-ffa2fe94b474_003B_ProjectProVL -14_688f6589-2bd9-424e-a152-b13f36aa6de1_003A_ProjectStdR -14_11b39439-6b93-4642-9570-f2eb81be2238_003A_ProjectStdVL -14_71af7e84-93e6-4363-9b69-699e04e74071_0011_ProPlusR_[ProPlusAcadR,ProPlusMSDNR,Sub4R] -14_e98ef0c0-71c4-42ce-8305-287d8721e26c_011D_ProPlusSubR -14_fdf3ecb9-b56f-43b2-a9b8-1b48b6bae1a7_0011_ProPlusVL_[ProPlusAcadVL] -14_98677603-a668-4fa4-9980-3f1f05f78f69_0019_PublisherR -14_3d014759-b128-4466-9018-e80f6320d9d0_0019_PublisherVL -14_dbe3aee0-5183-4ff7-8142-66050173cb01_008B_SmallBusBasicsR_[SmallBusBasicsMSDNR] -14_8090771e-d41a-4482-929e-de87f1f47e46_008B_SmallBusBasicsVL -14_b78df69e-0966-40b1-ae85-30a5134dedd0_0017_SPDR -14_d3422cfb-8d8b-4ead-99f9-eab0ccd990d7_0012_StandardR -14_1f76e346-e0be-49bc-9954-70ec53a4fcfe_0012_StandardVL_[StandardAcadVL] -14_2745e581-565a-4670-ae90-6bf7c57ffe43_0066_StarterR -14_66cad568-c2dc-459d-93ec-2f3cb967ee34_0057_VisioSIR_Prem[Pro,Std]Exception -14_36756cb8-8e69-4d11-9522-68899507cd6a_0057_VisioSIVL_Prem[Pro,Std]Exception -14_db3bbc9c-ce52-41d1-a46f-1a1d68059119_001B_WordR_[HSWordR] -14_98d4050e-9c98-49bf-9be1-85e12eb3ab13_001B_WordVL +:: Office 2010 +14_4d463c2c-0505-4626-8cdb-a4da82e2d8ed_AccessR +14_745fb377-0a59-4ca9-b9a9-c359557a2c4e_AccessRuntimeR +14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_ExcelR +14_7004b7f0-6407-4f45-8eac-966e5f868bde_GrooveR +14_7b7d1f17-fdcb-4820-9789-9bec6e377821_HomeBusinessR_[HomeBusinessDemoR] +14_19316117-30a8-4773-8fd9-7f7231f4e060_HomeBusinessSubR +14_09e2d37e-474b-4121-8626-58ad9be5776f_HomeStudentR_[HomeStudentDemoR] +14_c3ae020c-5a71-4cc5-a27a-2a97c2d46860_HSExcelR +14_25fe4611-b44d-49cc-ae87-2143d299194e_HSOneNoteR +14_d652ad8d-da5c-4358-b928-7fb1b4de7a7c_HSPowerPointR +14_a963d7ae-7a88-41a7-94da-8bb5635a8af9_HSWordR +14_ef1da464-01c8-43a6-91af-e4e5713744f9_InfoPathR +14_14f5946a-debc-4716-babc-7e2c240fec08_MondoR +14_c1ceda8b-c578-4d5d-a4aa-23626be4e234_OEM +14_3f7aa693-9a7e-44fc-9309-bb3d8e604925_OneNoteR +14_fbf4ac36-31c8-4340-8666-79873129cf40_OutlookR +14_acb51361-c0db-4895-9497-1831c41f31a6_PersonalR_[PersonalDemoR,PersonalPrepaidR] +14_133c8359-4e93-4241-8118-30bb18737ea0_PowerPointR +14_8b559c37-0117-413e-921b-b853aeb6e210_ProfessionalR_[ProfessionalAcadR,ProfessionalDemoR] +14_725714d7-d58f-4d12-9fa8-35873c6f7215_ProjectProR_[ProjectProMSDNR] +14_4d06f72e-fd50-4bc2-a24b-d448d7f17ef2_ProjectProSubR +14_688f6589-2bd9-424e-a152-b13f36aa6de1_ProjectStdR +14_71af7e84-93e6-4363-9b69-699e04e74071_ProPlusR_[ProPlusAcadR,ProPlusMSDNR,Sub4R] +14_e98ef0c0-71c4-42ce-8305-287d8721e26c_ProPlusSubR +14_98677603-a668-4fa4-9980-3f1f05f78f69_PublisherR +14_dbe3aee0-5183-4ff7-8142-66050173cb01_SmallBusBasicsR_[SmallBusBasicsMSDNR] +14_b78df69e-0966-40b1-ae85-30a5134dedd0_SPDR +14_d3422cfb-8d8b-4ead-99f9-eab0ccd990d7_StandardR +14_2745e581-565a-4670-ae90-6bf7c57ffe43_StarterR +14_66cad568-c2dc-459d-93ec-2f3cb967ee34_VisioSIR_Prem[Pro,Std] +14_db3bbc9c-ce52-41d1-a46f-1a1d68059119_WordR :: Office 2013 -15_ab4d047b-97cf-4126-a69f-34df08e2f254_0015_AccessRetail -15_259de5be-492b-44b3-9d78-9645f848f7b0_001C_AccessRuntimeRetail -15_4374022d-56b8-48c1-9bb7-d8f2fc726343_0015_AccessVolume -15_1b1d9bd5-12ea-4063-964c-16e7e87d6e08_0016_ExcelRetail -15_ac1ae7fd-b949-4e04-a330-849bc40638cf_0016_ExcelVolume -15_cfaf5356-49e3-48a8-ab3c-e729ab791250_00BA_GrooveRetail -15_4825ac28-ce41-45a7-9e6e-1fed74057601_00BA_GrooveVolume -15_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_00E7_HomeBusinessPipcRetail -15_cd256150-a898-441f-aac0-9f8f33390e45_0013_HomeBusinessRetail -15_1fdfb4e4-f9c9-41c4-b055-c80daf00697d_00CE_HomeStudentARMRetail -15_ebef9f05-5273-404a-9253-c5e252f50555_00DA_HomeStudentPlusARMRetail -15_98685d21-78bd-4c62-bc4f-653344a63035_002F_HomeStudentRetail -15_44984381-406e-4a35-b1c3-e54f499556e2_0044_InfoPathRetail -15_9e016989-4007-42a6-8051-64eb97110cf2_0044_InfoPathVolume -15_9103f3ce-1084-447a-827e-d6097f68c895_00EA_LyncAcademicRetail -15_ff693bf4-0276-4ddb-bb42-74ef1a0c9f4d_012D_LyncEntryRetail -15_fada6658-bfc6-4c4e-825a-59a89822cda8_012C_LyncRetail -15_e1264e10-afaf-4439-a98b-256df8bb156f_012C_LyncVolume -15_3169c8df-f659-4f95-9cc6-3115e6596e83_000F_MondoRetail -15_f33485a0-310b-4b72-9a0e-b1d605510dbd_000F_MondoVolume -15_3391e125-f6e4-4b1e-899c-a25e6092d40d_00A1_OneNoteFreeRetail -15_8b524bcc-67ea-4876-a509-45e46f6347e8_00A1_OneNoteRetail -15_b067e965-7521-455b-b9f7-c740204578a2_00A1_OneNoteVolume -15_12004b48-e6c8-4ffa-ad5a-ac8d4467765a_001A_OutlookRetail -15_8d577c50-ae5e-47fd-a240-24986f73d503_001A_OutlookVolume -15_5aab8561-1686-43f7-9ff5-2c861da58d17_00E6_PersonalPipcRetail -15_17e9df2d-ed91-4382-904b-4fed6a12caf0_0033_PersonalRetail -15_31743b82-bfbc-44b6-aa12-85d42e644d5b_0018_PowerPointRetail -15_e40dcb44-1d5c-4085-8e8f-943f33c4f004_0018_PowerPointVolume -15_4e26cac1-e15a-4467-9069-cb47b67fe191_00E8_ProfessionalPipcRetail -15_44bc70e2-fb83-4b09-9082-e5557e0c2ede_0014_ProfessionalRetail -15_f2435de4-5fc0-4e5b-ac97-34f515ec5ee7_003B_ProjectProRetail -15_ed34dc89-1c27-4ecd-8b2f-63d0f4cedc32_003B_ProjectProVolume -15_5517e6a2-739b-4822-946f-7f0f1c5934b1_003A_ProjectStdRetail -15_2b9e4a37-6230-4b42-bee2-e25ce86c8c7a_003A_ProjectStdVolume -15_064383fa-1538-491c-859b-0ecab169a0ab_0011_ProPlusRetail -15_2b88c4f2-ea8f-43cd-805e-4d41346e18a7_0011_ProPlusVolume -15_c3a0814a-70a4-471f-af37-2313a6331111_0019_PublisherRetail -15_38ea49f6-ad1d-43f1-9888-99a35d7c9409_0019_PublisherVolume -15_ba3e3833-6a7e-445a-89d0-7802a9a68588_0017_SPDRetail -15_32255c0a-16b4-4ce2-b388-8a4267e219eb_0012_StandardRetail -15_a24cca51-3d54-4c41-8a76-4031f5338cb2_0012_StandardVolume -15_15d12ad4-622d-4257-976c-5eb3282fb93d_0051_VisioProRetail -15_3e4294dd-a765-49bc-8dbd-cf8b62a4bd3d_0051_VisioProVolume -15_dae597ce-5823-4c77-9580-7268b93a4b23_0053_VisioStdRetail -15_44a1f6ff-0876-4edb-9169-dbb43101ee89_0053_VisioStdVolume -15_191509f2-6977-456f-ab30-cf0492b1e93a_001B_WordRetail -15_9cedef15-be37-4ff0-a08a-13a045540641_001B_WordVolume +15_ab4d047b-97cf-4126-a69f-34df08e2f254_AccessRetail +15_259de5be-492b-44b3-9d78-9645f848f7b0_AccessRuntimeRetail +15_1b1d9bd5-12ea-4063-964c-16e7e87d6e08_ExcelRetail +15_cfaf5356-49e3-48a8-ab3c-e729ab791250_GrooveRetail +15_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_HomeBusinessPipcRetail +15_a2b90e7a-a797-4713-af90-f0becf52a1dd_HomeBusinessRetail +15_1fdfb4e4-f9c9-41c4-b055-c80daf00697d_HomeStudentARMRetail +15_ebef9f05-5273-404a-9253-c5e252f50555_HomeStudentPlusARMRetail +15_f2de350d-3028-410a-bfae-283e00b44d0e_HomeStudentRetail +15_44984381-406e-4a35-b1c3-e54f499556e2_InfoPathRetail +15_9103f3ce-1084-447a-827e-d6097f68c895_LyncAcademicRetail +15_ff693bf4-0276-4ddb-bb42-74ef1a0c9f4d_LyncEntryRetail +15_fada6658-bfc6-4c4e-825a-59a89822cda8_LyncRetail +15_69ec9152-153b-471a-bf35-77ec88683eae_MondoRetail +15_3391e125-f6e4-4b1e-899c-a25e6092d40d_OneNoteFreeRetail +15_8b524bcc-67ea-4876-a509-45e46f6347e8_OneNoteRetail +15_12004b48-e6c8-4ffa-ad5a-ac8d4467765a_OutlookRetail +15_5aab8561-1686-43f7-9ff5-2c861da58d17_PersonalPipcRetail +15_17e9df2d-ed91-4382-904b-4fed6a12caf0_PersonalRetail +15_31743b82-bfbc-44b6-aa12-85d42e644d5b_PowerPointRetail +15_064383fa-1538-491c-859b-0ecab169a0ab_ProPlusRetail +15_4e26cac1-e15a-4467-9069-cb47b67fe191_ProfessionalPipcRetail +15_44bc70e2-fb83-4b09-9082-e5557e0c2ede_ProfessionalRetail +15_2f72340c-b555-418d-8b46-355944fe66b8_ProjectProRetail +15_58d95b09-6af6-453d-a976-8ef0ae0316b1_ProjectStdRetail +15_c3a0814a-70a4-471f-af37-2313a6331111_PublisherRetail +15_ba3e3833-6a7e-445a-89d0-7802a9a68588_SPDRetail +15_32255c0a-16b4-4ce2-b388-8a4267e219eb_StandardRetail +15_a56a3b37-3a35-4bbb-a036-eee5f1898eee_VisioProRetail +15_980f9e3e-f5a8-41c8-8596-61404addf677_VisioStdRetail +15_191509f2-6977-456f-ab30-cf0492b1e93a_WordRetail :: Office 365 - 15.0 version -15_befee371-a2f5-4648-85db-a2c55fdf324c_00E9_O365BusinessRetail -15_537ea5b5-7d50-4876-bd38-a53a77caca32_00D6_O365HomePremRetail -15_149dbce7-a48e-44db-8364-a53386cd4580_00D4_O365ProPlusRetail -15_bacd4614-5bef-4a5e-bafc-de4c788037a2_00D5_O365SmallBusPremRetail +15_6337137e-7c07-4197-8986-bece6a76fc33_O365BusinessRetail +15_537ea5b5-7d50-4876-bd38-a53a77caca32_O365HomePremRetail +15_149dbce7-a48e-44db-8364-a53386cd4580_O365ProPlusRetail +15_bacd4614-5bef-4a5e-bafc-de4c788037a2_O365SmallBusPremRetail :: Office 365 - 16.0 version -16_6337137e-7c07-4197-8986-bece6a76fc33_00E9_O365BusinessRetail -16_2f5c71b4-5b7a-4005-bb68-f9fac26f2ea3_00D6_O365EduCloudRetail -16_537ea5b5-7d50-4876-bd38-a53a77caca32_00D6_O365HomePremRetail -16_149dbce7-a48e-44db-8364-a53386cd4580_00D4_O365ProPlusRetail -16_bacd4614-5bef-4a5e-bafc-de4c788037a2_00D5_O365SmallBusPremRetail +16_6337137e-7c07-4197-8986-bece6a76fc33_O365BusinessRetail +16_2f5c71b4-5b7a-4005-bb68-f9fac26f2ea3_O365EduCloudRetail +16_537ea5b5-7d50-4876-bd38-a53a77caca32_O365HomePremRetail +16_149dbce7-a48e-44db-8364-a53386cd4580_O365ProPlusRetail +16_bacd4614-5bef-4a5e-bafc-de4c788037a2_O365SmallBusPremRetail :: Office 2016 -16_bfa358b0-98f1-4125-842e-585fa13032e6_0015_AccessRetail -16_9d9faf9e-d345-4b49-afce-68cb0a539c7c_001C_AccessRuntimeRetail -16_3b2fa33f-cd5a-43a5-bd95-f49f3f546b0b_0015_AccessVolume -16_424d52ff-7ad2-4bc7-8ac6-748d767b455d_0016_ExcelRetail -16_685062a7-6024-42e7-8c5f-6bb9e63e697f_0016_ExcelVolume -16_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_00E7_HomeBusinessPipcRetail -16_86834d00-7896-4a38-8fae-32f20b86fa2b_0013_HomeBusinessRetail -16_090896a0-ea98-48ac-b545-ba5da0eb0c9c_00CE_HomeStudentARMRetail -16_6bbe2077-01a4-4269-bf15-5bf4d8efc0b2_00DA_HomeStudentPlusARMRetail -16_c28acdb8-d8b3-4199-baa4-024d09e97c99_002F_HomeStudentRetail -16_e2127526-b60c-43e0-bed1-3c9dc3d5a468_002F_HomeStudentVNextRetail -16_b21367df-9545-4f02-9f24-240691da0e58_000F_MondoRetail -16_2cd0ea7e-749f-4288-a05e-567c573b2a6c_000F_MondoVolume -16_436366de-5579-4f24-96db-3893e4400030_00A3_OneNoteFreeRetail -16_83ac4dd9-1b93-40ed-aa55-ede25bb6af38_00A1_OneNoteRetail -16_23b672da-a456-4860-a8f3-e062a501d7e8_00A1_OneNoteVolume -16_5a670809-0983-4c2d-8aad-d3c2c5b7d5d1_001A_OutlookRetail -16_50059979-ac6f-4458-9e79-710bcb41721a_001A_OutlookVolume -16_5aab8561-1686-43f7-9ff5-2c861da58d17_00E6_PersonalPipcRetail -16_a9f645a1-0d6a-4978-926a-abcb363b72a6_0033_PersonalRetail -16_f32d1284-0792-49da-9ac6-deb2bc9c80b6_0018_PowerPointRetail -16_9b4060c9-a7f5-4a66-b732-faf248b7240f_0018_PowerPointVolume -16_4e26cac1-e15a-4467-9069-cb47b67fe191_00E8_ProfessionalPipcRetail -16_d64edc00-7453-4301-8428-197343fafb16_0014_ProfessionalRetail -16_0f42f316-00b1-48c5-ada4-2f52b5720ad0_003B_ProjectProRetail -16_82f502b5-b0b0-4349-bd2c-c560df85b248_003B_ProjectProVolume -16_16728639-a9ab-4994-b6d8-f81051e69833_003B_ProjectProXVolume -16_e9f0b3fc-962f-4944-ad06-05c10b6bcd5e_003A_ProjectStdRetail -16_82e6b314-2a62-4e51-9220-61358dd230e6_003A_ProjectStdVolume -16_431058f0-c059-44c5-b9e7-ed2dd46b6789_003A_ProjectStdXVolume -16_de52bd50-9564-4adc-8fcb-a345c17f84f9_0011_ProPlusRetail -16_c47456e3-265d-47b6-8ca0-c30abbd0ca36_0011_ProPlusVolume -16_6e0c1d99-c72e-4968-bcb7-ab79e03e201e_0019_PublisherRetail -16_fcc1757b-5d5f-486a-87cf-c4d6dedb6032_0019_PublisherVolume -16_971cd368-f2e1-49c1-aedd-330909ce18b6_012D_SkypeforBusinessEntryRetail -16_418d2b9f-b491-4d7f-84f1-49e27cc66597_012C_SkypeforBusinessRetail -16_03ca3b9a-0869-4749-8988-3cbc9d9f51bb_012C_SkypeforBusinessVolume -16_9103f3ce-1084-447a-827e-d6097f68c895_012C_SkypeServiceBypassRetail -16_4a31c291-3a12-4c64-b8ab-cd79212be45e_0012_StandardRetail -16_0ed94aac-2234-4309-ba29-74bdbb887083_0012_StandardVolume -16_2dfe2075-2d04-4e43-816a-eb60bbb77574_0051_VisioProRetail -16_295b2c03-4b1c-4221-b292-1411f468bd02_0051_VisioProVolume -16_0594dc12-8444-4912-936a-747ca742dbdb_0051_VisioProXVolume -16_c76dbcbc-d71b-4f45-b5b3-b7494cb4e23e_0053_VisioStdRetail -16_44151c2d-c398-471f-946f-7660542e3369_0053_VisioStdVolume -16_1d1c6879-39a3-47a5-9a6d-aceefa6a289d_0053_VisioStdXVolume -16_cacaa1bf-da53-4c3b-9700-11738ef1c2a5_001B_WordRetail -16_c3000759-551f-4f4a-bcac-a4b42cbf1de2_001B_WordVolume +16_bfa358b0-98f1-4125-842e-585fa13032e6_AccessRetail +16_9d9faf9e-d345-4b49-afce-68cb0a539c7c_AccessRuntimeRetail +16_424d52ff-7ad2-4bc7-8ac6-748d767b455d_ExcelRetail +16_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_HomeBusinessPipcRetail +16_86834d00-7896-4a38-8fae-32f20b86fa2b_HomeBusinessRetail +16_c28acdb8-d8b3-4199-baa4-024d09e97c99_HomeStudentRetail +16_090896a0-ea98-48ac-b545-ba5da0eb0c9c_HomeStudentARMRetail +16_6bbe2077-01a4-4269-bf15-5bf4d8efc0b2_HomeStudentPlusARMRetail +16_e2127526-b60c-43e0-bed1-3c9dc3d5a468_HomeStudentVNextRetail +16_69ec9152-153b-471a-bf35-77ec88683eae_MondoRetail +16_436366de-5579-4f24-96db-3893e4400030_OneNoteFreeRetail +16_83ac4dd9-1b93-40ed-aa55-ede25bb6af38_OneNoteRetail +16_5a670809-0983-4c2d-8aad-d3c2c5b7d5d1_OutlookRetail +16_5aab8561-1686-43f7-9ff5-2c861da58d17_PersonalPipcRetail +16_a9f645a1-0d6a-4978-926a-abcb363b72a6_PersonalRetail +16_f32d1284-0792-49da-9ac6-deb2bc9c80b6_PowerPointRetail +16_de52bd50-9564-4adc-8fcb-a345c17f84f9_ProPlusRetail +16_4e26cac1-e15a-4467-9069-cb47b67fe191_ProfessionalPipcRetail +16_d64edc00-7453-4301-8428-197343fafb16_ProfessionalRetail +16_2f72340c-b555-418d-8b46-355944fe66b8_ProjectProRetail +16_58d95b09-6af6-453d-a976-8ef0ae0316b1_ProjectStdRetail +16_6e0c1d99-c72e-4968-bcb7-ab79e03e201e_PublisherRetail +16_9103f3ce-1084-447a-827e-d6097f68c895_SkypeServiceBypassRetail +16_971cd368-f2e1-49c1-aedd-330909ce18b6_SkypeforBusinessEntryRetail +16_418d2b9f-b491-4d7f-84f1-49e27cc66597_SkypeforBusinessRetail +16_4a31c291-3a12-4c64-b8ab-cd79212be45e_StandardRetail +16_a56a3b37-3a35-4bbb-a036-eee5f1898eee_VisioProRetail +16_980f9e3e-f5a8-41c8-8596-61404addf677_VisioStdRetail +16_cacaa1bf-da53-4c3b-9700-11738ef1c2a5_WordRetail ) do ( for /f "tokens=1-5 delims=_" %%A in ("%%#") do ( -if "%oVer%"=="%%A" ( -reg query "%1\Registration\{%%B}" /v ProductCode %nul2% | find /i "-%%C-" %nul% && ( -reg query "%1\Common\InstalledPackages" %nul2% | find /i "-%%C-" %nul% && ( -if defined _oIds (set _oIds=!_oIds! %%D) else (set _oIds=%%D) -if /i 003D==%%C set SingleImage=1 +if %1==getmsiret if "%oVer%"=="%%A" ( +for /f "tokens=*" %%x in ('findstr /i /c:"%%B" "%_oBranding%"') do set "prodId=%%x" +set prodId=!prodId:"/>=! +set prodId=!prodId:~-4! +if "%oVer%"=="14" ( +REM Exception case for Visio because wrong primary product ID is mentioned in Branding.xml +echo %%C | find /i "Visio" %nul% && set prodId=0057 +) +reg query "%2\Registration\{%%B}" /v ProductCode %nul2% | find /i "-!prodId!-" %nul% && ( +reg query "%2\Common\InstalledPackages" %nul2% | find /i "-!prodId!-" %nul% && ( +if defined _oIds (set _oIds=!_oIds! %%C) else (set _oIds=%%C) ) ) ) @@ -4051,22 +3509,7 @@ a78b8bd9-8017-4df5-b86a-09f756affa7c_6TPJF-RBVHG-WBW2R-86QPH-6R%f%TM4__17_Server cda18cf3-c196-46ad-b289-60c072869994_TT8MH-CG224-D3D7Q-498W2-9Q%f%CTX__18_ServerHPC a78b8bd9-8017-4df5-b86a-09f756affa7c_6TPJF-RBVHG-WBW2R-86QPH-6R%f%TM4__29_ServerWebCore f772515c-0e87-48d5-a676-e6962c3e1195_736RG-XDKJK-V34PF-BHK87-J6%f%X3K__56_ServerEmbeddedSolution -:: Windows Vista -cfd8ff08-c0d7-452b-9f60-ef5c70c32094_VKK3X-68KWM-X2YGT-QR4M6-4B%f%WMV___4_Enterprise -4f3d1606-3fea-4c01-be3c-8d671c401e3b_YFKBB-PQJJV-G996G-VWGXY-2V%f%3X8___6_Business -2c682dc2-8b68-4f63-a165-ae291d4cf138_HMBQG-8H2RH-C77VX-27R82-VM%f%QBT__16_BusinessN -d4f54950-26f2-4fb4-ba21-ffab16afcade_VTC42-BM838-43QHV-84HX6-XJ%f%XKV__27_EnterpriseN -:: Windows Server 2008 -ad2542d4-9154-4c6d-8a44-30f11ee96989_TM24T-X9RMF-VWXK6-X8JC9-BF%f%GM2___7_ServerStandard -68b6e220-cf09-466b-92d3-45cd964b9509_7M67G-PC374-GR742-YH8V4-TC%f%BY3___8_ServerDatacenter -c1af4d90-d1bc-44ca-85d4-003ba33db3b9_YQGMW-MPWTJ-34KDK-48M3W-X4%f%Q6V__10_ServerEnterprise -01ef176b-3e0d-422a-b4f8-4ea880035e8f_4DWFP-JF3DJ-B7DTH-78FJB-PD%f%RHK__15_ServerEnterpriseIA64 -ddfa9f7c-f09e-40b9-8c1a-be877a9a7f4b_WYR28-R7TFJ-3X2YQ-YCY4H-M2%f%49D__17_ServerWeb -7afb1156-2c1d-40fc-b260-aab7442b62fe_RCTX3-KWVHP-BR6TB-RB6DM-6X%f%7HP__18_ServerComputeCluster -2401e3d0-c50a-4b58-87b2-7e794b7d2607_W7VD6-7JFBR-RX26B-YKQ3Y-6F%f%FFJ__36_ServerStandardV -fd09ef77-5647-4eff-809c-af2b64659a45_22XQ2-VRXRG-P8D42-K34TD-G3%f%QQC__37_ServerDatacenterV -8198490a-add0-47b2-b3ba-316b12d647b4_39BXF-X8Q23-P2WWT-38T2F-G3%f%FPG__38_ServerEnterpriseV -::======================================================================================================================================= +::======================================================================================================================================== :: Office 2010 8ce7e872-188c-4b98-9d90-f8f90b7aad02_V7Y44-9T38C-R2VJK-666HK-T7%f%DDX__14_AccessVL cee5d470-6e3b-4fcc-8c2b-d17428568a9f_H62QG-HXVKF-PP4HP-66KMR-CW%f%9BM__14_ExcelVL @@ -4113,7 +3556,7 @@ d9f5b1c6-5386-495a-88f9-9ad6b41ac9b3_6Q7VD-NX8JD-WJ2VH-88V73-4G%f%BJ7__15_WordVo 67c0fc0c-deba-401b-bf8b-9c8ad8395804_GNH9Y-D2J4T-FJHGG-QRVH7-QP%f%FDW__16_AccessVolume_-AccessRetail- c3e65d36-141f-4d2f-a303-a842ee756a29_9C2PK-NWTVB-JMPW8-BFT28-7F%f%TBF__16_ExcelVolume_-ExcelRetail- e914ea6e-a5fa-4439-a394-a9bb3293ca09_DMTCJ-KNRKX-26982-JYCKT-P7%f%KB6__16_MondoRetail -9caabccb-61b1-4b4b-8bec-d10a3c3ac2ce_HFTND-W9MK4-8B7MJ-B6C4G-XQ%f%BR2__16_MondoVolume_-O365AppsBasicRetail-O365BusinessRetail-O365EduCloudRetail-O365HomePremRetail-O365ProPlusRetail-O365SmallBusPremRetail- +9caabccb-61b1-4b4b-8bec-d10a3c3ac2ce_HFTND-W9MK4-8B7MJ-B6C4G-XQ%f%BR2__16_MondoVolume_-O365BusinessRetail-O365EduCloudRetail-O365HomePremRetail-O365ProPlusRetail-O365SmallBusPremRetail- 436366de-5579-4f24-96db-3893e4400030_XYNTG-R96FY-369HX-YFPHY-F9%f%CPM__16_OneNoteFreeRetail_[Bypass] d8cace59-33d2-4ac7-9b1b-9b72339c51c8_DR92N-9HTF2-97XKM-XW2WJ-XW%f%3J6__16_OneNoteVolume_-OneNoteRetail-OneNote2021Retail- ec9d9265-9d1e-4ed0-838a-cdc20f2551a1_R69KK-NTPKF-7M3Q4-QYBHW-6M%f%T9B__16_OutlookVolume_-OutlookRetail- @@ -4198,7 +3641,7 @@ if /i "%2"=="%%D" ( set key=%%B set _actid=%%A set _allactid=!_allactid! %%A -) else if not defined _oMSI if %_NoEditionChange%==0 ( +) else if not defined _oBranding if %_NoEditionChange%==0 ( echo: %%E | find /i "-%2-" %nul% && ( set key=%%B set _altoffid=%%D @@ -4208,6 +3651,21 @@ set _allactid=!_allactid! %%A ) ) +if %1==getmsiprod if "%oVer%"=="%%C" ( +for /f "tokens=*" %%x in ('findstr /i /c:"%%A" "%_oBranding%"') do set "prodId=%%x" +set prodId=!prodId:"/>=! +set prodId=!prodId:~-4! +if "%oVer%"=="14" ( +REM Exception case for Visio because wrong primary product ID is mentioned in Branding.xml +echo %%D | find /i "Visio" %nul% && set prodId=0057 +) +reg query "%2\Registration\{%%A}" /v ProductCode %nul2% | find /i "-!prodId!-" %nul% && ( +reg query "%2\Common\InstalledPackages" %nul2% | find /i "-!prodId!-" %nul% && ( +if defined _oIds (set _oIds=!_oIds! %%D) else (set _oIds=%%D) +) +) +) + ) ) exit /b @@ -4225,12 +3683,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..030e406 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.0 @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 @@ -145,7 +138,7 @@ echo: echo Null service is not running, script may crash... echo: echo: -echo Check this webpage for help - %mas%fix_service +echo Help - %mas%fix_service echo: echo: ping 127.0.0.1 -n 20 @@ -160,7 +153,7 @@ 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 Help - %mas%troubleshoot echo: echo: ping 127.0.0.1 -n 20 >nul @@ -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 ::======================================================================================================================================== @@ -215,55 +204,16 @@ 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 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%]. -echo MAS only supports Windows Vista/7/8/8.1/10/11 and their Server equivalents. -if %winbuild% EQU 6000 ( -echo: -echo Windows Vista RTM is not supported because Powershell cannot be installed. -echo Upgrade to Windows Vista SP1 or SP2. -) -goto dk_done -) - -if %winbuild% LSS 7600 if not exist "%SysPath%\WindowsPowerShell\v1.0\Modules" ( -%nceline% -if not exist %ps% ( -echo PowerShell is not installed in your system. -) -echo Install PowerShell 2.0 using the following URL. -echo: -echo https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 -if %_unattended%==0 start https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) if %winbuild% LSS 7600 ( -reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" /v Install %nul2% | find /i "0x1" %nul1% || ( -%eline% -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 +%nceline% +echo Unsupported OS version detected [%winbuild%]. +echo MAS only supports Windows 7/8/8.1/10/11 and their Server equivalents. goto dk_done ) -) ::======================================================================================================================================== @@ -297,6 +247,33 @@ goto dk_done ::======================================================================================================================================== +:: Check PowerShell + +REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +echo: +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% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto dk_done +) + +::======================================================================================================================================== + :: Elevate script as admin and pass arguments and preventing loop %nul1% fltmc || ( @@ -309,86 +286,6 @@ goto dk_done ::======================================================================================================================================== -:: Check PowerShell - -::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) - -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: - -REM check LanguageMode - -echo: !tstresult2! | 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... -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 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 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 ', '))}""" -) - -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 ( @@ -399,35 +296,34 @@ set terminal= :: Check if script is running in Terminal app +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + if defined terminal ( -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 -) -if !lines! GEQ 100 set terminal= +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= ) +if defined ps32onArm goto :skipQE 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 +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" ) +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) :skipQE ::======================================================================================================================================== @@ -436,18 +332,12 @@ exit /b 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= -) +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 activ%-%ated.win') do ( +if not "%%#"=="" set old=1 +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck%upver%.activ%-%ated.win') do ( +if not "%%#"=="" set old= ) ) @@ -464,7 +354,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) ) ) @@ -483,9 +373,9 @@ echo: echo ______________________________________________________________ echo: echo [1] Activate - Windows -echo [2] Activate - ESU -echo [3] Activate - Office [All] -echo [4] Activate - Office [Project/Visio] +echo [2] Activate - Windows [ESU] +echo [3] Activate - Office [All] +echo [4] Activate - Office [Project/Visio] echo [5] Activate - All echo _______________________________________________ echo: @@ -495,12 +385,7 @@ echo [A] Activate - Windows %KS% Host echo [B] Activate - Office %KS% Host echo [C] Activate - Windows 8/8.1 APPX Sideloading echo [D] Activate - Manually Select Products -if defined _vis ( -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 +394,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 +413,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 @@ -597,17 +431,12 @@ echo: echo Initializing... call :dk_chkmal -if not exist %SysPath%\%_slexe% ( +if not exist %SysPath%\sppsvc.exe ( %eline% -echo [%SysPath%\%_slexe%] file is missing, aborting... +echo [%SysPath%\sppsvc.exe] 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%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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -620,21 +449,21 @@ echo Install .NET Framework 4.8 and Windows Management Framework 5.1 ) echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) ) if %winbuild% LSS 9200 if exist "%SysPath%\wlms\wlms.exe" ( sc query wlms | find /i "RUNNING" %nul% && ( -sc stop %_slser% %nul% +sc stop sppsvc %nul% if !errorlevel! EQU 1051 ( %eline% -echo Evaluation WLMS service is running, %_slser% service can not be stopped. Aborting... +echo Evaluation WLMS service is running, sppsvc service can not be stopped. Aborting... echo Install Non-Eval version for Windows build %winbuild%. echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) ) @@ -661,79 +490,30 @@ 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" +set "_serv=sppsvc Winmgmt" :: Software Protection :: Windows Management Instrumentation call :dk_errorcheck +if defined error ( +call :dk_color %Red% "Some errors were detected. Aborting the operation..." +set fixes=%fixes% %mas%troubleshoot +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" +goto :dk_done +) + call :ts_getedition if not defined tsedition ( call :dk_color %Red% "Checking Windows Edition ID [Not found in installed licenses, aborting...]" set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto :dk_done ) -if /i !tsmethod!==KMS4k ( -call :_taskclear-cache -echo Clearing %KS% Cache [Successful] -) - ::======================================================================================================================================== if %_resall%==1 goto :ts_resetall @@ -755,24 +535,15 @@ 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 +552,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,164 +559,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 - -::======================================================================================================================================== - -:ts_winvista - -:: Process Windows Vista - -:: 1st column = Activation ID -:: 2nd column = Generic key -:: 3rd column = Key channel -:: 4th column = Edition ID -:: Separator = _ - -:: Keys aren't available for these editions, but since these editions aren't publicly available, it doesn't matter -:: a797d61e-1475-470b-86c8-f737a72c188d StarterN -:: 5e9f548a-c8a9-44e6-a6c2-3f8d0a7a99dd ServerComputeClusterV - -set f= -set key= -set tempid= -if not defined allapps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -for %%# in ( -:: WindowsVista -9de9abe2-d01d-4538-af84-4498bdbc2ba3_4D2XH-PRBMM-8Q22B-K8BM3-MR%f%W4W_____Retail_Business -db442be4-81ed-4ab3-9d66-2417e8a5c81c_76884-QXFY2-6Q2WX-2QTQ8-QX%f%X44_____Retail_BusinessN -b51791c2-b562-4b73-97b0-735a0e4429a6_YQPQV-RW8R3-XMPFG-RXG9R-JG%f%TVF_____Retail_Enterprise -58c37517-42f8-4723-bb44-30b05791ff2a_Q7J9R-G63R4-BFMHF-FWM9R-RW%f%DMV_____Retail_EnterpriseN -95c6e80a-0ff8-4bd0-95f2-c4a39b79d09e_RCG7P-TX42D-HM8FM-TCFCW-3V%f%4VD_____Retail_HomeBasic -d0333dad-c14e-46f2-b62a-8b47a1b9768b_HY2VV-XC6FF-MD6WV-FPYBQ-GF%f%JBT_____Retail_HomeBasicN -9e042223-03bf-49ae-808f-ff37f128d40d_X9HTF-MKJQQ-XK376-TJ7T4-76%f%PKF_____Retail_HomePremium -92d8977c-d506-4e63-b500-6d39283b6cd5_KJ6TP-PF9W2-23T3Q-XTV7M-PX%f%DT2_____Retail_HomePremiumN -89e51a3c-76c0-4beb-a650-53d34c8f8186_X9PYV-YBQRV-9BXWV-TQDMK-QD%f%WK4_____Retail_Starter -30fab9cc-8614-4339-989f-7ce61fb7a5c4_VMCB9-FDRV6-6CDQM-RV23K-RP%f%8F7_____Retail_Ultimate -1eefed20-8ac0-478c-8774-70cd44782ea1_CVX38-P27B4-2X8BT-RXD4J-V7%f%CKX_____Retail_UltimateN -:: WindowsServer2008 -c9ad502b-ef48-41d1-a2a0-38a38e82fed0_24FV9-H7JW8-C8Q6X-BQKMK-K9%f%77J_____Retail_ServerComputeCluster -866e924e-c2a3-4872-aca1-6b48c13962d5_6QBHY-DXTPJ-T9W3P-DTJXX-4V%f%QMB_____Retail_ServerDatacenter -d020c729-07f0-4f8f-87ce-bf803275c786_83TWG-TD3TC-HRDP2-K93FJ-Y3%f%4YC_OEM:NONSLP_ServerDatacenterV -32b40e5e-0c6d-4c6f-ab12-a031933fd2c6_MRB7H-QJRHG-FXTBR-B2Q2M-8W%f%MTJ_____Retail_ServerEnterprise -256cc990-1692-4ea8-965c-2d423d5dd24e_H4VB6-QPRWH-VDCYM-996P8-MH%f%KFY_OEM:NONSLP_ServerEnterpriseIA64 -1ba5e036-e386-42c4-b7eb-16bdb4fa1945_H8H7M-HDPQT-PJHQF-M7B83-9C%f%VGV_____Retail_ServerEnterpriseV -8df04457-07c8-4301-bce9-d61eb76cb2d6_RGBMC-PQBVF-94Q9K-HD63B-VY%f%6MP_____Retail_ServerHomePremium -5bd23b19-aa71-4a5b-8b68-c8801c2baff6_6C8KR-MD3QK-9GWFW-44CY2-W9%f%CBM_____Retail_ServerHomeStandard -b86c7736-91ff-4de9-bfa9-b32b8a09acac_7XRBY-6MP2K-VQPT8-F37JV-YY%f%Q83_____Retail_ServerMediumBusinessManagement -d3f5642f-081d-40b2-a4b9-efd3054d4584_6PDTD-JK48J-662TF-8J2QV-R4%f%CRB_____Retail_ServerMediumBusinessMessaging -c6936a36-69f3-4994-9857-3069c7b9ec7a_D694V-CMWKH-PY92X-PFQKQ-JC%f%B69_____Retail_ServerMediumBusinessSecurity -cc4c2cf8-ef29-4d8e-b168-2b65a3db3309_MRDK3-YYQF3-88BQJ-D6FJG-69%f%YJY_____Retail_ServerSBSPremium -b3827b27-bd38-4284-98af-e4f4d1c051a0_2KB23-GJRBD-W3T9C-6CH2W-39%f%B7V_____Retail_ServerSBSPrime -5dad0eff-3f6f-4310-8844-422f9dc7c84b_H4XDD-B27GY-667P6-XWVV7-GY%f%G8J_____Retail_ServerSBSStandard -603504f9-109f-49f0-9271-8c66f7878f58_8YVM4-YQBDH-7WDQM-R27WR-WV%f%CWG_____Retail_ServerStandard -65ab7338-9ad0-43fe-af1b-190b577495e2_H9MW3-6V7GK-94P9G-7FTPJ-VK%f%CKF_____Retail_ServerStandardV -2be204da-24a0-4943-b66c-81e8464acd7e_2264C-TD9T8-P8HPW-CC9GH-MH%f%M2V_____Retail_ServerStorageEnterprise -60207eba-8b4a-486c-a013-023b4b742c2f_RCYMT-YX342-8T6YY-XYHYC-3D%f%D7X_____Retail_ServerStorageExpress -368856e9-43f7-4601-8358-e561f36c7dd8_FKFT2-WXYY9-WBPY7-6YMY4-X4%f%8JF_____Retail_ServerStorageStandard -4bf433fa-ab04-4c6c-b55b-00170e14b8cd_8X9J7-HCJ7J-3WDJT-QM7D8-46%f%4YH_____Retail_ServerStorageWorkgroup -a77a6806-f59e-4953-97d7-229317b8e6a6_BGT39-9FYH7-X2CYD-T628F-QP%f%QPW_____Retail_ServerWeb -f92f836d-4d3e-4e90-a08f-2d612d65e716_HPH76-FHFPP-DRW9D-7W2V4-HW%f%GKT_____Retail_ServerWinSB -3059a9fd-b068-4f0d-acaf-66324dca67ac_2V8G6-KRXYR-MMGXJ-6RWM3-GX%f%CCG_____Retail_ServerWinSBV -) do ( -for /f "tokens=1-4 delims=_" %%A in ("%%#") do if %tsedition%==%%D if not defined key ( -echo "%allapps%" | find /i "%%A" %nul1% && ( -set key=%%B -set tempid=%%A -) -) -) - -if not defined key ( -set error=1 -call :dk_color %Red% "Checking Activation ID [%tsedition% SKU-%osSKU% not found in the system]" -call :dk_color %Blue% "%_fixmsg%" -goto :ts_esu -) - -echo Checking Activation ID [%tempid%] [%tsedition%] - -set generickey=1 -call :dk_inskey "[%key%]" -set tsids=%tsids% %tempid% goto :ts_esu ::======================================================================================================================================== @@ -1062,7 +668,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 @@ -1073,23 +679,25 @@ goto :ts_esu echo Resetting Rearm / GracePeriod [Successful] ) -set generickey=1 -call :dk_inskey "[%key%]" +%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 %keyerror% EQU 0 ( +call :dk_refresh +echo Installing Activable Evaluation Key [%key%] [Successful] +) else ( +set error=1 +call :dk_color %Red% "Installing Activable Evaluation Key [%key%] [Failed] %keyerror%" +call :dk_color %Blue% "%_fixmsg%" +) ::======================================================================================================================================== :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 +719,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- @@ -1132,7 +727,7 @@ REM Windows7EmbeddedPOSReady7 4f1f646c-1e66-4908-acc7-d1606229b29e_POS-ESU-Year3[1-3y]_-Embedded[POS]- REM Windows7EmbeddedStandard 6aaf1c7d-527f-4ed5-b908-9fc039dfc654_WES-ESU-Year3[1-3y]_-Embedded[Standard]- -REM WindowsServer2008/WindowsServer2008R2 +REM WindowsServer2008R2 8e7bfb1e-acc1-4f56-abae-b80fce56cd4b_Server-ESU-PA[1-6y]_-ServerDatacenter-ServerDatacenterCore-ServerDatacenterV-ServerDatacenterVCore-ServerStandard-ServerStandardCore-ServerStandardV-ServerStandardVCore-ServerEnterprise-ServerEnterpriseCore-ServerEnterpriseV-ServerEnterpriseVCore- REM Windows8.1 4afc620f-12a4-48ad-8015-2aebfbd6e47c_Client-ESU-Year3[1-3y]_-Enterprise-EnterpriseN-Professional-ProfessionalN- @@ -1140,10 +735,10 @@ 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% +83d49986-add3-41d7-ba33-87c7bfb5c0fb_Client-ESU-Year3[1-3y]_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN- +0b533b5e-08b6-44f9-b885-c2de291ba456_Client-ESU-Year6[4-6y]_-Education-EducationN-Enterprise-EnterpriseN-Professional-ProfessionalEducation-ProfessionalEducationN-ProfessionalN-ProfessionalWorkstation-ProfessionalWorkstationN- +4dac5a0c-5709-4595-a32c-14a56a4a6b31_Client-IoT-ESU-Year3[1-3y]_-IoTEnterprise- REM Removed IoTEnterpriseS because it already has longer support +f69e2d51-3bbd-4ddf-8da7-a145e9dca597_Client-IoT-ESU-Year6[4-6y]_-IoTEnterprise- REM Removed IoTEnterpriseS because it already has longer support ) do ( for /f "tokens=1-3 delims=_" %%A in ("%%#") do ( echo "%allapps%" | find /i "%%A" %nul1% && ( @@ -1162,18 +757,10 @@ set esuexistbutnosup=1 ) ) -if defined esuexistsup if defined _vis ( -set key=9FPV7-MWGT8-7XPDF-JC23W-WT7TW -REM This is a non-generic blocked MAK key for Server-ESU-PA -call :dk_inskey "[!key!]" -goto :ts_off -) - if defined esuexistsup ( echo "%tsids%" | find /i "4220f546-f522-46df-8202-4d07afd26454" %nul1% && ( echo "%tsids%" | find /i "7e94be23-b161-4956-a682-146ab291774c" %nul1% || ( -call :dk_color %Gray% "To get Client-ESU-Year6[4-6y] license, install updates from the below URL." -call :dk_color %Blue% "%mas%tsforge#windows-esu" +call :dk_color %Gray% "Now update Windows to get Client-ESU-Year6[4-6y] license and activate that using this script." ) ) goto :ts_off @@ -1185,20 +772,14 @@ 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 ) set esuavail= -if defined _vis if defined isServer set esuavail=1 -if %winbuild% LEQ 7602 if not defined _vis if not defined isThinpc set esuavail=1 +if %winbuild% LEQ 7602 if not defined isThinpc set esuavail=1 if %winbuild% GTR 7602 if %winbuild% LSS 10240 if defined isServer set esuavail=1 if %winbuild% GEQ 10240 if %winbuild% LEQ 19045 if not defined isServer set esuavail=1 if %winbuild% EQU 9600 set esuavail=1 @@ -1206,7 +787,7 @@ if %winbuild% EQU 9600 set esuavail=1 if defined esuavail ( call :dk_color %Red% "Checking Activation ID [ESU license is not found, make sure Windows is fully updated]" set fixes=%fixes% %mas%tsforge#windows-esu -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%tsforge#windows-esu" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%tsforge#windows-esu" ) else ( call :dk_color %Gray% "Checking Activation ID [ESU is not available for %winos%]" ) @@ -1220,7 +801,7 @@ if not %_actoff%==1 goto :ts_act if %winbuild% LSS 9200 ( echo: call :dk_color %Gray% "Checking Supported Office [TSforge for Office is supported on Windows 8 and later versions]" -call :dk_color %Blue% "On Windows Vista / 7, use Ohook activation option for Office instead." +call :dk_color %Blue% "On Windows 7 build, use Online %KS% activation option for Office instead." goto :ts_act ) @@ -1253,15 +834,14 @@ set o14c2r= set _68=HKLM\SOFTWARE\Microsoft\Office set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=Office 2010 MSI ) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o14msi=Office 2010 MSI ) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=Office 2010 MSI ) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o14msi=Office 2010 MSI ) %nul% reg query %_68%\14.0\CVH /f Click2run /k && set o14c2r=Office 2010 C2R %nul% reg query %_86%\14.0\CVH /f Click2run /k && set o14c2r=Office 2010 C2R if not "%o14msi%%o14c2r%"=="" ( echo: call :dk_color %Red% "Checking Unsupported Office Install [ %o14msi%%o14c2r%]" -if defined o14msi call :dk_color %Blue% "Use Ohook activation option for Office 2010." ) if %winbuild% GEQ 10240 %psc% "Get-AppxPackage -name "Microsoft.MicrosoftOfficeHub"" | find /i "Office" %nul1% && ( @@ -1317,7 +897,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 +1001,6 @@ set error=1 goto :ts_starto16c2r ) -call :oh_expiredpreview 2013 if "%_actprojvis%"=="0" call :oh_fixprids call :ts_process @@ -1463,30 +1042,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,22 +1070,11 @@ 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." ) -call :dk_color %Gray% "%KS% Host [Not to be confused with %KS% Client] license causes the %_slser% service to run continuously." +call :dk_color %Gray% "%KS% Host [Not to be confused with %KS% Client] license causes the sppsvc service to run continuously." call :dk_color %Blue% "Only use this activation when necessary, you can revert to normal activation from the previous menu." if %_unattended%==0 ( @@ -1539,18 +1088,16 @@ set _arr= set tempid= set keytype=kmshost -if defined _vis goto :ts_whost_vista - :: Install current edition csvlk license so that correct edition can reflect for csvlk 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) ) @@ -1572,53 +1119,6 @@ goto :ts_act ::======================================================================================================================================== -:ts_whost_vista - -:: Process Windows K-M-S host for Vista - -:: 1st column = Activation ID -:: 2nd column = CSVLK key -:: 3rd column = Edition IDs -:: Separator = _ - -set f= -set key= -set tempid= -if not defined allapps call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f - -for %%# in ( -:: WindowsVista -212a64dc-43b1-4d3d-a30c-2fc69d2095c6_TWVG3-9Q4P8-W9XJF-Y76FJ-DW%f%Q4R_-Business-BusinessN-Enterprise-EnterpriseN- -:: WindowsServer2008 -c90d1b4e-8aa8-439e-8b9e-b6d6b6a6d975_BHC4Q-6D7B7-QMVH7-4MKQH-Y9%f%VK7_-ServerComputeCluster-ServerDatacenter-ServerDatacenterV-ServerEnterprise-ServerEnterpriseIA64-ServerEnterpriseV-ServerStandard-ServerStandardV-ServerWeb- -56df4151-1f9f-41bf-acaa-2941c071872b_PVGKG-2R7XQ-7WTFD-FXTJR-DQ%f%BQ3_-ServerComputeCluster-ServerEnterprise-ServerEnterpriseV-ServerStandard-ServerStandardV-ServerWeb- -c448fa06-49d1-44ec-82bb-0085545c3b51_KH4PC-KJFX6-XFVHQ-GDK2G-JC%f%JY9_-ServerComputeCluster-ServerWeb- -) do ( -for /f "tokens=1-3 delims=_" %%A in ("%%#") do if not defined key ( -echo "%allapps%" | find /i "%%A" %nul1% && ( -echo "%%C" | find /i "-%tsedition%-" %nul1% && ( -set key=%%B -set tempid=%%A -) -) -) -) - -if defined key ( -echo Checking Activation ID [%tempid%] [%tsedition%] -) else ( -call :dk_color %Red% "Checking Activation ID [Not Found] [%tsedition%] [%osSKU%]" -call :dk_color %Blue% "%KS% Host license is not found on your system. It is available for the below editions." -call :dk_color %Blue% "Business, BusinessN, Enterprise, EnterpriseN, and Server editions, etc." -goto :ts_act -) - -call :dk_inskey "[%key%]" -set tsids=%tsids% %tempid% -goto :ts_act - -::======================================================================================================================================== - :ts_ohost :: Process Office K-M-S host @@ -1626,23 +1126,6 @@ goto :ts_act echo: echo Processing Office %KS% Host... -if defined _vis ( -echo: -call :dk_color %Blue% "Windows Vista and Server 2008 do not support the installation of Office KMS Host." -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% @@ -1668,7 +1151,7 @@ echo Checking Activation ID [%%A] [%%B] if not defined ohostexist ( call :dk_color %Gray% "Checking Activation ID [Not found for Office %KS% Host]" -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%tsforge#office-kms-host" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%tsforge#office-kms-host" ) echo: @@ -1695,17 +1178,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 @@ -1736,20 +1208,16 @@ goto :ts_act :ts_resetall echo: -if defined _vis ( -echo Processing Reset of Rearm / Timers... -) else ( 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." set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) else ( call :dk_color %Green% "Reset process has been successfully done." ) @@ -1764,17 +1232,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 +1249,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 @@ -1800,10 +1257,6 @@ goto :dk_done for /f "delims=" %%a in ('%psc% "$ids = Get-WmiObject -Query 'SELECT ID FROM SoftwareLicensingProduct' | Select-Object -ExpandProperty ID; $ids" %nul6%') do call set "allactids= %%a !allactids! " -if defined _vis ( -echo: -call :dk_color %Blue% "On Windows Vista and Server 2008, you must manually install the key before activating it." -) echo: call :dk_color %Gray% "Enter / Paste the Activation ID shown in first column in the opened text file, or just press Enter to return:" echo Add space after each Activation ID if you are adding multiple: @@ -1867,14 +1320,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,47 +1380,33 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) ) 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...) -) +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" +call :dk_color2 %Blue% "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 year 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 year ESU license is added just as a placeholder." ) ) -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." ) @@ -1983,7 +1422,7 @@ call :dk_reeval %nul% if not defined tsids if defined error if not defined showfix ( set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) goto :dk_done @@ -1999,7 +1438,8 @@ mode 100, 30 title Remove TSforge Activation %masver% echo: -echo TSforge activation doesn't modify any Windows components and doesn't install any new files. +echo TSforge activation doesn't modify any Windows component. +echo TSforge activation doesn't install any new file in the system. echo: echo Instead, it appends data to one of data files used by Software Protection Platform. echo: @@ -2026,7 +1466,7 @@ set _prids= set _config= set _version= set _License= -set _oMSI= +set _oBranding= exit /b ::======================================================================================================================================== @@ -2046,32 +1486,10 @@ for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\ClickToRun /v InstallPath" % 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 o15c2r=1&set o15c2r_reg=%_86%\15.0\ClickToRun) 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 o15c2r=1&set o15c2r_reg=%_68%\15.0\ClickToRun) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) - -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." -) -) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_86%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_68%\16.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.0) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_68%\15.0) exit /b @@ -2151,19 +1569,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,63 +1576,17 @@ 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) - -if defined no365 ( +echo %%# | findstr /i "O365" %nul% && ( 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 ( -echo %%# | findstr /i "ARM" %nul% && ( -set _License=MondoRetail -set _altoffid=MondoRetail -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!" @@ -2239,7 +1598,7 @@ call :dk_color %Red% "Checking Activation ID [Office %oVer%.0 ! set error=1 set showfix=1 set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) echo %%# | find /i "2024" %nul% && ( @@ -2255,7 +1614,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 ( echo %_oIds% | find /i "Retail" %nul1% && ( set scaIsNeeded=1 reg add %_config% /v SharedComputerLicensing /t REG_SZ /d "1" /f %nul1% @@ -2274,7 +1633,6 @@ exit /b call :ts_reset call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 -set _oMSI=1 set oVer=%1 for /f "skip=2 tokens=2*" %%a in ('"reg query %2\Common\InstallRoot /v Path" %nul6%') do (set "_oRoot=%%b") for /f "skip=2 tokens=2*" %%a in ('"reg query %2\Common\ProductVersion /v LastProduct" %nul6%') do (set "_version=%%b") @@ -2288,17 +1646,26 @@ set "_common=%CommonProgramFiles%" if defined PROCESSOR_ARCHITEW6432 set "_common=%CommonProgramW6432%" set "_common2=%CommonProgramFiles(x86)%" +for /r "%_common%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" +if not defined _oBranding for /r "%_common2%\Microsoft Shared\OFFICE%oVer%\" %%f in (BRANDING.XML) do if exist "%%f" set "_oBranding=%%f" + if exist "%_common%\Microsoft Shared\OFFICE%oVer%\Office Setup Controller\pkeyconfig-office.xrm-ms" ( set "pkeypath=%_common%\Microsoft Shared\OFFICE%oVer%\Office Setup Controller\pkeyconfig-office.xrm-ms" ) else if exist "%_common2%\Microsoft Shared\OFFICE%oVer%\Office Setup Controller\pkeyconfig-office.xrm-ms" ( set "pkeypath=%_common2%\Microsoft Shared\OFFICE%oVer%\Office Setup Controller\pkeyconfig-office.xrm-ms" ) -call :msiofficedata %2 +call :ts_msiofficedata %2 echo: echo Processing Office... [MSI ^| %_version% ^| %_oArch%] +if not defined _oBranding ( +set error=1 +call :dk_color %Red% "Checking BRANDING.XML [Not Found. Aborting activation...]" +exit /b +) + if not defined _oIds ( set error=1 call :dk_color %Red% "Checking Installed Products [Product IDs not found. Aborting activation...]" @@ -2348,7 +1715,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 +1730,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 +1782,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 +1808,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 +1815,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 +1826,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 +1909,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,79 +1920,20 @@ 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 -set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe -set psc=%ps% -nop -c +set psc=powershell.exe 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" - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set _NCS=1 if %winbuild% LSS 10586 set _NCS=0 @@ -2729,7 +2017,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% @@ -2764,7 +2052,7 @@ if ($r -eq 0) { :ts_checkwinperm -%psc% "Get-WmiObject -Query 'SELECT Name, Description FROM SoftwareLicensingProduct WHERE LicenseStatus=''1'' AND GracePeriodRemaining=''0'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn IS NULL' | Where-Object { $_.Description -notmatch 'KMS' } | Select-Object -Property Name" %nul2% | findstr /i "Windows" %nul1% && set _perm=1||set _perm= +%psc% "Get-WmiObject -Query 'SELECT Name, Description FROM SoftwareLicensingProduct WHERE LicenseStatus=''1'' AND GracePeriodRemaining=''0'' AND PartialProductKey IS NOT NULL AND LicenseDependsOn IS NULL' | Where-Object { $_.Description -notmatch 'KMS_' } | Select-Object -Property Name" %nul2% | findstr /i "Windows" %nul1% && set _perm=1||set _perm= exit /b :: Refresh license status @@ -2775,35 +2063,6 @@ if %_wmic% EQU 1 wmic path %sps% where __CLASS='%sps%' call RefreshLicenseStatus 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 showfix ( -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 -) - -set generickey= -exit /b - :: Activation command :dk_act @@ -2829,9 +2088,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% @@ -2856,8 +2115,6 @@ exit /b :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" @@ -2885,13 +2142,13 @@ function InstallLicenseArr($Str) { ForEach ($x in $a) {InstallLicenseFile "$x"} } function InstallLicenseDir($Loc) { - Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName} + dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} } function ReinstallLicenses() { - $Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens") - foreach ($Path in $Paths) { - if (Test-Path $Path) { InstallLicenseDir "$Path" } - } + $Oem = "$env:SysPath\oem" + $Spp = "$env:SysPath\spp\tokens" + InstallLicenseDir "$Spp" + If (Test-Path $Oem) {InstallLicenseDir "$Oem"} } :xrm: @@ -2899,7 +2156,6 @@ function ReinstallLicenses() { :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 @@ -2910,21 +2166,16 @@ exit /b :dk_sppissue -sc start %_slser% %nul% +sc start sppsvc %nul% 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 sc start sppsvc [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'}" +%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}" exit /b :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) @@ -2932,7 +2183,7 @@ exit /b :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 d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') set winos= for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) @@ -2988,20 +2239,19 @@ 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% +sc start sppsvc %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 exist %SysPath%\sppsvc.exe 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 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware" echo: ) @@ -3020,118 +2270,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 @@ -3151,7 +2323,6 @@ for %%# in (%serv_ste%) do ( if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%) if /i %%#==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% @@ -3166,26 +2337,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 +2363,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% "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 +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" ) ) -::============================== - -:: 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,21 +2451,42 @@ 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" ( + +if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( set 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%]" ) ) ) + + +%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%" ) -::============================== -:: Check SKU value to find if there is any difference +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,76 +2504,191 @@ 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 ( + +for %%# in (SppEx%w%tComObj.exe sppsvc.exe sppsvc.exe\PerfOptions) do ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#")) ) 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 ( +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 +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. Help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" +set error=1 +set showfix=1 +) + + +set tokenstore= +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% "Help - " %_Yellow% " %mas%troubleshoot" +) + + +:: This code creates token folder only if it's missing and sets default permission for it + +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% "Start-Job { Stop-Service sppsvc -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 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 @@ -3653,7 +2698,7 @@ exit /b $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.*') { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { $count++ } } @@ -3662,7 +2707,7 @@ $minBuildNumber = 14393 if ($osVersion.Build -ge $minBuildNumber) { $subkeyHashTable = @{} foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { - if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($subkeyName -match '.*-.*-.*-.*-.*-') { $keyNumber = $subkeyName -replace '.*-', '' $subkeyHashTable[$keyNumber] = $true } @@ -3676,7 +2721,7 @@ if ($osVersion.Build -ge $minBuildNumber) { } } $wpaKey.GetSubKeyNames() | ForEach-Object { - if ($_ -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') { + if ($_ -match '.*-.*-.*-.*-.*-') { if ($PSVersionTable.PSVersion.Major -lt 3) { cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1" if ($LASTEXITCODE -ne 0) { @@ -3705,10 +2750,8 @@ $wpaKey.Close() if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -) else if not exist %ps% ( -echo %~3 ) exit /b @@ -3716,10 +2759,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' -) else if not exist %ps% ( -echo %~3 %~6 ) exit /b @@ -3734,8 +2775,7 @@ 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 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -3752,233 +2792,26 @@ 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 Microsoft.Win32; using System; using System.IO; using System.Linq; using System.Runtime.InteropServices; + using System.ServiceProcess; using System.Text; + using LibTSforge.Crypto; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; + using LibTSforge.TokenStore; public enum PSVersion { Vista, Win7, + Win8Early, Win8, WinBlue, WinModern @@ -4049,8 +2882,8 @@ namespace LibTSforge 0x92, 0xA6, 0x56, 0x96 }; - // 2^31 - 8 minutes - public static readonly ulong TimerMax = (ulong)TimeSpan.FromMinutes(2147483640).Ticks; + // 2^31 - 1 minutes + public static ulong TimerMax = (ulong)TimeSpan.FromMinutes(2147483647).Ticks; public static readonly string ZeroCID = new string('0', 48); } @@ -4118,6 +2951,20 @@ namespace LibTSforge } return result; } + + public static T CastToStruct(this byte[] data) where T : struct + { + GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); + try + { + IntPtr ptr = handle.AddrOfPinnedObject(); + return (T)Marshal.PtrToStructure(ptr, typeof(T)); + } + finally + { + handle.Free(); + } + } } public static class FileStreamExt @@ -4138,12 +2985,6 @@ namespace LibTSforge public static class Utils { - [DllImport("kernel32.dll")] - public static extern uint GetSystemDefaultLCID(); - - [DllImport("kernel32.dll")] - public static extern bool Wow64EnableWow64FsRedirection(bool Wow64FsEnableRedirection); - public static string DecodeString(byte[] data) { return Encoding.Unicode.GetString(data).Trim('\0'); @@ -4154,6 +2995,9 @@ namespace LibTSforge return Encoding.Unicode.GetBytes(str + '\0'); } + [DllImport("kernel32.dll")] + public static extern uint GetSystemDefaultLCID(); + public static uint CRC32(byte[] data) { const uint polynomial = 0x04C11DB7; @@ -4177,6 +3021,157 @@ namespace LibTSforge return ~crc; } + public static void KillSPP() + { + ServiceController sc; + + try + { + sc = new ServiceController("sppsvc"); + + if (sc.Status == ServiceControllerStatus.Stopped) + return; + } + catch (InvalidOperationException ex) + { + throw new InvalidOperationException("Unable to access sppsvc: " + ex.Message); + } + + Logger.WriteLine("Stopping sppsvc..."); + + bool stopped = false; + + for (int i = 0; stopped == false && i < 60; i++) + { + try + { + if (sc.Status != ServiceControllerStatus.StopPending) + sc.Stop(); + + sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMilliseconds(500)); + } + catch (System.ServiceProcess.TimeoutException) + { + continue; + } + catch (InvalidOperationException) + { + System.Threading.Thread.Sleep(500); + continue; + } + + stopped = true; + } + + if (!stopped) + throw new System.TimeoutException("Failed to stop sppsvc"); + + Logger.WriteLine("sppsvc stopped successfully."); + } + + public static string GetPSPath(PSVersion version) + { + switch (version) + { + case PSVersion.Win7: + return Directory.GetFiles( + Environment.GetFolderPath(Environment.SpecialFolder.System), + "7B296FB0-376B-497e-B012-9C450E1B7327-*.C7483456-A289-439d-8115-601632D005A0") + .FirstOrDefault() ?? ""; + case PSVersion.Win8Early: + case PSVersion.WinBlue: + case PSVersion.Win8: + case PSVersion.WinModern: + return Path.Combine( + Environment.ExpandEnvironmentVariables( + (string)Registry.GetValue( + @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform", + "TokenStore", + string.Empty + ) + ), + "data.dat" + ); + default: + return ""; + } + } + + public static string GetTokensPath(PSVersion version) + { + switch (version) + { + case PSVersion.Win7: + return Path.Combine( + Environment.ExpandEnvironmentVariables("%WINDIR%"), + @"ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\tokens.dat" + ); + case PSVersion.Win8Early: + case PSVersion.WinBlue: + case PSVersion.Win8: + case PSVersion.WinModern: + return Path.Combine( + Environment.ExpandEnvironmentVariables( + (string)Registry.GetValue( + @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform", + "TokenStore", + string.Empty + ) + ), + "tokens.dat" + ); + default: + return ""; + } + } + + public static IPhysicalStore GetStore(PSVersion version, bool production) + { + string psPath; + + try + { + psPath = GetPSPath(version); + } + catch + { + throw new FileNotFoundException("Failed to get path of physical store."); + } + + if (string.IsNullOrEmpty(psPath) || !File.Exists(psPath)) + { + throw new FileNotFoundException(string.Format("Physical store not found at expected path {0}.", psPath)); + } + + if (version == PSVersion.Vista) + { + throw new NotSupportedException("Physical store editing is not supported for Windows Vista."); + } + + return version == PSVersion.Win7 ? new PhysicalStoreWin7(psPath, production) : (IPhysicalStore)new PhysicalStoreModern(psPath, production, version); + } + + public static ITokenStore GetTokenStore(PSVersion version) + { + string tokPath; + + try + { + tokPath = GetTokensPath(version); + } + catch + { + throw new FileNotFoundException("Failed to get path of physical store."); + } + + if (string.IsNullOrEmpty(tokPath) || !File.Exists(tokPath)) + { + throw new FileNotFoundException(string.Format("Token store not found at expected path {0}.", tokPath)); + } + + return new TokenStoreModern(tokPath); + } + public static string GetArchitecture() { string arch = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", EnvironmentVariableTarget.Machine).ToUpperInvariant(); @@ -4192,7 +3187,65 @@ namespace LibTSforge if (build >= 7600 && build <= 7602) return PSVersion.Win7; if (build == 9200) return PSVersion.Win8; - throw new NotSupportedException("Unable to auto-detect version info"); + throw new NotSupportedException("Unable to auto-detect version info, please specify one manually using the /ver argument."); + } + + public static bool DetectCurrentKey() + { + SLApi.RefreshLicenseStatus(); + + using (RegistryKey wpaKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\WPA")) + { + foreach (string subKey in wpaKey.GetSubKeyNames()) + { + if (subKey.StartsWith("8DEC0AF1") && subKey.EndsWith("-1")) + { + return subKey.Contains("P"); + } + } + } + + throw new FileNotFoundException("Failed to autodetect key type, specify physical store key with /prod or /test arguments."); + } + + public static void DumpStore(PSVersion version, bool production, string filePath, string encrFilePath) + { + if (encrFilePath == null) + { + encrFilePath = GetPSPath(version); + } + + if (string.IsNullOrEmpty(encrFilePath) || !File.Exists(encrFilePath)) + { + throw new FileNotFoundException("Store does not exist at expected path '" + encrFilePath + "'."); + } + + KillSPP(); + + using (FileStream fs = File.Open(encrFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)) + { + byte[] encrData = fs.ReadAllBytes(); + File.WriteAllBytes(filePath, PhysStoreCrypto.DecryptPhysicalStore(encrData, production)); + } + + Logger.WriteLine("Store dumped successfully to '" + filePath + "'."); + } + + public static void LoadStore(PSVersion version, bool production, string filePath) + { + if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) + { + throw new FileNotFoundException("Store file '" + filePath + "' does not exist."); + } + + KillSPP(); + + using (IPhysicalStore store = GetStore(version, production)) + { + store.WriteRaw(File.ReadAllBytes(filePath)); + } + + Logger.WriteLine("Loaded store file succesfully."); } } @@ -4208,7 +3261,7 @@ namespace LibTSforge } -// LibTSforge/SPP/PKeyConfig.cs +// SPP/PKeyConfig.cs namespace LibTSforge.SPP { using System; @@ -4234,7 +3287,7 @@ namespace LibTSforge.SPP public bool Contains(int n) { - return Start <= n && n <= End; + return Start <= n && End <= n; } } @@ -4285,8 +3338,8 @@ namespace LibTSforge.SPP public class PKeyConfig { - public readonly Dictionary Products = new Dictionary(); - private readonly List loadedPkeyConfigs = new List(); + public Dictionary Products = new Dictionary(); + private List loadedPkeyConfigs = new List(); public void LoadConfig(Guid actId) { @@ -4347,14 +3400,12 @@ namespace LibTSforge.SPP ranges[refActIdStr] = new List(); } - KeyRange keyRange = new KeyRange - { - Start = int.Parse(rangeNode.SelectSingleNode("./p:Start", nsmgr).InnerText), - End = int.Parse(rangeNode.SelectSingleNode("./p:End", nsmgr).InnerText), - EulaType = rangeNode.SelectSingleNode("./p:EulaType", nsmgr).InnerText, - PartNumber = rangeNode.SelectSingleNode("./p:PartNumber", nsmgr).InnerText, - Valid = rangeNode.SelectSingleNode("./p:IsValid", nsmgr).InnerText.ToLower() == "true" - }; + KeyRange keyRange = new KeyRange(); + keyRange.Start = int.Parse(rangeNode.SelectSingleNode("./p:Start", nsmgr).InnerText); + keyRange.End = int.Parse(rangeNode.SelectSingleNode("./p:End", nsmgr).InnerText); + keyRange.EulaType = rangeNode.SelectSingleNode("./p:EulaType", nsmgr).InnerText; + keyRange.PartNumber = rangeNode.SelectSingleNode("./p:PartNumber", nsmgr).InnerText; + keyRange.Valid = rangeNode.SelectSingleNode("./p:IsValid", nsmgr).InnerText.ToLower() == "true"; ranges[refActIdStr].Add(keyRange); } @@ -4364,30 +3415,19 @@ 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, - Edition = configNode.SelectSingleNode("./p:EditionId", nsmgr).InnerText, - 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, - Ranges = keyRanges, - ActivationId = refActId - }; + ProductConfig productConfig = new ProductConfig(); + productConfig.GroupId = group; + productConfig.Edition = configNode.SelectSingleNode("./p:EditionId", nsmgr).InnerText; + productConfig.Description = configNode.SelectSingleNode("./p:ProductDescription", nsmgr).InnerText; + productConfig.Channel = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText; + productConfig.Randomized = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText.ToLower() == "true"; + productConfig.Algorithm = algorithms[group]; + productConfig.Ranges = keyRanges; + productConfig.ActivationId = refActId; Products[refActId] = productConfig; } @@ -4430,18 +3470,23 @@ namespace LibTSforge.SPP } } } + + public PKeyConfig() + { + + } } } -// LibTSforge/SPP/ProductKey.cs +// SPP/ProductKey.cs namespace LibTSforge.SPP { using System; using System.IO; using System.Linq; - using Crypto; - using PhysicalStore; + using LibTSforge.Crypto; + using LibTSforge.PhysicalStore; public class ProductKey { @@ -4455,11 +3500,11 @@ namespace LibTSforge.SPP public ulong Security; public bool Upgrade; public PKeyAlgorithm Algorithm; - public readonly string EulaType; - public readonly string PartNumber; - public readonly string Edition; - public readonly string Channel; - public readonly Guid ActivationId; + public string EulaType; + public string PartNumber; + public string Edition; + public string Channel; + public Guid ActivationId; private string mpc; private string pid2; @@ -4469,11 +3514,6 @@ namespace LibTSforge.SPP get { return BitConverter.GetBytes(klow).Concat(BitConverter.GetBytes(khigh)).ToArray(); } } - public ProductKey() - { - - } - public ProductKey(int serial, ulong security, bool upgrade, PKeyAlgorithm algorithm, ProductConfig config, KeyRange range) { Group = config.GroupId; @@ -4502,22 +3542,22 @@ namespace LibTSforge.SPP public Guid GetPkeyId() { - VariableBag pkb = new VariableBag(PSVersion.WinModern); - pkb.Blocks.AddRange(new[] + VariableBag pkb = new VariableBag(); + pkb.Blocks.AddRange(new CRCBlock[] { - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyBindingProductKey", ValueAsStr = ToString() }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = "SppPkeyBindingMiscData", Value = new byte[] { } }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyBindingAlgorithm", @@ -4528,6 +3568,16 @@ namespace LibTSforge.SPP return new Guid(CryptoUtils.SHA256Hash(pkb.Serialize()).Take(16).ToArray()); } + public string GetDefaultMPC() + { + int build = Environment.OSVersion.Version.Build; + string defaultMPC = build >= 10240 ? "03612" : + build >= 9600 ? "06401" : + build >= 9200 ? "05426" : + "55041"; + return defaultMPC; + } + public string GetMPC() { if (mpc != null) @@ -4535,15 +3585,10 @@ namespace LibTSforge.SPP return mpc; } - int build = Environment.OSVersion.Version.Build; - - mpc = build >= 10240 ? "03612" : - build >= 9600 ? "06401" : - build >= 9200 ? "05426" : - "55041"; + mpc = GetDefaultMPC(); // setup.cfg doesn't exist in Windows 8+ - string setupcfg = string.Format(@"{0}\oobe\{1}", Environment.SystemDirectory, "setup.cfg"); + string setupcfg = string.Format("{0}\\oobe\\{1}", Environment.SystemDirectory, "setup.cfg"); if (!File.Exists(setupcfg) || Edition.Contains(";")) { @@ -4681,17 +3726,17 @@ namespace LibTSforge.SPP { if (version == PSVersion.Win7) { - ulong shortauth = ((ulong)Group << 41) | (Security << 31) | ((ulong)Serial << 1) | (Upgrade ? (ulong)1 : 0); - return BitConverter.GetBytes(shortauth); + Random rnd = new Random(Group * 1000000000 + Serial); + byte[] data = new byte[8]; + rnd.NextBytes(data); + return data; } int serialHigh = Serial / 1000000; int serialLow = Serial % 1000000; BinaryWriter writer = new BinaryWriter(new MemoryStream()); - string algoId = Algorithm == PKeyAlgorithm.PKEY2005 ? "B8731595-A2F6-430B-A799-FBFFB81A8D73" : "660672EF-7809-4CFD-8D54-41B7FB738988"; - - writer.Write(new Guid(algoId).ToByteArray()); + writer.Write(new Guid("B8731595-A2F6-430B-A799-FBFFB81A8D73").ToByteArray()); writer.Write(Group); writer.Write(serialHigh); writer.Write(serialLow); @@ -4750,7 +3795,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/SLAPI.cs +// SPP/SLAPI.cs namespace LibTSforge.SPP { using System; @@ -4797,40 +3842,40 @@ namespace LibTSforge.SPP public static readonly Guid WINDOWS_APP_ID = new Guid("55c92734-d682-4d71-983e-d6ec3f16059f"); - [DllImport("slc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] private static extern void SLOpen(out IntPtr hSLC); - [DllImport("slc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] private static extern void SLClose(IntPtr hSLC); [DllImport("slc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetWindowsInformationDWORD(string ValueName, ref int Value); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLInstallProofOfPurchase(IntPtr hSLC, string pwszPKeyAlgorithm, string pwszPKeyString, uint cbPKeySpecificData, byte[] pbPKeySpecificData, ref Guid PKeyId); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLUninstallProofOfPurchase(IntPtr hSLC, ref Guid PKeyId); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetPKeyInformation(IntPtr hSLC, ref Guid pPKeyId, string pwszValueName, out SLDATATYPE peDataType, out uint pcbValue, out IntPtr ppbValue); - [DllImport("slcext.dll", CharSet = CharSet.Unicode)] + [DllImport("sppcext.dll", CharSet = CharSet.Unicode)] private static extern uint SLActivateProduct(IntPtr hSLC, ref Guid pProductSkuId, byte[] cbAppSpecificData, byte[] pvAppSpecificData, byte[] pActivationInfo, string pwszProxyServer, ushort wProxyPort); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGenerateOfflineInstallationId(IntPtr hSLC, ref Guid pProductSkuId, ref string ppwszInstallationId); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLDepositOfflineConfirmationId(IntPtr hSLC, ref Guid pProductSkuId, string pwszInstallationId, string pwszConfirmationId); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetSLIDList(IntPtr hSLC, SLIDTYPE eQueryIdType, ref Guid pQueryId, SLIDTYPE eReturnIdType, out uint pnReturnIds, out IntPtr ppReturnIds); - [DllImport("slc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] private static extern void SLGetLicensingStatusInformation(IntPtr hSLC, ref Guid pAppID, IntPtr pProductSkuId, string pwszRightName, out uint pnStatusCount, out IntPtr ppLicensingStatus); - [DllImport("slc.dll", CharSet = CharSet.Unicode)] + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetInstalledProductKeyIds(IntPtr hSLC, ref Guid pProductSkuId, out uint pnProductKeyIds, out IntPtr ppProductKeyIds); [DllImport("slc.dll", CharSet = CharSet.Unicode)] @@ -4839,6 +3884,9 @@ namespace LibTSforge.SPP [DllImport("slc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetProductSkuInformation(IntPtr hSLC, ref Guid pProductSkuId, string pwszValueName, out SLDATATYPE peDataType, out uint pcbValue, out IntPtr ppbValue); + [DllImport("slc.dll", CharSet = CharSet.Unicode)] + private static extern uint SLGetProductSkuInformation(IntPtr hSLC, ref Guid pProductSkuId, string pwszValueName, IntPtr peDataType, out uint pcbValue, out IntPtr ppbValue); + [DllImport("slc.dll", CharSet = CharSet.Unicode)] private static extern uint SLGetLicense(IntPtr hSLC, ref Guid pLicenseFileId, out uint pcbLicenseFile, out IntPtr ppbLicenseFile); @@ -4848,7 +3896,7 @@ namespace LibTSforge.SPP [DllImport("slc.dll", CharSet = CharSet.Unicode)] private static extern uint SLFireEvent(IntPtr hSLC, string pwszEventId, ref Guid pApplicationId); - private class SLContext : IDisposable + public class SLContext : IDisposable { public readonly IntPtr Handle; @@ -4911,10 +3959,11 @@ namespace LibTSforge.SPP { using (SLContext sl = new SLContext()) { + uint status; uint count; IntPtr pProductKeyIds; - uint status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_PRODUCT_SKU, ref actId, SLIDTYPE.SL_ID_PKEY, out count, out pProductKeyIds); + status = SLGetInstalledProductKeyIds(sl.Handle, ref actId, out count, out pProductKeyIds); if (status != 0 || count == 0) { @@ -4938,7 +3987,7 @@ namespace LibTSforge.SPP SLConsumeWindowsRight(0); } - public static void RefreshTrustedTime(Guid actId) + public static bool RefreshTrustedTime(Guid actId) { using (SLContext sl = new SLContext()) { @@ -4946,7 +3995,8 @@ namespace LibTSforge.SPP uint count; IntPtr ppbValue; - SLGetProductSkuInformation(sl.Handle, ref actId, "TrustedTime", out type, out count, out ppbValue); + uint status = SLGetProductSkuInformation(sl.Handle, ref actId, "TrustedTime", out type, out count, out ppbValue); + return (int)status >= 0 && status != 0xC004F012; } } @@ -4962,10 +4012,11 @@ namespace LibTSforge.SPP { using (SLContext sl = new SLContext()) { + uint status; uint count; IntPtr pAppIds; - uint status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_PRODUCT_SKU, ref actId, SLIDTYPE.SL_ID_APPLICATION, out count, out pAppIds); + status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_PRODUCT_SKU, ref actId, SLIDTYPE.SL_ID_APPLICATION, out count, out pAppIds); if (status != 0 || count == 0) { @@ -4993,10 +4044,11 @@ namespace LibTSforge.SPP { using (SLContext sl = new SLContext()) { + uint status; uint count; IntPtr ppReturnLics; - uint status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_LICENSE, ref licId, SLIDTYPE.SL_ID_LICENSE_FILE, out count, out ppReturnLics); + status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_LICENSE, ref licId, SLIDTYPE.SL_ID_LICENSE_FILE, out count, out ppReturnLics); if (status != 0 || count == 0) { @@ -5058,7 +4110,7 @@ namespace LibTSforge.SPP IntPtr ppbValue; uint status = SLGetProductSkuInformation(sl.Handle, ref actId, "msft:sl/EUL/PHONE/PUBLIC", out type, out count, out ppbValue); - return status != 0xC004F012; + return status >= 0 && status != 0xC004F012; } } @@ -5141,11 +4193,11 @@ namespace LibTSforge.SPP } } - public static void UninstallProductKey(Guid pkeyId) + public static uint UninstallProductKey(Guid pkeyId) { using (SLContext sl = new SLContext()) { - SLUninstallProofOfPurchase(sl.Handle, ref pkeyId); + return SLUninstallProofOfPurchase(sl.Handle, ref pkeyId); } } @@ -5163,391 +4215,7 @@ namespace LibTSforge.SPP } -// LibTSforge/SPP/SPPUtils.cs -namespace LibTSforge.SPP -{ - using Microsoft.Win32; - using System; - using System.IO; - using System.Linq; - using System.ServiceProcess; - using Crypto; - using PhysicalStore; - using TokenStore; - - public static class SPPUtils - { - public static void KillSPP(PSVersion version) - { - ServiceController sc; - - string svcName = version == PSVersion.Vista ? "slsvc" : "sppsvc"; - - try - { - sc = new ServiceController(svcName); - - if (sc.Status == ServiceControllerStatus.Stopped) - return; - } - catch (InvalidOperationException ex) - { - throw new InvalidOperationException(string.Format("Unable to access {0}: ", svcName) + ex.Message); - } - - Logger.WriteLine(string.Format("Stopping {0}...", svcName)); - - bool stopped = false; - - for (int i = 0; stopped == false && i < 1080; i++) - { - try - { - if (sc.Status != ServiceControllerStatus.StopPending) - sc.Stop(); - - sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMilliseconds(500)); - } - catch (System.ServiceProcess.TimeoutException) - { - continue; - } - catch (InvalidOperationException ex) - { - Logger.WriteLine("Warning: Stopping sppsvc failed, retrying. Details: " + ex.Message); - System.Threading.Thread.Sleep(500); - continue; - } - - stopped = true; - } - - if (!stopped) - throw new System.TimeoutException(string.Format("Failed to stop {0}", svcName)); - - Logger.WriteLine(string.Format("{0} stopped successfully.", svcName)); - - if (version == PSVersion.Vista && SPSys.IsSpSysRunning()) - { - Logger.WriteLine("Unloading spsys..."); - - int status = SPSys.ControlSpSys(false); - - if (status < 0) - { - throw new IOException("Failed to unload spsys"); - } - - Logger.WriteLine("spsys unloaded successfully."); - } - } - - public static void RestartSPP(PSVersion version) - { - if (version == PSVersion.Vista) - { - ServiceController sc; - - try - { - sc = new ServiceController("slsvc"); - - if (sc.Status == ServiceControllerStatus.Running) - return; - } - catch (InvalidOperationException ex) - { - throw new InvalidOperationException("Unable to access slsvc: " + ex.Message); - } - - Logger.WriteLine("Starting slsvc..."); - - bool started = false; - - for (int i = 0; started == false && i < 360; i++) - { - try - { - if (sc.Status != ServiceControllerStatus.StartPending) - sc.Start(); - - sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromMilliseconds(500)); - } - catch (System.ServiceProcess.TimeoutException) - { - continue; - } - catch (InvalidOperationException ex) - { - Logger.WriteLine("Warning: Starting slsvc failed, retrying. Details: " + ex.Message); - System.Threading.Thread.Sleep(500); - continue; - } - - started = true; - } - - if (!started) - throw new System.TimeoutException("Failed to start slsvc"); - - Logger.WriteLine("slsvc started successfully."); - } - - SLApi.RefreshLicenseStatus(); - } - - public static bool DetectCurrentKey() - { - SLApi.RefreshLicenseStatus(); - - using (RegistryKey wpaKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\WPA")) - { - foreach (string subKey in wpaKey.GetSubKeyNames()) - { - if (subKey.StartsWith("8DEC0AF1")) - { - return subKey.Contains("P"); - } - } - } - - throw new FileNotFoundException("Failed to autodetect key type, specify physical store key with /prod or /test arguments."); - } - - public static string GetPSPath(PSVersion version) - { - switch (version) - { - case PSVersion.Vista: - case PSVersion.Win7: - return Directory.GetFiles( - Environment.GetFolderPath(Environment.SpecialFolder.System), - "7B296FB0-376B-497e-B012-9C450E1B7327-*.C7483456-A289-439d-8115-601632D005A0") - .FirstOrDefault() ?? ""; - default: - string psDir = Environment.ExpandEnvironmentVariables( - (string)Registry.GetValue( - @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform", - "TokenStore", - "" - ) - ); - string psPath = Path.Combine(psDir, "data.dat"); - - if (string.IsNullOrEmpty(psDir) || !File.Exists(psPath)) - { - string[] psDirs = - { - @"spp\store", - @"spp\store\2.0", - @"spp\store_test", - @"spp\store_test\2.0" - }; - - foreach (string dir in psDirs) - { - psPath = Path.Combine( - Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.System), - dir - ), - "data.dat" - ); - - if (File.Exists(psPath)) return psPath; - } - } - else - { - return psPath; - } - - throw new FileNotFoundException("Failed to locate physical store."); - } - } - - public static string GetTokensPath(PSVersion version) - { - switch (version) - { - case PSVersion.Vista: - return Path.Combine( - Environment.ExpandEnvironmentVariables("%WINDIR%"), - @"ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareLicensing\tokens.dat" - ); - case PSVersion.Win7: - return Path.Combine( - Environment.ExpandEnvironmentVariables("%WINDIR%"), - @"ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\tokens.dat" - ); - default: - string tokDir = Environment.ExpandEnvironmentVariables( - (string)Registry.GetValue( - @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform", - "TokenStore", - "" - ) - ); - string tokPath = Path.Combine(tokDir, "tokens.dat"); - - if (string.IsNullOrEmpty(tokDir) || !File.Exists(tokPath)) - { - string[] tokDirs = - { - @"spp\store", - @"spp\store\2.0", - @"spp\store_test", - @"spp\store_test\2.0" - }; - - foreach (string dir in tokDirs) - { - tokPath = Path.Combine( - Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.System), - dir - ), - "tokens.dat" - ); - - if (File.Exists(tokPath)) return tokPath; - } - } - else - { - return tokPath; - } - - throw new FileNotFoundException("Failed to locate token store."); - } - } - - public static IPhysicalStore GetStore(PSVersion version, bool production) - { - string psPath = GetPSPath(version); - - switch (version) - { - case PSVersion.Vista: - return new PhysicalStoreVista(psPath, production); - case PSVersion.Win7: - return new PhysicalStoreWin7(psPath, production); - default: - return new PhysicalStoreModern(psPath, production, version); - } - } - - public static ITokenStore GetTokenStore(PSVersion version) - { - string tokPath = GetTokensPath(version); - - return new TokenStoreModern(tokPath); - } - - public static void DumpStore(PSVersion version, bool production, string filePath, string encrFilePath) - { - bool manageSpp = false; - - if (encrFilePath == null) - { - encrFilePath = GetPSPath(version); - manageSpp = true; - KillSPP(version); - } - - if (string.IsNullOrEmpty(encrFilePath) || !File.Exists(encrFilePath)) - { - throw new FileNotFoundException("Store does not exist at expected path '" + encrFilePath + "'."); - } - - try - { - using (FileStream fs = File.Open(encrFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - byte[] encrData = fs.ReadAllBytes(); - File.WriteAllBytes(filePath, PhysStoreCrypto.DecryptPhysicalStore(encrData, production, version)); - } - Logger.WriteLine("Store dumped successfully to '" + filePath + "'."); - } - finally - { - if (manageSpp) - { - RestartSPP(version); - } - } - } - - public static void LoadStore(PSVersion version, bool production, string filePath) - { - if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) - { - throw new FileNotFoundException("Store file '" + filePath + "' does not exist."); - } - - KillSPP(version); - - using (IPhysicalStore store = GetStore(version, production)) - { - store.WriteRaw(File.ReadAllBytes(filePath)); - } - - RestartSPP(version); - - Logger.WriteLine("Loaded store file successfully."); - } - } -} - - -// LibTSforge/SPP/SPSys.cs -namespace LibTSforge.SPP -{ - using Microsoft.Win32.SafeHandles; - using System; - using System.Runtime.InteropServices; - - public class SPSys - { - [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] - private static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile); - private static SafeFileHandle CreateFileSafe(string device) - { - return new SafeFileHandle(CreateFile(device, 0xC0000000, 0, IntPtr.Zero, 3, 0, IntPtr.Zero), true); - } - - [return: MarshalAs(UnmanagedType.Bool)] - [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] - private static extern bool DeviceIoControl([In] SafeFileHandle hDevice, [In] uint dwIoControlCode, [In] IntPtr lpInBuffer, [In] int nInBufferSize, [Out] IntPtr lpOutBuffer, [In] int nOutBufferSize, out int lpBytesReturned, [In] IntPtr lpOverlapped); - - public static bool IsSpSysRunning() - { - SafeFileHandle file = CreateFileSafe(@"\\.\SpDevice"); - IntPtr buffer = Marshal.AllocHGlobal(1); - int bytesReturned; - DeviceIoControl(file, 0x80006008, IntPtr.Zero, 0, buffer, 1, out bytesReturned, IntPtr.Zero); - bool running = Marshal.ReadByte(buffer) != 0; - Marshal.FreeHGlobal(buffer); - file.Close(); - return running; - } - - public static int ControlSpSys(bool start) - { - SafeFileHandle file = CreateFileSafe(@"\\.\SpDevice"); - IntPtr buffer = Marshal.AllocHGlobal(4); - int bytesReturned; - DeviceIoControl(file, start ? 0x8000a000 : 0x8000a004, IntPtr.Zero, 0, buffer, 4, out bytesReturned, IntPtr.Zero); - int result = Marshal.ReadInt32(buffer); - Marshal.FreeHGlobal(buffer); - file.Close(); - return result; - } - } -} - - -// LibTSforge/Crypto/CryptoUtils.cs +// Crypto/CryptoUtils.cs namespace LibTSforge.Crypto { using System; @@ -5656,21 +4324,10 @@ namespace LibTSforge.Crypto public static bool HMACVerify(byte[] key, byte[] data, byte[] signature) { + HMACSHA1 hmac = new HMACSHA1(key); return Enumerable.SequenceEqual(signature, HMACSign(key, data)); } - public static byte[] SaltSHASum(byte[] salt, byte[] data) - { - SHA1 sha1 = SHA1.Create(); - byte[] sha_data = salt.Concat(data).ToArray(); - return sha1.ComputeHash(sha_data); - } - - public static bool SaltSHAVerify(byte[] salt, byte[] data, byte[] checksum) - { - return Enumerable.SequenceEqual(checksum, SaltSHASum(salt, data)); - } - public static byte[] SHA256Hash(byte[] data) { using (SHA256 sha256 = SHA256.Create()) @@ -5682,7 +4339,7 @@ namespace LibTSforge.Crypto } -// LibTSforge/Crypto/Keys.cs +// Crypto/Keys.cs namespace LibTSforge.Crypto { public static class Keys @@ -5772,7 +4429,7 @@ namespace LibTSforge.Crypto } -// LibTSforge/Crypto/PhysStoreCrypto.cs +// Crypto/PhysStoreCrypto.cs namespace LibTSforge.Crypto { using System; @@ -5783,7 +4440,7 @@ namespace LibTSforge.Crypto public static class PhysStoreCrypto { - public static byte[] DecryptPhysicalStore(byte[] data, bool production, PSVersion version) + public static byte[] DecryptPhysicalStore(byte[] data, bool production) { byte[] rsaKey = production ? Keys.PRODUCTION : Keys.TEST; BinaryReader br = new BinaryReader(new MemoryStream(data)); @@ -5791,40 +4448,29 @@ namespace LibTSforge.Crypto byte[] aesKeySig = br.ReadBytes(0x80); byte[] encAesKey = br.ReadBytes(0x80); - if (!CryptoUtils.RSAVerifySignature(rsaKey, encAesKey, aesKeySig)) + if (CryptoUtils.RSAVerifySignature(rsaKey, encAesKey, aesKeySig)) { - throw new Exception("Failed to decrypt physical store."); - } + byte[] aesKey = CryptoUtils.RSADecrypt(rsaKey, encAesKey); + byte[] decData = CryptoUtils.AESDecrypt(br.ReadBytes((int)br.BaseStream.Length - 0x110), aesKey); + byte[] hmacKey = decData.Take(0x10).ToArray(); + byte[] hmacSig = decData.Skip(0x10).Take(0x14).ToArray(); + byte[] psData = decData.Skip(0x28).ToArray(); - byte[] aesKey = CryptoUtils.RSADecrypt(rsaKey, encAesKey); - byte[] decData = CryptoUtils.AESDecrypt(br.ReadBytes((int)br.BaseStream.Length - 0x110), aesKey); - byte[] hmacKey = decData.Take(0x10).ToArray(); // SHA-1 salt on Vista - byte[] hmacSig = decData.Skip(0x10).Take(0x14).ToArray(); // SHA-1 hash on Vista - byte[] psData = decData.Skip(0x28).ToArray(); - - if (version != PSVersion.Vista) - { if (!CryptoUtils.HMACVerify(hmacKey, psData, hmacSig)) { - throw new InvalidDataException("Failed to verify HMAC. Physical store is corrupt."); - } - } - else - { - if (!CryptoUtils.SaltSHAVerify(hmacKey, psData, hmacSig)) - { - throw new InvalidDataException("Failed to verify checksum. Physical store is corrupt."); + Logger.WriteLine("Warning: Failed to verify HMAC. Physical store is either corrupt or in Vista format."); } + + return psData; } - return psData; + throw new Exception("Failed to decrypt physical store."); } public static byte[] EncryptPhysicalStore(byte[] data, bool production, PSVersion version) { Dictionary versionTable = new Dictionary { - {PSVersion.Vista, 2}, {PSVersion.Win7, 5}, {PSVersion.Win8, 1}, {PSVersion.WinBlue, 2}, @@ -5838,9 +4484,9 @@ namespace LibTSforge.Crypto byte[] encAesKey = CryptoUtils.RSAEncrypt(rsaKey, aesKey); byte[] aesKeySig = CryptoUtils.RSASign(rsaKey, encAesKey); - byte[] hmacSig = version != PSVersion.Vista ? CryptoUtils.HMACSign(hmacKey, data) : CryptoUtils.SaltSHASum(hmacKey, data); + byte[] hmacSig = CryptoUtils.HMACSign(hmacKey, data); - byte[] decData = { }; + byte[] decData = new byte[] { }; decData = decData.Concat(hmacKey).Concat(hmacSig).Concat(BitConverter.GetBytes(0)).Concat(data).ToArray(); byte[] encData = CryptoUtils.AESEncrypt(decData, aesKey); @@ -5857,15 +4503,15 @@ namespace LibTSforge.Crypto } -// LibTSforge/Modifiers/GenPKeyInstall.cs +// Modifiers/GenPKeyInstall.cs namespace LibTSforge.Modifiers { using System; using System.IO; using Microsoft.Win32; - using PhysicalStore; - using SPP; - using TokenStore; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; + using LibTSforge.TokenStore; public static class GenPKeyInstall { @@ -5891,7 +4537,6 @@ namespace LibTSforge.Modifiers public static void InstallGenPKey(PSVersion version, bool production, Guid actId) { - if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008."); if (actId == Guid.Empty) throw new ArgumentException("Activation ID must be specified for generated product key install."); PKeyConfig pkc = new PKeyConfig(); @@ -5918,7 +4563,7 @@ namespace LibTSforge.Modifiers if (pkey.Algorithm == PKeyAlgorithm.PKEY2009) { uint status = SLApi.InstallProductKey(pkey); - Logger.WriteLine(string.Format("Installing generated product key {0} status {1:X}", pkey, status)); + Logger.WriteLine(string.Format("Installing generated product key {0} status {1:X}", pkey.ToString(), status)); if ((int)status < 0) { @@ -5933,57 +4578,57 @@ namespace LibTSforge.Modifiers if (pkey.Channel == "Volume:GVLK" && version == PSVersion.Win7) throw new NotSupportedException("Fake GVLK generation is not supported on Windows 7."); - VariableBag pkb = new VariableBag(version); - pkb.Blocks.AddRange(new[] + VariableBag pkb = new VariableBag(); + pkb.Blocks.AddRange(new CRCBlock[] { - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyBindingProductKey", ValueAsStr = pkey.ToString() }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyBindingMPC", ValueAsStr = pkey.GetMPC() }, - new CRCBlockModern { + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = "SppPkeyBindingPid2", ValueAsStr = pkey.GetPid2() }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = "SppPkeyBindingPid3", Value = pkey.GetPid3() }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = "SppPkeyBindingPid4", Value = pkey.GetPid4() }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyChannelId", ValueAsStr = pkey.Channel }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.STRING, KeyAsStr = "SppPkeyBindingEditionId", ValueAsStr = pkey.Edition }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = (version == PSVersion.Win7) ? "SppPkeyShortAuthenticator" : "SppPkeyPhoneActivationData", Value = pkey.GetPhoneData(version) }, - new CRCBlockModern + new CRCBlock { DataType = CRCBlockType.BINARY, KeyAsStr = "SppPkeyBindingMiscData", @@ -6001,11 +4646,11 @@ namespace LibTSforge.Modifiers SLApi.UninstallAllProductKeys(appId); } - SPPUtils.KillSPP(version); + Utils.KillSPP(); - using (IPhysicalStore ps = SPPUtils.GetStore(version, production)) + using (IPhysicalStore ps = Utils.GetStore(version, production)) { - using (ITokenStore tks = SPPUtils.GetTokenStore(version)) + using (ITokenStore tks = Utils.GetTokenStore(version)) { Logger.WriteLine("Writing to physical store and token store..."); @@ -6029,7 +4674,7 @@ namespace LibTSforge.Modifiers uriMap.Data[pkeyId] = pkey.GetAlgoUri(); tks.SetEntry(uriMapName, "xml", uriMap.Serialize()); - string skuMetaName = actId + metSuffix; + string skuMetaName = actId.ToString() + metSuffix; TokenMeta skuMeta = tks.GetMetaEntry(skuMetaName); foreach (string k in skuMeta.Data.Keys) @@ -6056,7 +4701,7 @@ namespace LibTSforge.Modifiers Data = pkb.Serialize() }); - string cachePath = SPPUtils.GetTokensPath(version).Replace("tokens.dat", @"cache\cache.dat"); + string cachePath = Utils.GetTokensPath(version).Replace("tokens.dat", @"cache\cache.dat"); if (File.Exists(cachePath)) File.Delete(cachePath); } } @@ -6068,22 +4713,22 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/GracePeriodReset.cs +// Modifiers/GracePeriodReset.cs namespace LibTSforge.Modifiers { + using System; using System.Collections.Generic; using System.Linq; - using PhysicalStore; - using SPP; + using LibTSforge.PhysicalStore; public static class GracePeriodReset { public static void Reset(PSVersion version, bool production) { - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { string value = "msft:sl/timer"; List blocks = store.FindBlocks(value).ToList(); @@ -6094,31 +4739,26 @@ namespace LibTSforge.Modifiers } } - SPPUtils.RestartSPP(version); Logger.WriteLine("Successfully reset all grace and evaluation period timers."); } } } -// LibTSforge/Modifiers/KeyChangeLockDelete.cs +// Modifiers/KeyChangeLockDelete.cs namespace LibTSforge.Modifiers { using System.Collections.Generic; using System.Linq; - using PhysicalStore; - using SPP; - using System; - + using LibTSforge.PhysicalStore; + using LibTSforge; public static class KeyChangeLockDelete { public static void Delete(PSVersion version, bool production) { - if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008."); - - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { List values = new List { @@ -6141,17 +4781,17 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/KMSHostCharge.cs +// Modifiers/KMSHostCharge.cs namespace LibTSforge.Modifiers { using System; using System.IO; - using PhysicalStore; - using SPP; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; public static class KMSHostCharge { - public static void Charge(PSVersion version, bool production, Guid actId) + public static void Charge(PSVersion version, Guid actId, bool production) { if (actId == Guid.Empty) { @@ -6175,113 +4815,76 @@ namespace LibTSforge.Modifiers string key = string.Format("SPPSVC\\{0}", appId); long ldapTimestamp = DateTime.Now.ToFileTime(); - byte[] cmidGuids = { }; - byte[] reqCounts = { }; - byte[] kmsChargeData = { }; - BinaryWriter writer = new BinaryWriter(new MemoryStream()); - if (version == PSVersion.Vista) + for (int i = 0; i < currClients; i++) { - writer.Write(new byte[44]); - writer.Seek(0, SeekOrigin.Begin); - - writer.Write(totalClients); - writer.Write(43200); - writer.Write(32); - - writer.Seek(20, SeekOrigin.Begin); - writer.Write((byte)currClients); - - writer.Seek(32, SeekOrigin.Begin); - writer.Write((byte)currClients); - - writer.Seek(0, SeekOrigin.End); - - for (int i = 0; i < currClients; i++) - { - writer.Write(Guid.NewGuid().ToByteArray()); - writer.Write(ldapTimestamp - (10 * (i + 1))); - } - - kmsChargeData = writer.GetBytes(); - } - else - { - for (int i = 0; i < currClients; i++) - { - writer.Write(ldapTimestamp - (10 * (i + 1))); - writer.Write(Guid.NewGuid().ToByteArray()); - } - - cmidGuids = writer.GetBytes(); - - writer = new BinaryWriter(new MemoryStream()); - - writer.Write(new byte[40]); - - writer.Seek(4, SeekOrigin.Begin); - writer.Write((byte)currClients); - - writer.Seek(24, SeekOrigin.Begin); - writer.Write((byte)currClients); - - reqCounts = writer.GetBytes(); + writer.Write(ldapTimestamp - (10 * (i + 1))); + writer.Write(Guid.NewGuid().ToByteArray()); } - SPPUtils.KillSPP(version); + byte[] cmidGuids = writer.GetBytes(); + + writer = new BinaryWriter(new MemoryStream()); + + writer.Write(new byte[40]); + + writer.Seek(4, SeekOrigin.Begin); + writer.Write((byte)currClients); + + writer.Seek(24, SeekOrigin.Begin); + writer.Write((byte)currClients); + byte[] reqCounts = writer.GetBytes(); + + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { - if (version != PSVersion.Vista) + VariableBag kmsCountData = new VariableBag(); + kmsCountData.Blocks.AddRange(new CRCBlock[] { - VariableBag kmsCountData = new VariableBag(version); - kmsCountData.Blocks.AddRange(new[] + new CRCBlock { - new CRCBlockModern - { - DataType = CRCBlockType.BINARY, - KeyAsStr = "SppBindingLicenseData", - Value = hwidBlock - }, - new CRCBlockModern - { - DataType = CRCBlockType.UINT, - Key = new byte[] { }, - ValueAsInt = (uint)totalClients - }, - new CRCBlockModern - { - DataType = CRCBlockType.UINT, - Key = new byte[] { }, - ValueAsInt = 1051200000 - }, - new CRCBlockModern - { - DataType = CRCBlockType.UINT, - Key = new byte[] { }, - ValueAsInt = (uint)currClients - }, - new CRCBlockModern - { - DataType = CRCBlockType.BINARY, - Key = new byte[] { }, - Value = cmidGuids - }, - new CRCBlockModern - { - DataType = CRCBlockType.BINARY, - Key = new byte[] { }, - Value = reqCounts - } - }); + DataType = CRCBlockType.BINARY, + KeyAsStr = "SppBindingLicenseData", + Value = hwidBlock + }, + new CRCBlock + { + DataType = CRCBlockType.UINT, + Key = new byte[] { }, + ValueAsInt = (uint)totalClients + }, + new CRCBlock + { + DataType = CRCBlockType.UINT, + Key = new byte[] { }, + ValueAsInt = 1051200000 + }, + new CRCBlock + { + DataType = CRCBlockType.UINT, + Key = new byte[] { }, + ValueAsInt = (uint)currClients + }, + new CRCBlock + { + DataType = CRCBlockType.BINARY, + Key = new byte[] { }, + Value = cmidGuids + }, + new CRCBlock + { + DataType = CRCBlockType.BINARY, + Key = new byte[] { }, + Value = reqCounts + } + }); - kmsChargeData = kmsCountData.Serialize(); - } - - string countVal = version == PSVersion.Vista ? "C8F6FFF1-79CE-404C-B150-F97991273DF1" : string.Format("msft:spp/kms/host/2.0/store/counters/{0}", appId); + byte[] kmsChargeData = kmsCountData.Serialize(); + string countVal = string.Format("msft:spp/kms/host/2.0/store/counters/{0}", appId); store.DeleteBlock(key, countVal); store.AddBlock(new PSBlock @@ -6295,38 +4898,32 @@ namespace LibTSforge.Modifiers Logger.WriteLine(string.Format("Set charge count to {0} successfully.", currClients)); } - - SPPUtils.RestartSPP(version); } } } -// LibTSforge/Modifiers/RearmReset.cs +// Modifiers/RearmReset.cs namespace LibTSforge.Modifiers { + using System; using System.Collections.Generic; using System.Linq; - using PhysicalStore; - using SPP; + using LibTSforge.PhysicalStore; public static class RearmReset { public static void Reset(PSVersion version, bool production) { - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { List blocks; - if (version == PSVersion.Vista) - { - blocks = store.FindBlocks("740D70D8-6448-4b2f-9063-4A7A463600C5").ToList(); - } - else if (version == PSVersion.Win7) + if (version == PSVersion.Win7) { blocks = store.FindBlocks(0xA0000).ToList(); } @@ -6337,11 +4934,7 @@ namespace LibTSforge.Modifiers foreach (PSBlock block in blocks) { - if (version == PSVersion.Vista) - { - store.DeleteBlock(block.KeyAsStr, block.ValueAsStr); - } - else if (version == PSVersion.Win7) + if (version == PSVersion.Win7) { store.SetBlock(block.KeyAsStr, block.ValueAsInt, new byte[8]); } @@ -6358,110 +4951,38 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/SetIIDParams.cs +// Modifiers/TamperedFlagsDelete.cs namespace LibTSforge.Modifiers { - using PhysicalStore; - using SPP; - using System.IO; using System; - - public static class SetIIDParams - { - public static void SetParams(PSVersion version, bool production, Guid actId, PKeyAlgorithm algorithm, int group, int serial, ulong security) - { - if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008."); - - Guid appId; - - if (actId == Guid.Empty) - { - appId = SLApi.WINDOWS_APP_ID; - actId = SLApi.GetDefaultActivationID(appId, true); - - if (actId == Guid.Empty) - { - throw new Exception("No applicable activation IDs found."); - } - } - else - { - appId = SLApi.GetAppId(actId); - } - - Guid pkeyId = SLApi.GetInstalledPkeyID(actId); - - SPPUtils.KillSPP(version); - - Logger.WriteLine("Writing TrustedStore data..."); - - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) - { - string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId); - PSBlock keyBlock = store.GetBlock(key, pkeyId.ToString()); - - if (keyBlock == null) - { - throw new InvalidDataException("Failed to get product key data for activation ID " + actId + "."); - } - - VariableBag pkb = new VariableBag(keyBlock.Data, version); - - ProductKey pkey = new ProductKey - { - Group = group, - Serial = serial, - Security = security, - Algorithm = algorithm, - Upgrade = false - }; - - string blockName = version == PSVersion.Win7 ? "SppPkeyShortAuthenticator" : "SppPkeyPhoneActivationData"; - pkb.SetBlock(blockName, pkey.GetPhoneData(version)); - store.SetBlock(key, pkeyId.ToString(), pkb.Serialize()); - } - - Logger.WriteLine("Successfully set IID parameters."); - } - } -} - - -// LibTSforge/Modifiers/TamperedFlagsDelete.cs -namespace LibTSforge.Modifiers -{ using System.Linq; - using PhysicalStore; - using SPP; + using LibTSforge.PhysicalStore; public static class TamperedFlagsDelete { public static void DeleteTamperFlags(PSVersion version, bool production) { - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { - if (version == PSVersion.Vista) + if (version != PSVersion.Win7) { - DeleteFlag(store, "6BE8425B-E3CF-4e86-A6AF-5863E3DCB606"); - } - else if (version == PSVersion.Win7) - { - SetFlag(store, 0xA0001); + string recreatedFlag = "__##USERSEP-RESERVED##__$$RECREATED-FLAG$$"; + string recoveredFlag = "__##USERSEP-RESERVED##__$$RECOVERED-FLAG$$"; + + DeleteFlag(store, recreatedFlag); + DeleteFlag(store, recoveredFlag); } else { - DeleteFlag(store, "__##USERSEP-RESERVED##__$$RECREATED-FLAG$$"); - DeleteFlag(store, "__##USERSEP-RESERVED##__$$RECOVERED-FLAG$$"); + SetFlag(store, 0xA0001); } Logger.WriteLine("Successfully cleared the tamper state."); } - - SPPUtils.RestartSPP(version); } private static void DeleteFlag(IPhysicalStore store, string flag) @@ -6477,19 +4998,17 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Modifiers/UniqueIdDelete.cs +// Modifiers/UniqueIdDelete.cs namespace LibTSforge.Modifiers { using System; - using PhysicalStore; - using SPP; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; public static class UniqueIdDelete { public static void DeleteUniqueId(PSVersion version, bool production, Guid actId) { - if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008."); - Guid appId; if (actId == Guid.Empty) @@ -6507,13 +5026,14 @@ namespace LibTSforge.Modifiers appId = SLApi.GetAppId(actId); } + string instId = SLApi.GetInstallationID(actId); Guid pkeyId = SLApi.GetInstalledPkeyID(actId); - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId); PSBlock keyBlock = store.GetBlock(key, pkeyId.ToString()); @@ -6523,7 +5043,7 @@ namespace LibTSforge.Modifiers throw new Exception("No product key found."); } - VariableBag pkb = new VariableBag(keyBlock.Data, version); + VariableBag pkb = new VariableBag(keyBlock.Data); pkb.DeleteBlock("SppPkeyUniqueIdToken"); @@ -6536,230 +5056,18 @@ namespace LibTSforge.Modifiers } -// LibTSforge/Activators/KMS4K.cs +// Activators/ZeroCID.cs namespace LibTSforge.Activators { using System; using System.IO; - using PhysicalStore; - using SPP; - - public class KMS4k - { - public static void Activate(PSVersion version, bool production, Guid actId) - { - Guid appId; - if (actId == Guid.Empty) - { - appId = SLApi.WINDOWS_APP_ID; - actId = SLApi.GetDefaultActivationID(appId, true); - - if (actId == Guid.Empty) - { - throw new NotSupportedException("No applicable activation IDs found."); - } - } - else - { - appId = SLApi.GetAppId(actId); - } - - if (SLApi.GetPKeyChannel(SLApi.GetInstalledPkeyID(actId)) != "Volume:GVLK") - { - throw new NotSupportedException("Non-Volume:GVLK product key installed."); - } - - SPPUtils.KillSPP(version); - - Logger.WriteLine("Writing TrustedStore data..."); - - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) - { - string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId); - - ulong unknown = 0; - ulong time1; - ulong time2 = (ulong)DateTime.UtcNow.ToFileTime(); - ulong expiry = Constants.TimerMax; - - if (version == PSVersion.Vista || version == PSVersion.Win7) - { - 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 - }, - new CRCBlockModern - { - DataType = CRCBlockType.STRING, - Key = new byte[] { }, - ValueAsStr = "msft:rm/algorithm/hwid/4.0" - }, - new CRCBlockModern - { - DataType = CRCBlockType.BINARY, - KeyAsStr = "SppBindingLicenseData", - Value = hwidBlock - } - }); - - 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[] kmsBindingData = kmsBinding.Serialize(); - - Timer kmsTimer = new Timer - { - Unknown = unknown, - Time1 = time1, - Time2 = time2, - Expiry = expiry - }; - - 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.AddBlocks(new[] - { - new PSBlock - { - Type = BlockType.NAMED, - Flags = (version == PSVersion.WinModern) ? (uint)0x400 : 0, - KeyAsStr = key, - ValueAsStr = storeVal, - Data = kmsBindingData - }, - new PSBlock - { - Type = BlockType.TIMER, - Flags = (version == PSVersion.Win7) ? (uint)0 : 0x4, - KeyAsStr = key, - ValueAsStr = timerVal, - Data = kmsTimer.CastToArray() - } - }); - } - } - - SPPUtils.RestartSPP(version); - SLApi.FireStateChangedEvent(appId); - Logger.WriteLine("Activated using KMS4k successfully."); - } - } -} - - -// LibTSforge/Activators/ZeroCID.cs -namespace LibTSforge.Activators -{ - using System; - using System.IO; - using System.Linq; - using Crypto; - using PhysicalStore; - using SPP; + using LibTSforge.Crypto; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; public static class ZeroCID { - private static void Deposit(Guid actId, string instId) + public static void Deposit(Guid actId, string instId) { uint status = SLApi.DepositConfirmationID(actId, instId, Constants.ZeroCID); Logger.WriteLine(string.Format("Depositing fake CID status {0:X}", status)); @@ -6797,16 +5105,16 @@ namespace LibTSforge.Activators string instId = SLApi.GetInstallationID(actId); Guid pkeyId = SLApi.GetInstalledPkeyID(actId); - if (version == PSVersion.Vista || version == PSVersion.Win7) + if (version == PSVersion.Win7) { Deposit(actId, instId); } - SPPUtils.KillSPP(version); + Utils.KillSPP(); Logger.WriteLine("Writing TrustedStore data..."); - using (IPhysicalStore store = SPPUtils.GetStore(version, production)) + using (IPhysicalStore store = Utils.GetStore(version, production)) { byte[] hwidBlock = Constants.UniversalHWIDBlock; @@ -6816,11 +5124,7 @@ namespace LibTSforge.Activators byte[] iidHash; - if (version == PSVersion.Vista) - { - iidHash = CryptoUtils.SHA256Hash(Utils.EncodeString(instId)).Take(0x10).ToArray(); - } - else if (version == PSVersion.Win7) + if (version == PSVersion.Win7) { iidHash = CryptoUtils.SHA256Hash(Utils.EncodeString(instId)); } @@ -6837,39 +5141,11 @@ namespace LibTSforge.Activators throw new InvalidDataException("Failed to get product key data for activation ID " + actId + "."); } - VariableBag pkb = new VariableBag(keyBlock.Data, version); + VariableBag pkb = new VariableBag(keyBlock.Data); byte[] pkeyData; - if (version == PSVersion.Vista) - { - pkeyData = pkb.GetBlock("PKeyBasicInfo").Value; - string uniqueId = Utils.DecodeString(pkeyData.Skip(0x120).Take(0x80).ToArray()); - string extPid = Utils.DecodeString(pkeyData.Skip(0x1A0).Take(0x80).ToArray()); - - uint group; - uint.TryParse(extPid.Split('-')[1], out group); - - if (group == 0) - { - throw new FormatException("Extended PID has invalid format."); - } - - ulong shortauth; - - try - { - shortauth = BitConverter.ToUInt64(Convert.FromBase64String(uniqueId.Split('&')[1]), 0); - } - catch - { - throw new FormatException("Key Unique ID has invalid format."); - } - - shortauth |= (ulong)group << 41; - pkeyData = BitConverter.GetBytes(shortauth); - } - else if (version == PSVersion.Win7) + if (version == PSVersion.Win7) { pkeyData = pkb.GetBlock("SppPkeyShortAuthenticator").Value; } @@ -6882,34 +5158,26 @@ namespace LibTSforge.Activators store.SetBlock(key, pkeyId.ToString(), pkb.Serialize()); BinaryWriter writer = new BinaryWriter(new MemoryStream()); - writer.Write(iidHash.Length); + writer.Write(0x20); writer.Write(iidHash); writer.Write(hwidBlock.Length); writer.Write(hwidBlock); byte[] tsHwidData = writer.GetBytes(); writer = new BinaryWriter(new MemoryStream()); - writer.Write(iidHash.Length); + writer.Write(0x20); writer.Write(iidHash); writer.Write(pkeyData.Length); writer.Write(pkeyData); byte[] tsPkeyInfoData = writer.GetBytes(); - string phoneVersion = version == PSVersion.Vista ? "6.0" : "7.0"; - Guid indexSlid = version == PSVersion.Vista ? actId : pkeyId; - string hwidBlockName = string.Format("msft:Windows/{0}/Phone/Cached/HwidBlock/{1}", phoneVersion, indexSlid); - string pkeyInfoName = string.Format("msft:Windows/{0}/Phone/Cached/PKeyInfo/{1}", phoneVersion, indexSlid); - - store.DeleteBlock(key, hwidBlockName); - store.DeleteBlock(key, pkeyInfoName); - - store.AddBlocks(new[] { + store.AddBlocks(new PSBlock[] { new PSBlock { Type = BlockType.NAMED, Flags = 0, KeyAsStr = key, - ValueAsStr = hwidBlockName, + ValueAsStr = "msft:Windows/7.0/Phone/Cached/HwidBlock/" + pkeyId, Data = tsHwidData }, new PSBlock @@ -6917,18 +5185,18 @@ namespace LibTSforge.Activators Type = BlockType.NAMED, Flags = 0, KeyAsStr = key, - ValueAsStr = pkeyInfoName, + ValueAsStr = "msft:Windows/7.0/Phone/Cached/PKeyInfo/" + pkeyId, Data = tsPkeyInfoData } }); } - if (version != PSVersion.Vista && version != PSVersion.Win7) + if (version != PSVersion.Win7) { Deposit(actId, instId); } - SPPUtils.RestartSPP(version); + SLApi.RefreshLicenseStatus(); SLApi.FireStateChangedEvent(appId); Logger.WriteLine("Activated using ZeroCID successfully."); } @@ -6936,7 +5204,7 @@ namespace LibTSforge.Activators } -// LibTSforge/TokenStore/Common.cs +// TokenStore/Common.cs namespace LibTSforge.TokenStore { using System.Collections.Generic; @@ -6953,7 +5221,7 @@ namespace LibTSforge.TokenStore public class TokenMeta { public string Name; - public readonly Dictionary Data = new Dictionary(); + public Dictionary Data = new Dictionary(); public byte[] Serialize() { @@ -6976,7 +5244,7 @@ namespace LibTSforge.TokenStore return writer.GetBytes(); } - private void Deserialize(byte[] data) + public void Deserialize(byte[] data) { BinaryReader reader = new BinaryReader(new MemoryStream(data)); reader.ReadInt32(); @@ -7006,7 +5274,7 @@ namespace LibTSforge.TokenStore } -// LibTSforge/TokenStore/ITokenStore.cs +// TokenStore/ITokenStore.cs namespace LibTSforge.TokenStore { using System; @@ -7026,14 +5294,14 @@ namespace LibTSforge.TokenStore } -// LibTSforge/TokenStore/TokenStoreModern.cs +// TokenStore/TokenStoreModern.cs namespace LibTSforge.TokenStore { using System; using System.Collections.Generic; using System.IO; using System.Linq; - using Crypto; + using LibTSforge.Crypto; public class TokenStoreModern : ITokenStore { @@ -7047,29 +5315,29 @@ namespace LibTSforge.TokenStore private static readonly byte[] CONTS_FOOTER = Enumerable.Repeat((byte)0xAA, 0x20).ToArray(); private List Entries = new List(); - private readonly FileStream TokensFile; + public FileStream TokensFile; public void Deserialize() { if (TokensFile.Length < BLOCK_SIZE) return; TokensFile.Seek(0x24, SeekOrigin.Begin); - uint nextBlock; + uint nextBlock = 0; BinaryReader reader = new BinaryReader(TokensFile); do { - reader.ReadUInt32(); + uint curOffset = reader.ReadUInt32(); nextBlock = reader.ReadUInt32(); for (int i = 0; i < ENTRIES_PER_BLOCK; i++) { - uint curOffset = reader.ReadUInt32(); + curOffset = reader.ReadUInt32(); bool populated = reader.ReadUInt32() == 1; uint contentOffset = reader.ReadUInt32(); uint contentLength = reader.ReadUInt32(); uint allocLength = reader.ReadUInt32(); - byte[] contentData = { }; + byte[] contentData = new byte[] { }; if (populated) { @@ -7169,10 +5437,11 @@ namespace LibTSforge.TokenStore writer.WritePadding(BLOCK_PAD_SIZE); writer.BaseStream.Seek(curBlockOffset, SeekOrigin.Begin); + byte[] blockHash; byte[] blockData = new byte[BLOCK_SIZE - 0x20]; tokens.Read(blockData, 0, BLOCK_SIZE - 0x20); - byte[] blockHash = CryptoUtils.SHA256Hash(blockData); + blockHash = CryptoUtils.SHA256Hash(blockData); writer.BaseStream.Seek(curBlockOffset + BLOCK_SIZE - 0x20, SeekOrigin.Begin); writer.Write(blockHash); @@ -7303,6 +5572,11 @@ namespace LibTSforge.TokenStore Deserialize(); } + public TokenStoreModern() + { + + } + public void Dispose() { Serialize(); @@ -7312,7 +5586,7 @@ namespace LibTSforge.TokenStore } -// LibTSforge/PhysicalStore/Common.cs +// PhysicalStore/Common.cs namespace LibTSforge.PhysicalStore { using System.Runtime.InteropServices; @@ -7333,17 +5607,10 @@ namespace LibTSforge.PhysicalStore public ulong Time2; public ulong Expiry; } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct VistaTimer - { - public ulong Time; - public ulong Expiry; - } } -// LibTSforge/PhysicalStore/IPhysicalStore.cs +// PhysicalStore/IPhysicalStore.cs namespace LibTSforge.PhysicalStore { using System; @@ -7438,13 +5705,13 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/PhysicalStoreModern.cs +// PhysicalStore/PhysicalStoreModern.cs namespace LibTSforge.PhysicalStore { using System; using System.Collections.Generic; using System.IO; - using Crypto; + using LibTSforge.Crypto; public class ModernBlock { @@ -7534,7 +5801,7 @@ namespace LibTSforge.PhysicalStore public sealed class PhysicalStoreModern : IPhysicalStore { - private byte[] PreHeaderBytes = { }; + private byte[] PreHeaderBytes = new byte[] { }; private readonly Dictionary> Data = new Dictionary>(); private readonly FileStream TSFile; private readonly PSVersion Version; @@ -7722,50 +5989,46 @@ namespace LibTSforge.PhysicalStore public void DeleteBlock(string key, string value) { - if (!Data.ContainsKey(key)) + if (Data.ContainsKey(key)) { - return; - } + List blocks = Data[key]; - List blocks = Data[key]; - - foreach (ModernBlock block in blocks) - { - if (block.ValueAsStr == value) + foreach (ModernBlock block in blocks) { - blocks.Remove(block); - break; + if (block.ValueAsStr == value) + { + blocks.Remove(block); + break; + } } - } - Data[key] = blocks; + Data[key] = blocks; + } } public void DeleteBlock(string key, uint value) { - if (!Data.ContainsKey(key)) + if (Data.ContainsKey(key)) { - return; - } + List blocks = Data[key]; - List blocks = Data[key]; - - foreach (ModernBlock block in blocks) - { - if (block.ValueAsInt == value) + foreach (ModernBlock block in blocks) { - blocks.Remove(block); - break; + if (block.ValueAsInt == value) + { + blocks.Remove(block); + break; + } } - } - Data[key] = blocks; + Data[key] = blocks; + } } public PhysicalStoreModern(string tsPath, bool production, PSVersion version) { TSFile = File.Open(tsPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); - Deserialize(PhysStoreCrypto.DecryptPhysicalStore(TSFile.ReadAllBytes(), production, version)); + Deserialize(PhysStoreCrypto.DecryptPhysicalStore(TSFile.ReadAllBytes(), production)); TSFile.Seek(0, SeekOrigin.Begin); Version = version; Production = production; @@ -7785,7 +6048,7 @@ namespace LibTSforge.PhysicalStore public byte[] ReadRaw() { - byte[] data = PhysStoreCrypto.DecryptPhysicalStore(TSFile.ReadAllBytes(), Production, Version); + byte[] data = PhysStoreCrypto.DecryptPhysicalStore(TSFile.ReadAllBytes(), Production); TSFile.Seek(0, SeekOrigin.Begin); return data; } @@ -7856,372 +6119,13 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/PhysicalStoreVista.cs +// PhysicalStore/PhysicalStoreWin7.cs namespace LibTSforge.PhysicalStore { using System; using System.Collections.Generic; using System.IO; - using Crypto; - - public class VistaBlock - { - public BlockType Type; - public uint Flags; - public byte[] Value; - public string ValueAsStr - { - get - { - return Utils.DecodeString(Value); - } - set - { - Value = Utils.EncodeString(value); - } - } - public uint ValueAsInt - { - get - { - return BitConverter.ToUInt32(Value, 0); - } - set - { - Value = BitConverter.GetBytes(value); - } - } - public byte[] Data; - public string DataAsStr - { - get - { - return Utils.DecodeString(Data); - } - set - { - Data = Utils.EncodeString(value); - } - } - public uint DataAsInt - { - get - { - return BitConverter.ToUInt32(Data, 0); - } - set - { - Data = BitConverter.GetBytes(value); - } - } - - internal void Encode(BinaryWriter writer) - { - writer.Write((uint)Type); - writer.Write(Flags); - writer.Write(Value.Length); - writer.Write(Data.Length); - writer.Write(Value); - writer.Write(Data); - } - - internal static VistaBlock Decode(BinaryReader reader) - { - uint type = reader.ReadUInt32(); - uint flags = reader.ReadUInt32(); - - int valueLen = reader.ReadInt32(); - int dataLen = reader.ReadInt32(); - - byte[] value = reader.ReadBytes(valueLen); - byte[] data = reader.ReadBytes(dataLen); - return new VistaBlock - { - Type = (BlockType)type, - Flags = flags, - Value = value, - Data = data, - }; - } - } - - public sealed class PhysicalStoreVista : IPhysicalStore - { - private byte[] PreHeaderBytes = { }; - private readonly List Blocks = new List(); - private readonly FileStream TSPrimary; - private readonly FileStream TSSecondary; - private readonly bool Production; - - public byte[] Serialize() - { - BinaryWriter writer = new BinaryWriter(new MemoryStream()); - writer.Write(PreHeaderBytes); - - foreach (VistaBlock block in Blocks) - { - block.Encode(writer); - writer.Align(4); - } - - return writer.GetBytes(); - } - - public void Deserialize(byte[] data) - { - int len = data.Length; - - BinaryReader reader = new BinaryReader(new MemoryStream(data)); - PreHeaderBytes = reader.ReadBytes(8); - - while (reader.BaseStream.Position < len - 0x14) - { - Blocks.Add(VistaBlock.Decode(reader)); - reader.Align(4); - } - } - - public void AddBlock(PSBlock block) - { - Blocks.Add(new VistaBlock - { - Type = block.Type, - Flags = block.Flags, - Value = block.Value, - Data = block.Data - }); - } - - public void AddBlocks(IEnumerable blocks) - { - foreach (PSBlock block in blocks) - { - AddBlock(block); - } - } - - public PSBlock GetBlock(string key, string value) - { - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsStr == value) - { - return new PSBlock - { - Type = block.Type, - Flags = block.Flags, - Key = new byte[0], - Value = block.Value, - Data = block.Data - }; - } - } - - return null; - } - - public PSBlock GetBlock(string key, uint value) - { - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsInt == value) - { - return new PSBlock - { - Type = block.Type, - Flags = block.Flags, - Key = new byte[0], - Value = block.Value, - Data = block.Data - }; - } - } - - return null; - } - - public void SetBlock(string key, string value, byte[] data) - { - for (int i = 0; i < Blocks.Count; i++) - { - VistaBlock block = Blocks[i]; - - if (block.ValueAsStr == value) - { - block.Data = data; - Blocks[i] = block; - break; - } - } - } - - public void SetBlock(string key, uint value, byte[] data) - { - for (int i = 0; i < Blocks.Count; i++) - { - VistaBlock block = Blocks[i]; - - if (block.ValueAsInt == value) - { - block.Data = data; - Blocks[i] = block; - break; - } - } - } - - public void SetBlock(string key, string value, string data) - { - SetBlock(key, value, Utils.EncodeString(data)); - } - - public void SetBlock(string key, string value, uint data) - { - SetBlock(key, value, BitConverter.GetBytes(data)); - } - - public void SetBlock(string key, uint value, string data) - { - SetBlock(key, value, Utils.EncodeString(data)); - } - - public void SetBlock(string key, uint value, uint data) - { - SetBlock(key, value, BitConverter.GetBytes(data)); - } - - public void DeleteBlock(string key, string value) - { - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsStr == value) - { - Blocks.Remove(block); - return; - } - } - } - - public void DeleteBlock(string key, uint value) - { - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsInt == value) - { - Blocks.Remove(block); - return; - } - } - } - - public PhysicalStoreVista(string primaryPath, bool production) - { - TSPrimary = File.Open(primaryPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); - TSSecondary = File.Open(primaryPath.Replace("-0.", "-1."), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); - Production = production; - - Deserialize(PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), production, PSVersion.Vista)); - TSPrimary.Seek(0, SeekOrigin.Begin); - } - - public void Dispose() - { - if (TSPrimary.CanWrite && TSSecondary.CanWrite) - { - byte[] data = PhysStoreCrypto.EncryptPhysicalStore(Serialize(), Production, PSVersion.Vista); - - TSPrimary.SetLength(data.LongLength); - TSSecondary.SetLength(data.LongLength); - - TSPrimary.Seek(0, SeekOrigin.Begin); - TSSecondary.Seek(0, SeekOrigin.Begin); - - TSPrimary.WriteAllBytes(data); - TSSecondary.WriteAllBytes(data); - - TSPrimary.Close(); - TSSecondary.Close(); - } - } - - public byte[] ReadRaw() - { - byte[] data = PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), Production, PSVersion.Vista); - TSPrimary.Seek(0, SeekOrigin.Begin); - return data; - } - - public void WriteRaw(byte[] data) - { - byte[] encrData = PhysStoreCrypto.EncryptPhysicalStore(data, Production, PSVersion.Vista); - - TSPrimary.SetLength(encrData.LongLength); - TSSecondary.SetLength(encrData.LongLength); - - TSPrimary.Seek(0, SeekOrigin.Begin); - TSSecondary.Seek(0, SeekOrigin.Begin); - - TSPrimary.WriteAllBytes(encrData); - TSSecondary.WriteAllBytes(encrData); - - TSPrimary.Close(); - TSSecondary.Close(); - } - - public IEnumerable FindBlocks(string valueSearch) - { - List results = new List(); - - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsStr.Contains(valueSearch)) - { - results.Add(new PSBlock - { - Type = block.Type, - Flags = block.Flags, - Key = new byte[0], - Value = block.Value, - Data = block.Data - }); - } - } - - return results; - } - - public IEnumerable FindBlocks(uint valueSearch) - { - List results = new List(); - - foreach (VistaBlock block in Blocks) - { - if (block.ValueAsInt == valueSearch) - { - results.Add(new PSBlock - { - Type = block.Type, - Flags = block.Flags, - Key = new byte[0], - Value = block.Value, - Data = block.Data - }); - } - } - - return results; - } - } -} - - -// LibTSforge/PhysicalStore/PhysicalStoreWin7.cs -namespace LibTSforge.PhysicalStore -{ - using System; - using System.Collections.Generic; - using System.IO; - using Crypto; + using LibTSforge.Crypto; public class Win7Block { @@ -8323,7 +6227,7 @@ namespace LibTSforge.PhysicalStore public sealed class PhysicalStoreWin7 : IPhysicalStore { - private byte[] PreHeaderBytes = { }; + private byte[] PreHeaderBytes = new byte[] { }; private readonly List Blocks = new List(); private readonly FileStream TSPrimary; private readonly FileStream TSSecondary; @@ -8497,7 +6401,7 @@ namespace LibTSforge.PhysicalStore TSSecondary = File.Open(primaryPath.Replace("-0.", "-1."), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); Production = production; - Deserialize(PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), production, PSVersion.Win7)); + Deserialize(PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), production)); TSPrimary.Seek(0, SeekOrigin.Begin); } @@ -8523,7 +6427,7 @@ namespace LibTSforge.PhysicalStore public byte[] ReadRaw() { - byte[] data = PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), Production, PSVersion.Win7); + byte[] data = PhysStoreCrypto.DecryptPhysicalStore(TSPrimary.ReadAllBytes(), Production); TSPrimary.Seek(0, SeekOrigin.Begin); return data; } @@ -8592,7 +6496,7 @@ namespace LibTSforge.PhysicalStore } -// LibTSforge/PhysicalStore/VariableBag.cs +// PhysicalStore/VariableBag.cs namespace LibTSforge.PhysicalStore { using System; @@ -8606,7 +6510,7 @@ namespace LibTSforge.PhysicalStore BINARY = 1 << 2 } - public abstract class CRCBlock + public class CRCBlock { public CRCBlockType DataType; public byte[] Key; @@ -8645,57 +6549,7 @@ namespace LibTSforge.PhysicalStore } } - public abstract void Encode(BinaryWriter writer); - public abstract void Decode(BinaryReader reader); - public abstract uint CRC(); - } - - public class CRCBlockVista : CRCBlock - { - public override void Encode(BinaryWriter writer) - { - uint crc = CRC(); - writer.Write((uint)DataType); - writer.Write(0); - writer.Write(Key.Length); - writer.Write(Value.Length); - writer.Write(crc); - - writer.Write(Key); - - writer.Write(Value); - } - - public override void Decode(BinaryReader reader) - { - uint type = reader.ReadUInt32(); - reader.ReadUInt32(); - uint lenName = reader.ReadUInt32(); - uint lenVal = reader.ReadUInt32(); - uint crc = reader.ReadUInt32(); - - byte[] key = reader.ReadBytes((int)lenName); - byte[] value = reader.ReadBytes((int)lenVal); - - DataType = (CRCBlockType)type; - Key = key; - Value = value; - - if (CRC() != crc) - { - throw new InvalidDataException("Invalid CRC in variable bag."); - } - } - - public override uint CRC() - { - return Utils.CRC32(Value); - } - } - - public class CRCBlockModern : CRCBlock - { - public override void Encode(BinaryWriter writer) + public void Encode(BinaryWriter writer) { uint crc = CRC(); writer.Write(crc); @@ -8710,7 +6564,7 @@ namespace LibTSforge.PhysicalStore writer.Align(8); } - public override void Decode(BinaryReader reader) + public static CRCBlock Decode(BinaryReader reader) { uint crc = reader.ReadUInt32(); uint type = reader.ReadUInt32(); @@ -8723,17 +6577,22 @@ namespace LibTSforge.PhysicalStore byte[] value = reader.ReadBytes((int)lenVal); reader.Align(8); - DataType = (CRCBlockType)type; - Key = key; - Value = value; + CRCBlock block = new CRCBlock + { + DataType = (CRCBlockType)type, + Key = key, + Value = value, + }; - if (CRC() != crc) + if (block.CRC() != crc) { throw new InvalidDataException("Invalid CRC in variable bag."); } + + return block; } - public override uint CRC() + public uint CRC() { BinaryWriter wtemp = new BinaryWriter(new MemoryStream()); wtemp.Write(0); @@ -8749,9 +6608,8 @@ namespace LibTSforge.PhysicalStore public class VariableBag { public List Blocks = new List(); - private readonly PSVersion Version; - private void Deserialize(byte[] data) + public void Deserialize(byte[] data) { int len = data.Length; @@ -8759,19 +6617,7 @@ namespace LibTSforge.PhysicalStore while (reader.BaseStream.Position < len - 0x10) { - CRCBlock block; - - if (Version == PSVersion.Vista) - { - block = new CRCBlockVista(); - } - else - { - block = new CRCBlockModern(); - } - - block.Decode(reader); - Blocks.Add(block); + Blocks.Add(CRCBlock.Decode(reader)); } } @@ -8781,13 +6627,7 @@ namespace LibTSforge.PhysicalStore foreach (CRCBlock block in Blocks) { - if (Version == PSVersion.Vista) - { - ((CRCBlockVista)block).Encode(writer); - } else - { - ((CRCBlockModern)block).Encode(writer); - } + block.Encode(writer); } return writer.GetBytes(); @@ -8833,48 +6673,35 @@ namespace LibTSforge.PhysicalStore } } - public VariableBag(byte[] data, PSVersion version) + public VariableBag(byte[] data) { - Version = version; Deserialize(data); } - public VariableBag(PSVersion version) + public VariableBag() { - Version = version; + } } } '@ $ErrorActionPreference = 'Stop' -$binPath = "$env:_work\BIN\LibTSforge.dll" -$psMajorVer = (Get-Host).Version.Major -$build = [System.Environment]::OSVersion.Version.Build +$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" } -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" } - - $ctemp = "$env:SystemRoot\Temp\" - if (-Not (Test-Path -Path $ctemp)) { New-Item -Path $ctemp -ItemType Directory > $null } - $env:TMP = $ctemp - $env:TEMP = $ctemp - - $cp.GenerateInMemory = $true - Add-Type -Language $lang -TypeDefinition $src -CompilerParameters $cp -} +$ctemp = "$env:SystemRoot\Temp\" +if (-Not (Test-Path -Path $ctemp)) { New-Item -Path $ctemp -ItemType Directory > $null } +$env:TMP = $ctemp +$env:TEMP = $ctemp +$cp.GenerateInMemory = $true +Add-Type -Language $lang -TypeDefinition $src -CompilerParameters $cp if ($env:_debug -eq '0') { [LibTSforge.Logger]::HideOutput = $true } -[void][LibTSforge.Utils]::Wow64EnableWow64FsRedirection($false) $ver = [LibTSforge.Utils]::DetectVersion() -$prod = [LibTSforge.SPP.SPPUtils]::DetectCurrentKey() +$prod = [LibTSforge.Utils]::DetectCurrentKey() $tsactids = @($args) function Get-WmiInfo { @@ -8887,97 +6714,26 @@ function Get-WmiInfo { } } -function slGetSkuInfo($SkuId) { - $t = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0) - $t.DefinePInvokeMethod('SLOpen', 'slc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $t.DefinePInvokeMethod('SLClose', 'slc.dll', 22, 1, [IntPtr], @([IntPtr]), 1, 3).SetImplementationFlags(128) - $t.DefinePInvokeMethod('SLGetProductSkuInformation', 'slc.dll', 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $w = $t.CreateType() - $hSLC = 0 - try { - [void]$w::SLOpen([ref]$hSLC) - $c = 0; $b = 0 - $r = $w::SLGetProductSkuInformation($hSLC, [ref][Guid]$SkuId, "msft:sl/EUL/PHONE/PUBLIC", [ref]$null, [ref]$c, [ref]$b) - return ($r -eq 0) - } - finally { - [void]$w::SLClose($hSLC) - } -} - -if (-not $env:resetstuff) { +if ($env:resetstuff -eq $null) { 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))) { - $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.Modifiers.GenPKeyInstall]::InstallGenPKey($ver, $prod, $tsactid) + [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 + [LibTSforge.Modifiers.KMSHostCharge]::Charge($ver, $tsactid, $prod) + 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 { @@ -8993,13 +6749,13 @@ if (-not $env:resetstuff) { } } -if ($env:resetstuff) { +if ($env:resetstuff -eq '1') { try { - if (-not $env:_vis) { [LibTSforge.Modifiers.TamperedFlagsDelete]::DeleteTamperFlags($ver, $prod) } + [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) } + [LibTSforge.Modifiers.KeyChangeLockDelete]::Delete($ver, $prod) } catch { $errcode = 3 @@ -9244,7 +7000,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 @@ -9261,300 +7017,137 @@ Office-ActID -pkeypath "$env:pkeypath" -edition "$env:_License" -keytype "$env:k :: 1st column = Office version number :: 2nd column = Activation ID -:: 3rd column = Product ID from branding.xml -:: 4th column = Edition -:: 5th column = Other Edition IDs if they are part of the same primary product (For reference only) +:: 3rd column = Edition :: Separator = "_" -:msiofficedata +:ts_msiofficedata for %%# in ( -14_4d463c2c-0505-4626-8cdb-a4da82e2d8ed_0015_AccessR -14_745fb377-0a59-4ca9-b9a9-c359557a2c4e_001C_AccessRuntimeR -14_95ab3ec8-4106-4f9d-b632-03c019d1d23f_0015_AccessVL -14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_0016_ExcelR_[HSExcelR] -14_71dc86ff-f056-40d0-8ffb-9592705c9b76_0016_ExcelVL -14_7004b7f0-6407-4f45-8eac-966e5f868bde_00BA_GrooveR -14_fdad0dfa-417d-4b4f-93e4-64ea8867b7fd_00BA_GrooveVL -14_7b7d1f17-fdcb-4820-9789-9bec6e377821_0013_HomeBusinessR_[HomeBusinessDemoR] -14_19316117-30a8-4773-8fd9-7f7231f4e060_011E_HomeBusinessSubR -14_09e2d37e-474b-4121-8626-58ad9be5776f_002F_HomeStudentR_[HomeStudentDemoR] -14_ef1da464-01c8-43a6-91af-e4e5713744f9_0044_InfoPathR -14_85e22450-b741-430c-a172-a37962c938af_0044_InfoPathVL -14_14f5946a-debc-4716-babc-7e2c240fec08_000F_MondoR -14_533b656a-4425-480b-8e30-1a2358898350_000F_MondoVL -14_c1ceda8b-c578-4d5d-a4aa-23626be4e234_003D_ProfessionalR_[OEM-SingleImage]Exception -14_3f7aa693-9a7e-44fc-9309-bb3d8e604925_00A1_OneNoteR_[HSOneNoteR] -14_6860b31f-6a67-48b8-84b9-e312b3485c4b_00A1_OneNoteVL -14_fbf4ac36-31c8-4340-8666-79873129cf40_001A_OutlookR -14_a9aeabd8-63b8-4079-a28e-f531807fd6b8_001A_OutlookVL -14_acb51361-c0db-4895-9497-1831c41f31a6_0033_PersonalR_[PersonalDemoR,PersonalPrepaidR] -14_133c8359-4e93-4241-8118-30bb18737ea0_0018_PowerPointR_[HSPowerPointR] -14_38252940-718c-4aa6-81a4-135398e53851_0018_PowerPointVL -14_8b559c37-0117-413e-921b-b853aeb6e210_0014_ProfessionalR_[ProfessionalAcadR,ProfessionalDemoR] -14_725714d7-d58f-4d12-9fa8-35873c6f7215_003B_ProjectProR_[ProjectProMSDNR] -14_4d06f72e-fd50-4bc2-a24b-d448d7f17ef2_011F_ProjectProSubR -14_1cf57a59-c532-4e56-9a7d-ffa2fe94b474_003B_ProjectProVL -14_688f6589-2bd9-424e-a152-b13f36aa6de1_003A_ProjectStdR -14_11b39439-6b93-4642-9570-f2eb81be2238_003A_ProjectStdVL -14_71af7e84-93e6-4363-9b69-699e04e74071_0011_ProPlusR_[ProPlusAcadR,ProPlusMSDNR,Sub4R] -14_e98ef0c0-71c4-42ce-8305-287d8721e26c_011D_ProPlusSubR -14_fdf3ecb9-b56f-43b2-a9b8-1b48b6bae1a7_0011_ProPlusVL_[ProPlusAcadVL] -14_98677603-a668-4fa4-9980-3f1f05f78f69_0019_PublisherR -14_3d014759-b128-4466-9018-e80f6320d9d0_0019_PublisherVL -14_dbe3aee0-5183-4ff7-8142-66050173cb01_008B_SmallBusBasicsR_[SmallBusBasicsMSDNR] -14_8090771e-d41a-4482-929e-de87f1f47e46_008B_SmallBusBasicsVL -14_b78df69e-0966-40b1-ae85-30a5134dedd0_0017_SPDR -14_d3422cfb-8d8b-4ead-99f9-eab0ccd990d7_0012_StandardR -14_1f76e346-e0be-49bc-9954-70ec53a4fcfe_0012_StandardVL_[StandardAcadVL] -14_2745e581-565a-4670-ae90-6bf7c57ffe43_0066_StarterR -14_66cad568-c2dc-459d-93ec-2f3cb967ee34_0057_VisioSIR_Prem[Pro,Std]Exception -14_36756cb8-8e69-4d11-9522-68899507cd6a_0057_VisioSIVL_Prem[Pro,Std]Exception -14_db3bbc9c-ce52-41d1-a46f-1a1d68059119_001B_WordR_[HSWordR] -14_98d4050e-9c98-49bf-9be1-85e12eb3ab13_001B_WordVL :: Office 2013 -15_ab4d047b-97cf-4126-a69f-34df08e2f254_0015_AccessRetail -15_259de5be-492b-44b3-9d78-9645f848f7b0_001C_AccessRuntimeRetail -15_4374022d-56b8-48c1-9bb7-d8f2fc726343_0015_AccessVolume -15_1b1d9bd5-12ea-4063-964c-16e7e87d6e08_0016_ExcelRetail -15_ac1ae7fd-b949-4e04-a330-849bc40638cf_0016_ExcelVolume -15_cfaf5356-49e3-48a8-ab3c-e729ab791250_00BA_GrooveRetail -15_4825ac28-ce41-45a7-9e6e-1fed74057601_00BA_GrooveVolume -15_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_00E7_HomeBusinessPipcRetail -15_cd256150-a898-441f-aac0-9f8f33390e45_0013_HomeBusinessRetail -15_1fdfb4e4-f9c9-41c4-b055-c80daf00697d_00CE_HomeStudentARMRetail -15_ebef9f05-5273-404a-9253-c5e252f50555_00DA_HomeStudentPlusARMRetail -15_98685d21-78bd-4c62-bc4f-653344a63035_002F_HomeStudentRetail -15_44984381-406e-4a35-b1c3-e54f499556e2_0044_InfoPathRetail -15_9e016989-4007-42a6-8051-64eb97110cf2_0044_InfoPathVolume -15_9103f3ce-1084-447a-827e-d6097f68c895_00EA_LyncAcademicRetail -15_ff693bf4-0276-4ddb-bb42-74ef1a0c9f4d_012D_LyncEntryRetail -15_fada6658-bfc6-4c4e-825a-59a89822cda8_012C_LyncRetail -15_e1264e10-afaf-4439-a98b-256df8bb156f_012C_LyncVolume -15_3169c8df-f659-4f95-9cc6-3115e6596e83_000F_MondoRetail -15_f33485a0-310b-4b72-9a0e-b1d605510dbd_000F_MondoVolume -15_3391e125-f6e4-4b1e-899c-a25e6092d40d_00A1_OneNoteFreeRetail -15_8b524bcc-67ea-4876-a509-45e46f6347e8_00A1_OneNoteRetail -15_b067e965-7521-455b-b9f7-c740204578a2_00A1_OneNoteVolume -15_12004b48-e6c8-4ffa-ad5a-ac8d4467765a_001A_OutlookRetail -15_8d577c50-ae5e-47fd-a240-24986f73d503_001A_OutlookVolume -15_5aab8561-1686-43f7-9ff5-2c861da58d17_00E6_PersonalPipcRetail -15_17e9df2d-ed91-4382-904b-4fed6a12caf0_0033_PersonalRetail -15_31743b82-bfbc-44b6-aa12-85d42e644d5b_0018_PowerPointRetail -15_e40dcb44-1d5c-4085-8e8f-943f33c4f004_0018_PowerPointVolume -15_4e26cac1-e15a-4467-9069-cb47b67fe191_00E8_ProfessionalPipcRetail -15_44bc70e2-fb83-4b09-9082-e5557e0c2ede_0014_ProfessionalRetail -15_f2435de4-5fc0-4e5b-ac97-34f515ec5ee7_003B_ProjectProRetail -15_ed34dc89-1c27-4ecd-8b2f-63d0f4cedc32_003B_ProjectProVolume -15_5517e6a2-739b-4822-946f-7f0f1c5934b1_003A_ProjectStdRetail -15_2b9e4a37-6230-4b42-bee2-e25ce86c8c7a_003A_ProjectStdVolume -15_064383fa-1538-491c-859b-0ecab169a0ab_0011_ProPlusRetail -15_2b88c4f2-ea8f-43cd-805e-4d41346e18a7_0011_ProPlusVolume -15_c3a0814a-70a4-471f-af37-2313a6331111_0019_PublisherRetail -15_38ea49f6-ad1d-43f1-9888-99a35d7c9409_0019_PublisherVolume -15_ba3e3833-6a7e-445a-89d0-7802a9a68588_0017_SPDRetail -15_32255c0a-16b4-4ce2-b388-8a4267e219eb_0012_StandardRetail -15_a24cca51-3d54-4c41-8a76-4031f5338cb2_0012_StandardVolume -15_15d12ad4-622d-4257-976c-5eb3282fb93d_0051_VisioProRetail -15_3e4294dd-a765-49bc-8dbd-cf8b62a4bd3d_0051_VisioProVolume -15_dae597ce-5823-4c77-9580-7268b93a4b23_0053_VisioStdRetail -15_44a1f6ff-0876-4edb-9169-dbb43101ee89_0053_VisioStdVolume -15_191509f2-6977-456f-ab30-cf0492b1e93a_001B_WordRetail -15_9cedef15-be37-4ff0-a08a-13a045540641_001B_WordVolume +15_ab4d047b-97cf-4126-a69f-34df08e2f254_AccessRetail +15_259de5be-492b-44b3-9d78-9645f848f7b0_AccessRuntimeRetail +15_4374022d-56b8-48c1-9bb7-d8f2fc726343_AccessVolume +15_1b1d9bd5-12ea-4063-964c-16e7e87d6e08_ExcelRetail +15_ac1ae7fd-b949-4e04-a330-849bc40638cf_ExcelVolume +15_cfaf5356-49e3-48a8-ab3c-e729ab791250_GrooveRetail +15_4825ac28-ce41-45a7-9e6e-1fed74057601_GrooveVolume +15_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_HomeBusinessPipcRetail +15_a2b90e7a-a797-4713-af90-f0becf52a1dd_HomeBusinessRetail +15_1fdfb4e4-f9c9-41c4-b055-c80daf00697d_HomeStudentARMRetail +15_ebef9f05-5273-404a-9253-c5e252f50555_HomeStudentPlusARMRetail +15_f2de350d-3028-410a-bfae-283e00b44d0e_HomeStudentRetail +15_44984381-406e-4a35-b1c3-e54f499556e2_InfoPathRetail +15_9e016989-4007-42a6-8051-64eb97110cf2_InfoPathVolume +15_9103f3ce-1084-447a-827e-d6097f68c895_LyncAcademicRetail +15_ff693bf4-0276-4ddb-bb42-74ef1a0c9f4d_LyncEntryRetail +15_fada6658-bfc6-4c4e-825a-59a89822cda8_LyncRetail +15_e1264e10-afaf-4439-a98b-256df8bb156f_LyncVolume +15_69ec9152-153b-471a-bf35-77ec88683eae_MondoRetail +15_f33485a0-310b-4b72-9a0e-b1d605510dbd_MondoVolume +15_3391e125-f6e4-4b1e-899c-a25e6092d40d_OneNoteFreeRetail +15_8b524bcc-67ea-4876-a509-45e46f6347e8_OneNoteRetail +15_b067e965-7521-455b-b9f7-c740204578a2_OneNoteVolume +15_12004b48-e6c8-4ffa-ad5a-ac8d4467765a_OutlookRetail +15_8d577c50-ae5e-47fd-a240-24986f73d503_OutlookVolume +15_5aab8561-1686-43f7-9ff5-2c861da58d17_PersonalPipcRetail +15_17e9df2d-ed91-4382-904b-4fed6a12caf0_PersonalRetail +15_31743b82-bfbc-44b6-aa12-85d42e644d5b_PowerPointRetail +15_e40dcb44-1d5c-4085-8e8f-943f33c4f004_PowerPointVolume +15_064383fa-1538-491c-859b-0ecab169a0ab_ProPlusRetail +15_2b88c4f2-ea8f-43cd-805e-4d41346e18a7_ProPlusVolume +15_4e26cac1-e15a-4467-9069-cb47b67fe191_ProfessionalPipcRetail +15_44bc70e2-fb83-4b09-9082-e5557e0c2ede_ProfessionalRetail +15_2f72340c-b555-418d-8b46-355944fe66b8_ProjectProRetail +15_ed34dc89-1c27-4ecd-8b2f-63d0f4cedc32_ProjectProVolume +15_58d95b09-6af6-453d-a976-8ef0ae0316b1_ProjectStdRetail +15_2b9e4a37-6230-4b42-bee2-e25ce86c8c7a_ProjectStdVolume +15_c3a0814a-70a4-471f-af37-2313a6331111_PublisherRetail +15_38ea49f6-ad1d-43f1-9888-99a35d7c9409_PublisherVolume +15_ba3e3833-6a7e-445a-89d0-7802a9a68588_SPDRetail +15_32255c0a-16b4-4ce2-b388-8a4267e219eb_StandardRetail +15_a24cca51-3d54-4c41-8a76-4031f5338cb2_StandardVolume +15_a56a3b37-3a35-4bbb-a036-eee5f1898eee_VisioProRetail +15_3e4294dd-a765-49bc-8dbd-cf8b62a4bd3d_VisioProVolume +15_980f9e3e-f5a8-41c8-8596-61404addf677_VisioStdRetail +15_44a1f6ff-0876-4edb-9169-dbb43101ee89_VisioStdVolume +15_191509f2-6977-456f-ab30-cf0492b1e93a_WordRetail +15_9cedef15-be37-4ff0-a08a-13a045540641_WordVolume :: Office 365 - 15.0 version -15_befee371-a2f5-4648-85db-a2c55fdf324c_00E9_O365BusinessRetail -15_537ea5b5-7d50-4876-bd38-a53a77caca32_00D6_O365HomePremRetail -15_149dbce7-a48e-44db-8364-a53386cd4580_00D4_O365ProPlusRetail -15_bacd4614-5bef-4a5e-bafc-de4c788037a2_00D5_O365SmallBusPremRetail +15_742178ed-6b28-42dd-b3d7-b7c0ea78741b_O365BusinessRetail +15_a96f8dae-da54-4fad-bdc6-108da592707a_O365HomePremRetail +15_e3dacc06-3bc2-4e13-8e59-8e05f3232325_O365ProPlusRetail +15_0bc1dae4-6158-4a1c-a893-807665b934b2_O365SmallBusPremRetail :: Office 365 - 16.0 version -16_6337137e-7c07-4197-8986-bece6a76fc33_00E9_O365BusinessRetail -16_2f5c71b4-5b7a-4005-bb68-f9fac26f2ea3_00D6_O365EduCloudRetail -16_537ea5b5-7d50-4876-bd38-a53a77caca32_00D6_O365HomePremRetail -16_149dbce7-a48e-44db-8364-a53386cd4580_00D4_O365ProPlusRetail -16_bacd4614-5bef-4a5e-bafc-de4c788037a2_00D5_O365SmallBusPremRetail +16_742178ed-6b28-42dd-b3d7-b7c0ea78741b_O365BusinessRetail +16_2f5c71b4-5b7a-4005-bb68-f9fac26f2ea3_O365EduCloudRetail +16_a96f8dae-da54-4fad-bdc6-108da592707a_O365HomePremRetail +16_e3dacc06-3bc2-4e13-8e59-8e05f3232325_O365ProPlusRetail +16_0bc1dae4-6158-4a1c-a893-807665b934b2_O365SmallBusPremRetail :: Office 2016 -16_bfa358b0-98f1-4125-842e-585fa13032e6_0015_AccessRetail -16_9d9faf9e-d345-4b49-afce-68cb0a539c7c_001C_AccessRuntimeRetail -16_3b2fa33f-cd5a-43a5-bd95-f49f3f546b0b_0015_AccessVolume -16_424d52ff-7ad2-4bc7-8ac6-748d767b455d_0016_ExcelRetail -16_685062a7-6024-42e7-8c5f-6bb9e63e697f_0016_ExcelVolume -16_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_00E7_HomeBusinessPipcRetail -16_86834d00-7896-4a38-8fae-32f20b86fa2b_0013_HomeBusinessRetail -16_090896a0-ea98-48ac-b545-ba5da0eb0c9c_00CE_HomeStudentARMRetail -16_6bbe2077-01a4-4269-bf15-5bf4d8efc0b2_00DA_HomeStudentPlusARMRetail -16_c28acdb8-d8b3-4199-baa4-024d09e97c99_002F_HomeStudentRetail -16_e2127526-b60c-43e0-bed1-3c9dc3d5a468_002F_HomeStudentVNextRetail -16_b21367df-9545-4f02-9f24-240691da0e58_000F_MondoRetail -16_2cd0ea7e-749f-4288-a05e-567c573b2a6c_000F_MondoVolume -16_436366de-5579-4f24-96db-3893e4400030_00A3_OneNoteFreeRetail -16_83ac4dd9-1b93-40ed-aa55-ede25bb6af38_00A1_OneNoteRetail -16_23b672da-a456-4860-a8f3-e062a501d7e8_00A1_OneNoteVolume -16_5a670809-0983-4c2d-8aad-d3c2c5b7d5d1_001A_OutlookRetail -16_50059979-ac6f-4458-9e79-710bcb41721a_001A_OutlookVolume -16_5aab8561-1686-43f7-9ff5-2c861da58d17_00E6_PersonalPipcRetail -16_a9f645a1-0d6a-4978-926a-abcb363b72a6_0033_PersonalRetail -16_f32d1284-0792-49da-9ac6-deb2bc9c80b6_0018_PowerPointRetail -16_9b4060c9-a7f5-4a66-b732-faf248b7240f_0018_PowerPointVolume -16_4e26cac1-e15a-4467-9069-cb47b67fe191_00E8_ProfessionalPipcRetail -16_d64edc00-7453-4301-8428-197343fafb16_0014_ProfessionalRetail -16_0f42f316-00b1-48c5-ada4-2f52b5720ad0_003B_ProjectProRetail -16_82f502b5-b0b0-4349-bd2c-c560df85b248_003B_ProjectProVolume -16_16728639-a9ab-4994-b6d8-f81051e69833_003B_ProjectProXVolume -16_e9f0b3fc-962f-4944-ad06-05c10b6bcd5e_003A_ProjectStdRetail -16_82e6b314-2a62-4e51-9220-61358dd230e6_003A_ProjectStdVolume -16_431058f0-c059-44c5-b9e7-ed2dd46b6789_003A_ProjectStdXVolume -16_de52bd50-9564-4adc-8fcb-a345c17f84f9_0011_ProPlusRetail -16_c47456e3-265d-47b6-8ca0-c30abbd0ca36_0011_ProPlusVolume -16_6e0c1d99-c72e-4968-bcb7-ab79e03e201e_0019_PublisherRetail -16_fcc1757b-5d5f-486a-87cf-c4d6dedb6032_0019_PublisherVolume -16_971cd368-f2e1-49c1-aedd-330909ce18b6_012D_SkypeforBusinessEntryRetail -16_418d2b9f-b491-4d7f-84f1-49e27cc66597_012C_SkypeforBusinessRetail -16_03ca3b9a-0869-4749-8988-3cbc9d9f51bb_012C_SkypeforBusinessVolume -16_9103f3ce-1084-447a-827e-d6097f68c895_012C_SkypeServiceBypassRetail -16_4a31c291-3a12-4c64-b8ab-cd79212be45e_0012_StandardRetail -16_0ed94aac-2234-4309-ba29-74bdbb887083_0012_StandardVolume -16_2dfe2075-2d04-4e43-816a-eb60bbb77574_0051_VisioProRetail -16_295b2c03-4b1c-4221-b292-1411f468bd02_0051_VisioProVolume -16_0594dc12-8444-4912-936a-747ca742dbdb_0051_VisioProXVolume -16_c76dbcbc-d71b-4f45-b5b3-b7494cb4e23e_0053_VisioStdRetail -16_44151c2d-c398-471f-946f-7660542e3369_0053_VisioStdVolume -16_1d1c6879-39a3-47a5-9a6d-aceefa6a289d_0053_VisioStdXVolume -16_cacaa1bf-da53-4c3b-9700-11738ef1c2a5_001B_WordRetail -16_c3000759-551f-4f4a-bcac-a4b42cbf1de2_001B_WordVolume +16_bfa358b0-98f1-4125-842e-585fa13032e6_AccessRetail +16_9d9faf9e-d345-4b49-afce-68cb0a539c7c_AccessRuntimeRetail +16_3b2fa33f-cd5a-43a5-bd95-f49f3f546b0b_AccessVolume +16_424d52ff-7ad2-4bc7-8ac6-748d767b455d_ExcelRetail +16_685062a7-6024-42e7-8c5f-6bb9e63e697f_ExcelVolume +16_c02fb62e-1cd5-4e18-ba25-e0480467ffaa_HomeBusinessPipcRetail +16_86834d00-7896-4a38-8fae-32f20b86fa2b_HomeBusinessRetail +16_090896a0-ea98-48ac-b545-ba5da0eb0c9c_HomeStudentARMRetail +16_6bbe2077-01a4-4269-bf15-5bf4d8efc0b2_HomeStudentPlusARMRetail +16_c28acdb8-d8b3-4199-baa4-024d09e97c99_HomeStudentRetail +16_e2127526-b60c-43e0-bed1-3c9dc3d5a468_HomeStudentVNextRetail +16_69ec9152-153b-471a-bf35-77ec88683eae_MondoRetail +16_2cd0ea7e-749f-4288-a05e-567c573b2a6c_MondoVolume +16_436366de-5579-4f24-96db-3893e4400030_OneNoteFreeRetail +16_83ac4dd9-1b93-40ed-aa55-ede25bb6af38_OneNoteRetail +16_23b672da-a456-4860-a8f3-e062a501d7e8_OneNoteVolume +16_5a670809-0983-4c2d-8aad-d3c2c5b7d5d1_OutlookRetail +16_50059979-ac6f-4458-9e79-710bcb41721a_OutlookVolume +16_5aab8561-1686-43f7-9ff5-2c861da58d17_PersonalPipcRetail +16_a9f645a1-0d6a-4978-926a-abcb363b72a6_PersonalRetail +16_f32d1284-0792-49da-9ac6-deb2bc9c80b6_PowerPointRetail +16_9b4060c9-a7f5-4a66-b732-faf248b7240f_PowerPointVolume +16_de52bd50-9564-4adc-8fcb-a345c17f84f9_ProPlusRetail +16_c47456e3-265d-47b6-8ca0-c30abbd0ca36_ProPlusVolume +16_4e26cac1-e15a-4467-9069-cb47b67fe191_ProfessionalPipcRetail +16_d64edc00-7453-4301-8428-197343fafb16_ProfessionalRetail +16_2f72340c-b555-418d-8b46-355944fe66b8_ProjectProRetail +16_82f502b5-b0b0-4349-bd2c-c560df85b248_ProjectProVolume +16_16728639-a9ab-4994-b6d8-f81051e69833_ProjectProXVolume +16_58d95b09-6af6-453d-a976-8ef0ae0316b1_ProjectStdRetail +16_82e6b314-2a62-4e51-9220-61358dd230e6_ProjectStdVolume +16_431058f0-c059-44c5-b9e7-ed2dd46b6789_ProjectStdXVolume +16_6e0c1d99-c72e-4968-bcb7-ab79e03e201e_PublisherRetail +16_fcc1757b-5d5f-486a-87cf-c4d6dedb6032_PublisherVolume +16_9103f3ce-1084-447a-827e-d6097f68c895_SkypeServiceBypassRetail +16_971cd368-f2e1-49c1-aedd-330909ce18b6_SkypeforBusinessEntryRetail +16_418d2b9f-b491-4d7f-84f1-49e27cc66597_SkypeforBusinessRetail +16_03ca3b9a-0869-4749-8988-3cbc9d9f51bb_SkypeforBusinessVolume +16_4a31c291-3a12-4c64-b8ab-cd79212be45e_StandardRetail +16_0ed94aac-2234-4309-ba29-74bdbb887083_StandardVolume +16_a56a3b37-3a35-4bbb-a036-eee5f1898eee_VisioProRetail +16_295b2c03-4b1c-4221-b292-1411f468bd02_VisioProVolume +16_0594dc12-8444-4912-936a-747ca742dbdb_VisioProXVolume +16_980f9e3e-f5a8-41c8-8596-61404addf677_VisioStdRetail +16_44151c2d-c398-471f-946f-7660542e3369_VisioStdVolume +16_1d1c6879-39a3-47a5-9a6d-aceefa6a289d_VisioStdXVolume +16_cacaa1bf-da53-4c3b-9700-11738ef1c2a5_WordRetail +16_c3000759-551f-4f4a-bcac-a4b42cbf1de2_WordVolume ) do ( for /f "tokens=1-5 delims=_" %%A in ("%%#") do ( if "%oVer%"=="%%A" ( -reg query "%1\Registration\{%%B}" /v ProductCode %nul2% | find /i "-%%C-" %nul% && ( -reg query "%1\Common\InstalledPackages" %nul2% | find /i "-%%C-" %nul% && ( -if defined _oIds (set _oIds=!_oIds! %%D) else (set _oIds=%%D) -if /i 003D==%%C set SingleImage=1 +for /f "tokens=*" %%x in ('findstr /i /c:"%%B" "%_oBranding%"') do set "prodId=%%x" +set prodId=!prodId:"/>=! +set prodId=!prodId:~-4! +if "%oVer%"=="14" ( +REM Exception case for Visio because wrong primary product ID is mentioned in Branding.xml +echo %%C | find /i "Visio" %nul% && set prodId=0057 ) +reg query "%1\Registration\{%%B}" /v ProductCode %nul2% | find /i "-!prodId!-" %nul% && ( +reg query "%1\Common\InstalledPackages" %nul2% | find /i "-!prodId!-" %nul% && ( +if defined _oIds (set _oIds=!_oIds! %%C) else (set _oIds=%%C) ) ) - -) -) -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 -) ) ) diff --git a/MAS/Separate-Files-Version/Activators/_ReadMe.txt b/MAS/Separate-Files-Version/Activators/_ReadMe.txt index 9832bc8..2473884 100644 --- a/MAS/Separate-Files-Version/Activators/_ReadMe.txt +++ b/MAS/Separate-Files-Version/Activators/_ReadMe.txt @@ -5,9 +5,9 @@ Activation Type Supported Product Activation Period HWID - Windows 10-11 - Permanent Ohook - Office - Permanent TSforge - Windows / ESU / Office - Permanent +KMS38 - Windows 10-11-Server - Till the Year 2038 Online KMS - Windows / Office - 180 Days. Lifetime With Renewal Task -------------------------------------------------------------------------------------- -Check the below link for more details: -https://massgrave.dev/chart \ No newline at end of file +For more details, check https://massgrave.dev/activations_comparison \ No newline at end of file diff --git a/MAS/Separate-Files-Version/Change_Office_Edition.cmd b/MAS/Separate-Files-Version/Change_Office_Edition.cmd index 9220148..05d4410 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.0 @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 @@ -71,7 +69,7 @@ echo: echo Null service is not running, script may crash... echo: echo: -echo Check this webpage for help - %mas%fix_service +echo Help - %mas%fix_service echo: echo: ping 127.0.0.1 -n 20 @@ -86,7 +84,7 @@ 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 Help - %mas%troubleshoot echo: echo: ping 127.0.0.1 -n 20 >nul @@ -131,24 +129,14 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" 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% +%nceline% echo Unsupported OS version detected [%winbuild%]. -echo This option is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. +echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. goto dk_done ) @@ -184,6 +172,33 @@ goto dk_done ::======================================================================================================================================== +:: Check PowerShell + +REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +echo: +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% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto dk_done +) + +::======================================================================================================================================== + :: Elevate script as admin and pass arguments and preventing loop %nul1% fltmc || ( @@ -196,86 +211,6 @@ goto dk_done ::======================================================================================================================================== -:: Check PowerShell - -::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) - -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: - -REM check LanguageMode - -echo: !tstresult2! | 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... -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 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 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 ', '))}""" -) - -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 ( @@ -286,35 +221,34 @@ set terminal= :: Check if script is running in Terminal app +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + if defined terminal ( -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 -) -if !lines! GEQ 100 set terminal= +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= ) +if defined ps32onArm goto :skipQE 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 +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" ) +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) :skipQE ::======================================================================================================================================== @@ -323,18 +257,12 @@ exit /b 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= -) +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 activ%-%ated.win') do ( +if not "%%#"=="" set old=1 +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck%upver%.activ%-%ated.win') do ( +if not "%%#"=="" set old= ) ) @@ -351,7 +279,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 +293,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% "Help - " %_Yellow% " %mas%troubleshoot" +goto dk_done +) + ::======================================================================================================================================== set spp=SoftwareLicensingProduct @@ -398,7 +335,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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -447,7 +385,6 @@ _updch _lang _clversion _version -_AudienceData _oIds _c2rXml _c2rExe @@ -472,7 +409,7 @@ echo which is not officially supported on your Windows build version %winbuild%. echo Aborting... echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -486,7 +423,7 @@ echo Unsupported Office %verchk% is installed on your Windows build version %win echo Aborting... echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -575,10 +512,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 @@ -593,7 +529,7 @@ if not exist %SystemRoot%\Temp\%list%.txt ( echo Failed to generate available editions list. echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto :oe_goback ) @@ -652,13 +588,13 @@ 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. echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto :oe_goback ) ) @@ -694,8 +630,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 +757,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,43 +772,11 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) call :oe_tempcleanup @@ -896,7 +797,6 @@ goto :oe_goback ) set change=0 -set editedition=1 call :ch_getinfo cls @@ -1002,8 +902,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... @@ -1014,7 +919,7 @@ echo %c2rcommand% if %errorlevel% NEQ 0 ( echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) goto :oe_goback @@ -1045,12 +950,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 +958,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 +1014,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 +1028,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 +1056,42 @@ 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 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!==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 +1114,6 @@ set _oRoot= set _oArch= set _updch= set _oIds= -set _firstoId= set _lang= set _cfolder= set _version= @@ -1343,13 +1144,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 +1162,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 +1179,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 @@ -1543,15 +1322,9 @@ if ($appIdsList.Count -gt 0) { :dk_setvar -set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe -set psc=%ps% -nop -c +set psc=powershell.exe 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" - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set _NCS=1 if %winbuild% LSS 10586 set _NCS=0 @@ -1599,7 +1372,6 @@ exit /b :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 @@ -1610,21 +1382,16 @@ exit /b :dk_sppissue -sc start %_slser% %nul% +sc start sppsvc %nul% 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 sc start sppsvc [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'}" +%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}" exit /b :: Common lines used in PowerShell reflection code @@ -1642,10 +1409,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -) else if not exist %ps% ( -echo %~3 ) exit /b @@ -1653,10 +1418,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' -) else if not exist %ps% ( -echo %~3 %~6 ) exit /b @@ -1671,8 +1434,7 @@ 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 (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..fa4f62f 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.0 @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 @@ -76,7 +74,7 @@ echo: echo Null service is not running, script may crash... echo: echo: -echo Check this webpage for help - %mas%fix_service +echo Help - %mas%fix_service echo: echo: ping 127.0.0.1 -n 20 @@ -91,7 +89,7 @@ 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 Help - %mas%troubleshoot echo: echo: ping 127.0.0.1 -n 20 >nul @@ -136,24 +134,14 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" 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% +%nceline% echo Unsupported OS version detected [%winbuild%]. -echo This option is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. +echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. goto dk_done ) @@ -189,6 +177,33 @@ goto dk_done ::======================================================================================================================================== +:: Check PowerShell + +REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +echo: +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% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto dk_done +) + +::======================================================================================================================================== + :: Elevate script as admin and pass arguments and preventing loop %nul1% fltmc || ( @@ -201,86 +216,6 @@ goto dk_done ::======================================================================================================================================== -:: Check PowerShell - -::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) - -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: - -REM check LanguageMode - -echo: !tstresult2! | 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... -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 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 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 ', '))}""" -) - -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 ( @@ -291,35 +226,34 @@ set terminal= :: Check if script is running in Terminal app +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + if defined terminal ( -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 -) -if !lines! GEQ 100 set terminal= +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= ) +if defined ps32onArm goto :skipQE 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 +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" ) +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) :skipQE ::======================================================================================================================================== @@ -328,18 +262,12 @@ exit /b 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= -) +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 activ%-%ated.win') do ( +if not "%%#"=="" set old=1 +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck%upver%.activ%-%ated.win') do ( +if not "%%#"=="" set old= ) ) @@ -356,7 +284,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) ) ) @@ -396,11 +324,8 @@ if not exist %SysPath%\%%# ( %eline% echo [%SysPath%\%%#] file is missing, aborting... 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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) ) @@ -432,7 +357,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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -454,7 +380,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% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -477,7 +404,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 +473,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 +526,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 @@ -620,7 +543,7 @@ echo [%targetedition% ^| %winbuild%] echo Failed to get product key from pkeyhelper.dll. echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -675,7 +598,7 @@ call :dk_color %Gray% "Reboot is required to fully change the edition." call :dk_color %Red% "[Unsuccessful] [Error Code: !keyerror!]" echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" ) ) @@ -687,7 +610,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 +648,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% @@ -756,7 +679,7 @@ echo [%targetedition% ^| %winbuild%] echo Failed to get product key from pkeyhelper.dll. echo: set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" goto dk_done ) @@ -832,14 +755,14 @@ echo: call :dk_color %Blue% "In case there are errors, you should restart the system before trying again." echo: set fixes=%fixes% %mas%change_edition_issues -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%change_edition_issues" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%change_edition_issues" exit /b :compresslog :: 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% @@ -871,15 +794,9 @@ exit /b :dk_setvar -set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe -set psc=%ps% -nop -c +set psc=powershell.exe 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" - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set _NCS=1 if %winbuild% LSS 10586 set _NCS=0 @@ -954,7 +871,6 @@ exit /b :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 @@ -965,21 +881,16 @@ exit /b :dk_sppissue -sc start %_slser% %nul% +sc start sppsvc %nul% 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 sc start sppsvc [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'}" +%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc is not working correctly. Help - %mas%troubleshoot'}" exit /b :: Common lines used in PowerShell reflection code @@ -1077,10 +988,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -) else if not exist %ps% ( -echo %~3 ) exit /b @@ -1088,10 +997,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' -) else if not exist %ps% ( -echo %~3 %~6 ) exit /b @@ -1106,8 +1013,7 @@ 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 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -1396,55 +1302,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..f15f36e 100644 --- a/MAS/Separate-Files-Version/Check_Activation_Status.cmd +++ b/MAS/Separate-Files-Version/Check_Activation_Status.cmd @@ -23,11 +23,10 @@ set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%Syste set "ComSpec=%SysPath%\cmd.exe" set "PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;%SysPath%\WindowsPowerShell\v1.0\Modules" -set "ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe" -set "_psc=%ps% -nop -c" +set "_psc=powershell -nop -c" set "_err===== ERROR ====" set _pwsh=1 -if not exist %ps% set _pwsh=0 +for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" set _pwsh=0 cmd /c "%_psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" 1>nul || (set _pwsh=0) if %_pwsh% equ 0 ( echo %_err% @@ -39,7 +38,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. @@ -119,7 +118,6 @@ $IID = $IID.IsPresent -Or $Dlv.IsPresent $NT6 = $winbuild -GE 6000 $NT7 = $winbuild -GE 7600 -$NT8 = $winbuild -GE 9200 $NT9 = $winbuild -GE 9600 $Admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) @@ -195,289 +193,55 @@ function CheckOhook & $noAll } -#region SSSS -function BoolToWStr($bVal) { - ("TRUE", "FALSE")[!$bVal] -} - -function InitializePInvoke($LaDll, $bOffice) { - $LaName = [IO.Path]::GetFileNameWithoutExtension($LaDll) - $SLApp = $NT7 -Or $bOffice -Or ($LaName -EQ 'sppc' -And [Diagnostics.FileVersionInfo]::GetVersionInfo("$SysPath\sppc.dll").FilePrivatePart -GE 16501) - $Win32 = $null - - $Marshal = [System.Runtime.InteropServices.Marshal] - $Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly(($LaName+"_Assembly"), 'Run').DefineDynamicModule(($LaName+"_Module"), $False) - $Class = $Module.DefineType(($LaName+"_Methods"), 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0) - - $Class.DefinePInvokeMethod('SLClose', $LaDll, 22, 1, [Int32], @([IntPtr]), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLOpen', $LaDll, 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGenerateOfflineInstallationId', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetSLIDList', $LaDll, 22, 1, [Int32], @([IntPtr], [UInt32], [Guid].MakeByRefType(), [UInt32], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetLicensingStatusInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [Guid].MakeByRefType(), [IntPtr], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetPKeyInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetProductSkuInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetServiceInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - if ($SLApp) { - $Class.DefinePInvokeMethod('SLGetApplicationInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - } - if ($bOffice) { - $Win32 = $Class.CreateType() - return - } - if ($NT6) { - $Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Class.DefinePInvokeMethod('SLIsGenuineLocal', 'slwga.dll', 22, 1, [Int32], @([Guid].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr]), 1, 3).SetImplementationFlags(128) - } - if ($NT7) { - $Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig') - } - - if ($DllSubscription) { - $Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) - $Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0) - [void]$Struct.DefineField('dwEnabled', [UInt32], 'Public') - [void]$Struct.DefineField('dwSku', [UInt32], 6) - [void]$Struct.DefineField('dwState', [UInt32], 6) - $SubStatus = $Struct.CreateType() - } - - $Win32 = $Class.CreateType() -} - -function SlGetInfoIID($SkuId) +#region WMI +function DetectID($strSLP, $strAppId) { - $bData = 0 - - if ($Win32::SLGenerateOfflineInstallationId( - $hSLC, - [ref][Guid]$SkuId, - [ref]$bData - )) - { - return $null - } - else - { - return $Marshal::PtrToStringUni($bData) - } + $ppk = (" AND PartialProductKey <> NULL)", ")")[$All.IsPresent] + $fltr = "SELECT ID FROM $strSLP WHERE (ApplicationID='$strAppId'" + $clause = $fltr + $ppk + $sWmi = [wmisearcher]$clause + $sWmi.Options.Rewindable = $false + return ($sWmi.Get().Count -GT 0) } -function SlReturnData($hrRet, $tData, $cData, $bData) { - if ($hrRet -NE 0 -Or $cData -EQ 0) - { - return $null - } - if ($tData -EQ 1) - { - return $Marshal::PtrToStringUni($bData) - } - elseif ($tData -EQ 4) - { - return $Marshal::ReadInt32($bData) - } - elseif ($tData -EQ 3 -And $cData -EQ 8) - { - return $Marshal::ReadInt64($bData) - } - else - { - return $null - } -} - -function SlGetInfoPKey($PkeyId, $Value) +function GetID($strSLP, $strAppId) { - $tData = 0 - $cData = 0 - $bData = 0 + $NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001) + $IDs = [Collections.ArrayList]@() + $isAdd = (" AND LicenseDependsOn <> NULL)", ")")[$NT5] + $noAdd = " AND LicenseDependsOn IS NULL)" + $query = "SELECT ID FROM $strSLP WHERE (ApplicationID='$strAppId' AND PartialProductKey" - $hrRet = $Win32::SLGetPKeyInformation( - $hSLC, - [ref][Guid]$PkeyId, - $Value, - [ref]$tData, - [ref]$cData, - [ref]$bData - ) - - return SlReturnData $hrRet $tData $cData $bData -} - -function SlGetInfoSku($SkuId, $Value) -{ - $tData = 0 - $cData = 0 - $bData = 0 - - $hrRet = $Win32::SLGetProductSkuInformation( - $hSLC, - [ref][Guid]$SkuId, - $Value, - [ref]$tData, - [ref]$cData, - [ref]$bData - ) - - return SlReturnData $hrRet $tData $cData $bData -} - -function SlGetInfoApp($AppId, $Value) -{ - $tData = 0 - $cData = 0 - $bData = 0 - - $hrRet = $Win32::SLGetApplicationInformation( - $hSLC, - [ref][Guid]$AppId, - $Value, - [ref]$tData, - [ref]$cData, - [ref]$bData - ) - - return SlReturnData $hrRet $tData $cData $bData -} - -function SlGetInfoService($Value) -{ - $tData = 0 - $cData = 0 - $bData = 0 - - $hrRet = $Win32::SLGetServiceInformation( - $hSLC, - $Value, - [ref]$tData, - [ref]$cData, - [ref]$bData - ) - - return SlReturnData $hrRet $tData $cData $bData -} - -function SlGetInfoSvcApp($strApp, $Value) -{ - if ($SLApp) - { - return SlGetInfoApp $strApp $Value - } - else - { - return SlGetInfoService $Value - } -} - -function SlGetInfoLicensing($AppId, $SkuId) -{ - $dwStatus = 0 - $dwGrace = 0 - $hrReason = 0 - $qwValidity = 0 - - $cStatus = 0 - $pStatus = 0 - - $hrRet = $Win32::SLGetLicensingStatusInformation( - $hSLC, - [ref][Guid]$AppId, - [ref][Guid]$SkuId, - 0, - [ref]$cStatus, - [ref]$pStatus - ) - - if ($hrRet -NE 0 -Or $cStatus -EQ 0) - { - return - } - - [IntPtr]$ppStatus = [Int64]$pStatus + [Int64]40 * ($cStatus - 1) - $dwStatus = $Marshal::ReadInt32($ppStatus, 16) - $dwGrace = $Marshal::ReadInt32($ppStatus, 20) - $hrReason = $Marshal::ReadInt32($ppStatus, 28) - $qwValidity = $Marshal::ReadInt64($ppStatus, 32) - - if ($dwStatus -EQ 3) - { - $dwStatus = 5 - } - if ($dwStatus -EQ 2) - { - if ($hrReason -EQ 0x4004F00D) - { - $dwStatus = 3 - } - elseif ($hrReason -EQ 0x4004F065) - { - $dwStatus = 4 - } - elseif ($hrReason -EQ 0x4004FC06) - { - $dwStatus = 6 + if ($All.IsPresent) { + $fltr = $query + " IS NULL" + $clause = $fltr + $isAdd + $sWmi = [wmisearcher]$clause + $sWmi.Options.Rewindable = $false + try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {} + if (-Not $NT5) { + $clause = $fltr + $noAdd + $sWmi = [wmisearcher]$clause + $sWmi.Options.Rewindable = $false + try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {} } } - return -} - -function SlGetInfoSLID($AppId) -{ - $cReturnIds = 0 - $pReturnIds = 0 - - $hrRet = $Win32::SLGetSLIDList( - $hSLC, - 0, - [ref][Guid]$AppId, - 1, - [ref]$cReturnIds, - [ref]$pReturnIds - ) - - if ($hrRet -NE 0 -Or $cReturnIds -EQ 0) - { - return + $fltr = $query + " <> NULL" + $clause = $fltr + $isAdd + $sWmi = [wmisearcher]$clause + $sWmi.Options.Rewindable = $false + try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {} + if (-Not $NT5) { + $clause = $fltr + $noAdd + $sWmi = [wmisearcher]$clause + $sWmi.Options.Rewindable = $false + try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {} } - $a1List = @() - $a2List = @() - $a3List = @() - $a4List = @() - - foreach ($i in 0..($cReturnIds - 1)) - { - $bytes = New-Object byte[] 16 - $Marshal::Copy([Int64]$pReturnIds + [Int64]16 * $i, $bytes, 0, 16) - $actid = ([Guid]$bytes).Guid - $gPPK = SlGetInfoSku $actid "pkeyId" - $gAdd = SlGetInfoSku $actid "DependsOn" - if ($All.IsPresent) { - if ($null -EQ $gPPK -And $null -NE $gAdd) { $a1List += @{id = $actid; pk = $null; ex = $true} } - if ($null -EQ $gPPK -And $null -EQ $gAdd) { $a2List += @{id = $actid; pk = $null; ex = $false} } - } - if ($null -NE $gPPK -And $null -NE $gAdd) { $a3List += @{id = $actid; pk = $gPPK; ex = $true} } - if ($null -NE $gPPK -And $null -EQ $gAdd) { $a4List += @{id = $actid; pk = $gPPK; ex = $false} } - } - - return ($a1List + $a2List + $a3List + $a4List) + return $IDs } function DetectSubscription { - try - { - $objSvc = New-Object PSObject - $wmiSvc = [wmisearcher]"SELECT SubscriptionType, SubscriptionStatus, SubscriptionEdition, SubscriptionExpiry FROM SoftwareLicensingService" - $wmiSvc.Options.Rewindable = $false - $wmiSvc.Get() | select -Expand Properties -EA 0 | foreach { $objSvc | Add-Member 8 $_.Name $_.Value } - $wmiSvc.Dispose() - } - catch - { - return - } - if ($null -EQ $objSvc.SubscriptionType -Or $objSvc.SubscriptionType -EQ 120) { return } @@ -509,267 +273,208 @@ function DetectSubscription { } CONOUT "`nSubscription information:" + CONOUT " Edition: $SubMsgEdition" CONOUT " Type : $SubMsgType" CONOUT " Status : $SubMsgStatus" - CONOUT " Edition: $SubMsgEdition" CONOUT " Expiry : $SubMsgExpiry" } function DetectAdbaClient { - $propADBA | foreach { set $_ (SlGetInfoSku $licID $_) } - DetectActType CONOUT "`nAD Activation client information:" CONOUT " Object Name: $ADActivationObjectName" CONOUT " Domain Name: $ADActivationObjectDN" - CONOUT " CSVLK Extended PID: $ADActivationCsvlkPID" - CONOUT " CSVLK Activation ID: $ADActivationCsvlkSkuID" + CONOUT " CSVLK Extended PID: $ADActivationCsvlkPid" + CONOUT " CSVLK Activation ID: $ADActivationCsvlkSkuId" } function DetectAvmClient { - $propAVMA | foreach { set $_ (SlGetInfoSku $licID $_) } CONOUT "`nAutomatic VM Activation client information:" - if (-Not [String]::IsNullOrEmpty($InheritedActivationId)) { - CONOUT " Guest IAID: $InheritedActivationId" + if (-Not [String]::IsNullOrEmpty($IAID)) { + CONOUT " Guest IAID: $IAID" } else { CONOUT " Guest IAID: Not Available" } - if (-Not [String]::IsNullOrEmpty($InheritedActivationHostMachineName)) { - CONOUT " Host machine name: $InheritedActivationHostMachineName" + if (-Not [String]::IsNullOrEmpty($AutomaticVMActivationHostMachineName)) { + CONOUT " Host machine name: $AutomaticVMActivationHostMachineName" } else { CONOUT " Host machine name: Not Available" } - if (-Not [String]::IsNullOrEmpty($InheritedActivationHostDigitalPid2)) { - CONOUT " Host Digital PID2: $InheritedActivationHostDigitalPid2" - } else { - CONOUT " Host Digital PID2: Not Available" - } - if ($InheritedActivationActivationTime) { - $IAAT = [DateTime]::FromFileTime($InheritedActivationActivationTime).ToString('yyyy-MM-dd hh:mm:ss tt') - CONOUT " Activation time: $IAAT" + if ($AutomaticVMActivationLastActivationTime.Substring(0,4) -NE "1601") { + $EED = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($AutomaticVMActivationLastActivationTime),$null,48).ToString('yyyy-MM-dd hh:mm:ss tt') + CONOUT " Activation time: $EED UTC" } else { CONOUT " Activation time: Not Available" } + if (-Not [String]::IsNullOrEmpty($AutomaticVMActivationHostDigitalPid2)) { + CONOUT " Host Digital PID2: $AutomaticVMActivationHostDigitalPid2" + } else { + CONOUT " Host Digital PID2: Not Available" + } } function DetectKmsHost { - $IsKeyManagementService = SlGetInfoSvcApp $strApp 'IsKeyManagementService' - if (-Not $IsKeyManagementService) { - return - } - if ($Vista -Or $NT5) { - $regk = $SLKeyPath - } elseif ($strSLP -EQ $oslp) { - $regk = $OPKeyPath + $KeyManagementServiceListeningPort = strGetRegistry $SLKeyPath "KeyManagementServiceListeningPort" + $KeyManagementServiceDnsPublishing = strGetRegistry $SLKeyPath "DisableDnsPublishing" + $KeyManagementServiceLowPriority = strGetRegistry $SLKeyPath "EnableKmsLowPriority" + if (-Not $KeyManagementServiceDnsPublishing) {$KeyManagementServiceDnsPublishing = "TRUE"} + if (-Not $KeyManagementServiceLowPriority) {$KeyManagementServiceLowPriority = "FALSE"} } else { - $regk = $SPKeyPath - } - $KMSListening = strGetRegistry $regk "KeyManagementServiceListeningPort" - $KMSPublishing = strGetRegistry $regk "DisableDnsPublishing" - $KMSPriority = strGetRegistry $regk "EnableKmsLowPriority" - - if (-Not $KMSListening) {$KMSListening = 1688} - if (-Not $KMSPublishing) {$KMSPublishing = "TRUE"} else {$KMSPublishing = BoolToWStr (!$KMSPublishing)} - if (-Not $KMSPriority) {$KMSPriority = "FALSE"} else {$KMSPriority = BoolToWStr $KMSPriority} - - if ($KMSPublishing -EQ "TRUE") {$KMSPublishing = "Enabled"} else {$KMSPublishing = "Disabled"} - if ($KMSPriority -EQ "TRUE") {$KMSPriority = "Low"} else {$KMSPriority = "Normal"} - - if ($SLApp) - { - $propKMSServer | foreach { set $_ (SlGetInfoApp $strApp $_) } - } - else - { - $propKMSServer | foreach { set $_ (SlGetInfoService $_) } + $KeyManagementServiceListeningPort = $objSvc.KeyManagementServiceListeningPort + $KeyManagementServiceDnsPublishing = $objSvc.KeyManagementServiceDnsPublishing + $KeyManagementServiceLowPriority = $objSvc.KeyManagementServiceLowPriority } - $KMSRequests = $KeyManagementServiceTotalRequests - $NoRequests = ($null -EQ $KMSRequests) -Or ($KMSRequests -EQ -1) -Or ($KMSRequests -EQ 4294967295) + if (-Not $KeyManagementServiceListeningPort) {$KeyManagementServiceListeningPort = 1688} + if ($KeyManagementServiceDnsPublishing -EQ "TRUE") { + $KeyManagementServiceDnsPublishing = "Enabled" + } else { + $KeyManagementServiceDnsPublishing = "Disabled" + } + if ($KeyManagementServiceLowPriority -EQ "TRUE") { + $KeyManagementServiceLowPriority = "Low" + } else { + $KeyManagementServiceLowPriority = "Normal" + } CONOUT "`nKey Management Service host information:" CONOUT " Current count: $KeyManagementServiceCurrentCount" - CONOUT " Listening on Port: $KMSListening" - CONOUT " DNS publishing: $KMSPublishing" - CONOUT " KMS priority: $KMSPriority" - if ($NoRequests) { - return + CONOUT " Listening on Port: $KeyManagementServiceListeningPort" + CONOUT " DNS publishing: $KeyManagementServiceDnsPublishing" + CONOUT " KMS priority: $KeyManagementServiceLowPriority" + if (-Not [String]::IsNullOrEmpty($KeyManagementServiceTotalRequests)) { + CONOUT "`nKey Management Service cumulative requests received from clients:" + CONOUT " Total: $KeyManagementServiceTotalRequests" + CONOUT " Failed: $KeyManagementServiceFailedRequests" + CONOUT " Unlicensed: $KeyManagementServiceUnlicensedRequests" + CONOUT " Licensed: $KeyManagementServiceLicensedRequests" + CONOUT " Initial grace period: $KeyManagementServiceOOBGraceRequests" + CONOUT " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests" + CONOUT " Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests" + if ($null -NE $KeyManagementServiceNotificationRequests) {CONOUT " Notification: $KeyManagementServiceNotificationRequests"} } - CONOUT "`nKey Management Service cumulative requests received from clients:" - CONOUT " Total: $KeyManagementServiceTotalRequests" - CONOUT " Failed: $KeyManagementServiceFailedRequests" - CONOUT " Unlicensed: $KeyManagementServiceUnlicensedRequests" - CONOUT " Licensed: $KeyManagementServiceLicensedRequests" - CONOUT " Initial grace period: $KeyManagementServiceOOBGraceRequests" - CONOUT " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests" - CONOUT " Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests" - 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 ($null -NE $VLActivationTypeEnabled) {CONOUT "Configured Activation Type: $($VLActTypes[$VLActivationTypeEnabled])"} CONOUT "`r" if ($LicenseStatus -NE 1) { CONOUT "Please activate the product in order to update KMS client information values." return } - if ($NT7 -Or $strSLP -EQ $oslp) { - $propKMSClient | foreach { set $_ (SlGetInfoSku $licID $_) } - if ($strSLP -EQ $oslp) {$regk = $OPKeyPath} else {$regk = $SPKeyPath} - $KMSCaching = strGetRegistry $regk "DisableKeyManagementServiceHostCaching" - if (-Not $KMSCaching) {$KMSCaching = "TRUE"} else {$KMSCaching = BoolToWStr (!$KMSCaching)} - } - - "ClientMachineID" | foreach { set $_ (SlGetInfoService $_) } - if ($Vista) { - $propKMSVista | foreach { set $_ (SlGetInfoService $_) } $KeyManagementServicePort = strGetRegistry $SLKeyPath "KeyManagementServicePort" - $DiscoveredKeyManagementServiceName = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServiceName" - $DiscoveredKeyManagementServicePort = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServicePort" + $DiscoveredKeyManagementServiceMachineName = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServiceName" + $DiscoveredKeyManagementServiceMachinePort = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServicePort" } - if ([String]::IsNullOrEmpty($KeyManagementServiceName)) { + if ([String]::IsNullOrEmpty($KeyManagementServiceMachine)) { $KmsReg = $null } else { if (-Not $KeyManagementServicePort) {$KeyManagementServicePort = 1688} - $KmsReg = "Registered KMS machine name: ${KeyManagementServiceName}:${KeyManagementServicePort}" + $KmsReg = "Registered KMS machine name: ${KeyManagementServiceMachine}:${KeyManagementServicePort}" } - if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceName)) { + if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceMachineName)) { $KmsDns = "DNS auto-discovery: KMS name not available" if ($Vista -And -Not $Admin) {$KmsDns = "DNS auto-discovery: Run the script as administrator to retrieve info"} } else { - if (-Not $DiscoveredKeyManagementServicePort) {$DiscoveredKeyManagementServicePort = 1688} - $KmsDns = "KMS machine name from DNS: ${DiscoveredKeyManagementServiceName}:${DiscoveredKeyManagementServicePort}" + if (-Not $DiscoveredKeyManagementServiceMachinePort) {$DiscoveredKeyManagementServiceMachinePort = 1688} + $KmsDns = "KMS machine name from DNS: ${DiscoveredKeyManagementServiceMachineName}:${DiscoveredKeyManagementServiceMachinePort}" } - if ($null -NE $KMSCaching) { - if ($KMSCaching -EQ "TRUE") {$KMSCaching = "Enabled"} else {$KMSCaching = "Disabled"} - } - - if ($strSLP -EQ $wslp -And $NT9) { - if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceIpAddress)) { - $DiscoveredKeyManagementServiceIpAddress = "not available" + if ($null -NE $objSvc.KeyManagementServiceHostCaching) { + if ($objSvc.KeyManagementServiceHostCaching -EQ "TRUE") { + $KeyManagementServiceHostCaching = "Enabled" + } else { + $KeyManagementServiceHostCaching = "Disabled" } } CONOUT "Key Management Service client information:" - CONOUT " Client Machine ID (CMID): $ClientMachineID" + CONOUT " Client Machine ID (CMID): $($objSvc.ClientMachineID)" if ($null -EQ $KmsReg) { CONOUT " $KmsDns" CONOUT " Registered KMS machine name: KMS name not available" } else { CONOUT " $KmsReg" } - if ($null -NE $DiscoveredKeyManagementServiceIpAddress) {CONOUT " KMS machine IP address: $DiscoveredKeyManagementServiceIpAddress"} - CONOUT " KMS machine extended PID: $CustomerPID" + if ($null -NE $DiscoveredKeyManagementServiceMachineIpAddress) {CONOUT " KMS machine IP address: $DiscoveredKeyManagementServiceMachineIpAddress"} + CONOUT " KMS machine extended PID: $KeyManagementServiceProductKeyID" CONOUT " Activation interval: $VLActivationInterval minutes" CONOUT " Renewal interval: $VLRenewalInterval minutes" - if ($null -NE $KMSCaching) {CONOUT " KMS host caching: $KMSCaching"} + if ($null -NE $KeyManagementServiceHostCaching) {CONOUT " KMS host caching: $KeyManagementServiceHostCaching"} if (-Not [String]::IsNullOrEmpty($KeyManagementServiceLookupDomain)) {CONOUT " KMS SRV record lookup domain: $KeyManagementServiceLookupDomain"} } -function GetResult($strSLP, $strApp, $entry) +function GetResult($strSLP, $strSLS, $strID) { - $licID = $entry.id - $propPrd | foreach { set $_ (SlGetInfoSku $licID $_) } - . SlGetInfoLicensing $strApp $licID - $LicenseStatus = $dwStatus - $LicReason = $hrReason - $EvaluationEndDate = $qwValidity - $gprMnt = $dwGrace - - $pkid = $entry.pk - $isPPK = $null -NE $pkid - - $add_on = $Name.IndexOf("add-on for", 5) - if ($add_on -NE -1) { - $Name = $Name.Substring(0, $add_on + 7) + try + { + $objPrd = [wmisearcher]"SELECT * FROM $strSLP WHERE ID='$strID'" + $objPrd.Options.Rewindable = $false + $objPrd.Get() | select -Expand Properties -EA 0 | foreach { if (-Not [String]::IsNullOrEmpty($_.Value)) {set $_.Name $_.Value} } + $objPrd.Dispose() } - - $licPHN = "empty" - if ($Dlv -Or $All.IsPresent) { - $licPHN = SlGetInfoSku $licID "msft:sl/EUL/PHONE/PUBLIC" - } - - if ($LicenseStatus -EQ 0 -And !$isPPK) { - & $isAll - CONOUT "Name: $Name" - CONOUT "Description: $Description" - CONOUT "Activation ID: $licID" - CONOUT "License Status: Unlicensed" - if ($licPHN -NE "empty") { - $gPHN = [String]::IsNullOrEmpty($licPHN) -NE $true - CONOUT "Phone activatable: $($gPHN.ToString())" - } + catch + { return } - $winID = ($strApp -EQ $winApp) - $winPR = ($winID -And -Not $entry.ex) + $winID = ($ApplicationID -EQ $winApp) + $winPR = ($winID -And -Not $LicenseIsAddon) $Vista = ($winID -And $NT6 -And -Not $NT7) $NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001) - $win8 = ($strSLP -EQ $wslp -And $NT8) $reapp = ("Windows", "App")[!$winID] $prmnt = ("machine", "product")[!$winPR] - if ($Description.Contains("VOLUME_KMSCLIENT")) {$cKmsClient = 1; $actTag = "Volume"} - if ($Description.Contains("TIMEBASED_")) {$cTblClient = 1; $actTag = "Timebased"} - if ($Description.Contains("VIRTUAL_MACHINE_ACTIVATION")) {$cAvmClient = 1; $actTag = "Automatic VM"} - if ($null -EQ $cKmsClient -And $Description.Contains("VOLUME_KMS")) {$cKmsServer = 1} - - $gprDay = [Math]::Round($gprMnt/1440) - $_xpr = "" - $inGrace = $false - if ($gprMnt -GT 0) { - $_xpr = [DateTime]::Now.AddMinutes($gprMnt).ToString('yyyy-MM-dd hh:mm:ss tt') - $inGrace = $true + if ($Description | Select-String "VOLUME_KMSCLIENT") {$cKmsClient = 1; $_mTag = "Volume"} + if ($Description | Select-String "TIMEBASED_") {$cTblClient = 1; $_mTag = "Timebased"} + if ($Description | Select-String "VIRTUAL_MACHINE_ACTIVATION") {$cAvmClient = 1; $_mTag = "Automatic VM"} + if ($null -EQ $cKmsClient) { + if ($Description | Select-String "VOLUME_KMS") {$cKmsHost = 1} } - $LicenseMsg = "Time remaining: $gprMnt minute(s) ($gprDay day(s))" + $_gpr = [Math]::Round($GracePeriodRemaining/1440) + if ($_gpr -GT 0) { + $_xpr = [DateTime]::Now.addMinutes($GracePeriodRemaining).ToString('yyyy-MM-dd hh:mm:ss tt') + } + + if ($null -EQ $LicenseStatusReason) {$LicenseStatusReason = -1} + $LicenseReason = '0x{0:X}' -f $LicenseStatusReason + $LicenseMsg = "Time remaining: $GracePeriodRemaining minute(s) ($_gpr day(s))" if ($LicenseStatus -EQ 0) { $LicenseInf = "Unlicensed" $LicenseMsg = $null } if ($LicenseStatus -EQ 1) { $LicenseInf = "Licensed" - if ($gprMnt -EQ 0) { - $LicenseMsg = $null + $LicenseMsg = $null + if ($GracePeriodRemaining -EQ 0) { $ExpireMsg = "The $prmnt is permanently activated." } else { - $LicenseMsg = "$actTag activation expiration: $gprMnt minute(s) ($gprDay day(s))" - if ($inGrace) {$ExpireMsg = "$actTag activation will expire $_xpr"} + $LicenseMsg = "$_mTag activation expiration: $GracePeriodRemaining minute(s) ($_gpr day(s))" + if ($null -NE $_xpr) {$ExpireMsg = "$_mTag activation will expire $_xpr"} } } if ($LicenseStatus -EQ 2) { $LicenseInf = "Initial grace period" - if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"} + if ($null -NE $_xpr) {$ExpireMsg = "Initial grace period ends $_xpr"} } if ($LicenseStatus -EQ 3) { $LicenseInf = "Additional grace period (KMS license expired or hardware out of tolerance)" - if ($inGrace) {$ExpireMsg = "Additional grace period ends $_xpr"} + if ($null -NE $_xpr) {$ExpireMsg = "Additional grace period ends $_xpr"} } if ($LicenseStatus -EQ 4) { $LicenseInf = "Non-genuine grace period" - if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"} + if ($null -NE $_xpr) {$ExpireMsg = "Non-genuine grace period ends $_xpr"} } if ($LicenseStatus -EQ 5 -And -Not $NT5) { - $LicenseReason = '0x{0:X}' -f $LicReason $LicenseInf = "Notification" $LicenseMsg = "Notification Reason: $LicenseReason" if ($LicenseReason -EQ "0xC004F00F") {if ($null -NE $cKmsClient) {$LicenseMsg = $LicenseMsg + " (KMS license expired)."} else {$LicenseMsg = $LicenseMsg + " (hardware out of tolerance)."}} @@ -782,116 +487,110 @@ function GetResult($strSLP, $strApp, $entry) } if ($LicenseStatus -EQ 6 -And -Not $Vista -And -Not $NT5) { $LicenseInf = "Extended grace period" - if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"} + if ($null -NE $_xpr) {$ExpireMsg = "Extended grace period ends $_xpr"} } - if ($isPPK) { - $propPkey | foreach { set $_ (SlGetInfoPKey $pkid $_) } - } - - if ($winPR -And $isPPK -And -Not $NT8) { - $uxd = SlGetInfoSku $licID 'UXDifferentiator' - $script:primary += @{ - aid = $licID; - ppk = $PartialProductKey; - chn = $Channel; - lst = $LicenseStatus; - lcr = $LicReason; - ged = $gprMnt; - evl = $EvaluationEndDate; - dff = $uxd + if ($winPR -And $PartialProductKey -And -Not $NT9) { + $dp4 = strGetRegistry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" "DigitalProductId4" + if ($null -NE $dp4) { + $ProductKeyChannel = ([System.Text.Encoding]::Unicode.GetString($dp4, 1016, 128)).Trim([char]$null) } } - if ($IID -And $isPPK) { - $OfflineInstallationId = SlGetInfoIID $licID - } - - if ($Dlv) { - if ($win8) + if ($winPR -And $Dlv -And $NT7 -And $null -EQ $RemainingAppReArmCount) { + try { - $RemainingSkuReArmCount = SlGetInfoSku $licID 'RemainingRearmCount' - $RemainingAppReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount' + $tmp = [wmisearcher]"SELECT RemainingWindowsReArmCount FROM $strSLS" + $tmp.Options.Rewindable = $false + $tmp.Get() | select -Expand Properties -EA 0 | foreach {set $_.Name $_.Value} + $tmp.Dispose() } - else + catch { - if (($winID -And $NT7) -Or $strSLP -EQ $oslp) - { - $RemainingSLReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount' - } - else - { - $RemainingSLReArmCount = SlGetInfoService 'RearmCount' - } - } - if ($null -EQ $TrustedTime) - { - $TrustedTime = SlGetInfoSvcApp $strApp 'TrustedTime' } } + $add_on = $Name.IndexOf("add-on for", 5) + & $isAll - CONOUT "Name: $Name" + if ($add_on -EQ -1) {CONOUT "Name: $Name"} else {CONOUT "Name: $($Name.Substring(0, $add_on + 7))"} CONOUT "Description: $Description" - CONOUT "Activation ID: $licID" - if ($null -NE $DigitalPID) {CONOUT "Extended PID: $DigitalPID"} - if ($null -NE $DigitalPID2 -And $Dlv) {CONOUT "Product ID: $DigitalPID2"} + CONOUT "Activation ID: $ID" + if ($null -NE $ProductKeyID) {CONOUT "Extended PID: $ProductKeyID"} + if ($null -NE $ProductKeyID2 -And $Dlv) {CONOUT "Product ID: $ProductKeyID2"} if ($null -NE $OfflineInstallationId -And $IID) {CONOUT "Installation ID: $OfflineInstallationId"} - if ($null -NE $Channel) {CONOUT "Product Key Channel: $Channel"} + if ($null -NE $ProductKeyChannel) {CONOUT "Product Key Channel: $ProductKeyChannel"} if ($null -NE $PartialProductKey) {CONOUT "Partial Product Key: $PartialProductKey"} CONOUT "License Status: $LicenseInf" if ($null -NE $LicenseMsg) {CONOUT "$LicenseMsg"} - if ($LicenseStatus -NE 0 -And $EvaluationEndDate) { - $EED = [DateTime]::FromFileTimeUtc($EvaluationEndDate).ToString('yyyy-MM-dd hh:mm:ss tt') + if ($LicenseStatus -NE 0 -And $EvaluationEndDate.Substring(0,4) -NE "1601") { + $EED = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($EvaluationEndDate),$null,48).ToString('yyyy-MM-dd hh:mm:ss tt') CONOUT "Evaluation End Date: $EED UTC" } - if ($LicenseStatus -NE 1 -And $licPHN -NE "empty") { - $gPHN = [String]::IsNullOrEmpty($licPHN) -NE $true - CONOUT "Phone activatable: $($gPHN.ToString())" - } if ($Dlv) { - if ($null -NE $RemainingSLReArmCount) { - CONOUT "Remaining $reapp rearm count: $RemainingSLReArmCount" + if ($null -NE $RemainingWindowsReArmCount) { + CONOUT "Remaining Windows rearm count: $RemainingWindowsReArmCount" } - if ($null -NE $RemainingSkuReArmCount) { + if ($null -NE $RemainingSkuReArmCount -And $RemainingSkuReArmCount -NE 4294967295) { CONOUT "Remaining $reapp rearm count: $RemainingAppReArmCount" CONOUT "Remaining SKU rearm count: $RemainingSkuReArmCount" } - if ($LicenseStatus -NE 0 -And $TrustedTime) { - $TTD = [DateTime]::FromFileTime($TrustedTime).ToString('yyyy-MM-dd hh:mm:ss tt') + if ($null -NE $TrustedTime -And $LicenseStatus -NE 0) { + $TTD = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($TrustedTime),$null,32).ToString('yyyy-MM-dd hh:mm:ss tt') CONOUT "Trusted time: $TTD" } } - if (!$isPPK) { + if ($LicenseStatus -EQ 0) { return } - if ($win8 -And $VLActivationType -EQ 1) { + if ($strSLP -EQ $wslp -And $null -NE $PartialProductKey -And $null -NE $ADActivationObjectName -And $VLActivationType -EQ 1) { DetectAdbaClient - $cKmsClient = $null } - if ($winID -And $null -NE $cAvmClient) { + if ($winID -And $null -NE $cAvmClient -And $null -NE $PartialProductKey) { DetectAvmClient } - $chkSub = ($winPR -And $isSub) + $chkSub = ($winPR -And $cSub) - $chkSLS = ($null -NE $cKmsClient -Or $null -NE $cKmsServer -Or $chkSub) + $chkSLS = ($null -NE $PartialProductKey) -And ($null -NE $cKmsClient -Or $null -NE $cKmsHost -Or $chkSub) if (!$chkSLS) { if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} return } + try + { + $objSvc = New-Object PSObject + $wmiSvc = [wmisearcher]"SELECT * FROM $strSLS" + $wmiSvc.Options.Rewindable = $false + $wmiSvc.Get() | select -Expand Properties -EA 0 | foreach { if (-Not [String]::IsNullOrEmpty($_.Value)) {$objSvc | Add-Member 8 $_.Name $_.Value} } + $wmiSvc.Dispose() + if ($null -EQ $IsKeyManagementServiceMachine) {$objSvc.PSObject.Properties | foreach {set $_.Name $_.Value}} + } + catch + { + return + } + + if ($strSLS -EQ $wsls -And $NT9) { + if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceMachineIpAddress)) { + $DiscoveredKeyManagementServiceMachineIpAddress = "not available" + } + } + + if ($null -NE $cKmsHost -And $IsKeyManagementServiceMachine -GT 0) { + if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} + DetectKmsHost + } + if ($null -NE $cKmsClient) { DetectKmsClient } - if ($null -NE $cKmsServer) { - if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} - DetectKmsHost - } else { + if ($null -EQ $cKmsHost) { if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"} } @@ -900,16 +599,6 @@ function GetResult($strSLP, $strApp, $entry) } } - -function ParseList($strSLP, $strApp, $arrList) -{ - foreach ($entry in $arrList) - { - GetResult $strSLP $strApp $entry - CONOUT "$line3" - & $noAll - } -} #endregion #region vNextDiag @@ -1075,8 +764,8 @@ function PrintLicensesInformation function vNextDiagRun { - $fNUL = ([IO.Directory]::Exists("${env:LOCALAPPDATA}\Microsoft\Office\Licenses")) -and ([IO.Directory]::GetFiles("${env:LOCALAPPDATA}\Microsoft\Office\Licenses", "*", 1).Length -GT 0) - $fDev = ([IO.Directory]::Exists("${env:PROGRAMDATA}\Microsoft\Office\Licenses")) -and ([IO.Directory]::GetFiles("${env:PROGRAMDATA}\Microsoft\Office\Licenses", "*", 1).Length -GT 0) + $fNUL = ([IO.Directory]::Exists("${env:LOCALAPPDATA}\Microsoft\Office\Licenses")) -and ([IO.Directory]::GetFiles("${env:LOCALAPPDATA}\Microsoft\Office\Licenses", "*", 1).Length -GE 0) + $fDev = ([IO.Directory]::Exists("${env:PROGRAMDATA}\Microsoft\Office\Licenses")) -and ([IO.Directory]::GetFiles("${env:PROGRAMDATA}\Microsoft\Office\Licenses", "*", 1).Length -GE 0) $rPID = $null -NE (GP "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext" -EA 0 | select -Expand 'property' -EA 0 | where -Filter {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume"}) $rSCA = $null -NE (GP "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" -EA 0 | select -Expand "SharedComputerLicensing" -EA 0) $rSCL = $null -NE (GP "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing" -EA 0 | select -Expand "SharedComputerLicensing" -EA 0) @@ -1128,6 +817,31 @@ 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. #> +function BoolToWStr($bVal) { + ("TRUE", "FALSE")[!$bVal] +} + +function InitializePInvoke { + $Marshal = [System.Runtime.InteropServices.Marshal] + $Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly((Get-Random), 'Run').DefineDynamicModule((Get-Random)) + + $Class = $Module.DefineType('NativeMethods', 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0) + $Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig') + $Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128) + $Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) + + if ($DllSubscription) { + $Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) + $Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0) + [void]$Struct.DefineField('dwEnabled', [UInt32], 'Public') + [void]$Struct.DefineField('dwSku', [UInt32], 6) + [void]$Struct.DefineField('dwState', [UInt32], 6) + $SubStatus = $Struct.CreateType() + } + + $Win32 = $Class.CreateType() +} + function InitializeDigitalLicenseCheck { $CAB = [System.Reflection.Emit.CustomAttributeBuilder] @@ -1182,29 +896,36 @@ function PrintLastActivationHResult { } function PrintLastActivationTime { - $pqwLastTime = 0 + $pdwLastTime = 0 $cbSize = 0 if ($Win32::SLGetWindowsInformation( "Security-SPP-LastWindowsActivationTime", [ref]$null, [ref]$cbSize, - [ref]$pqwLastTime + [ref]$pdwLastTime )) { return $FALSE } - $actTime = $Marshal::ReadInt64($pqwLastTime) + $actTime = $Marshal::ReadInt64($pdwLastTime) if ($actTime -ne 0) { CONOUT (" LastActivationTime={0}" -f [DateTime]::FromFileTimeUtc($actTime).ToString("yyyy/MM/dd:HH:mm:ss")) } - $Marshal::FreeHGlobal($pqwLastTime) + $Marshal::FreeHGlobal($pdwLastTime) return $TRUE } function PrintIsWindowsGenuine { $dwGenuine = 0 + $ppwszGenuineStates = @( + "SL_GEN_STATE_IS_GENUINE", + "SL_GEN_STATE_INVALID_LICENSE", + "SL_GEN_STATE_TAMPERED", + "SL_GEN_STATE_OFFLINE", + "SL_GEN_STATE_LAST" + ) if ($Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine)) { return $FALSE @@ -1301,126 +1022,6 @@ function ClicRun } #endregion -#region clc -function clcGetExpireKrn -{ - $tData = 0 - $cData = 0 - $bData = 0 - - $hrRet = $Win32::SLGetWindowsInformation( - "Kernel-ExpirationDate", - [ref]$tData, - [ref]$cData, - [ref]$bData - ) - - if ($hrRet -Or !$cData -Or $tData -NE 3) - { - return $null - } - - $year = $Marshal::ReadInt16($bData, 0) - if ($year -EQ 0 -Or $year -EQ 1601) - { - $rData = $null - } - else - { - $rData = '{0}/{1}/{2}:{3}:{4}:{5}' -f $year, $Marshal::ReadInt16($bData, 2), $Marshal::ReadInt16($bData, 4), $Marshal::ReadInt16($bData, 6), $Marshal::ReadInt16($bData, 8), $Marshal::ReadInt16($bData, 10) - } - - #$Marshal::FreeHGlobal($bData) - return $rData -} - -function clcGetExpireSys -{ - $kuser = $Marshal::ReadInt64((New-Object IntPtr(0x7FFE02C8))) - - if ($kuser -EQ 0) - { - return $null - } - - $rData = [DateTime]::FromFileTimeUtc($kuser).ToString('yyyy/MM/dd:HH:mm:ss') - return $rData -} - -function clcGetLicensingState($dwState) -{ - if ($dwState -EQ 5) { - $dwState = 3 - } elseif ($dwState -EQ 3 -Or $dwState -EQ 4 -Or $dwState -EQ 6) { - $dwState = 2 - } elseif ($dwState -GT 6) { - $dwState = 4 - } - - $rData = '{0}' -f $ppwszLicensingStates[$dwState] - return $rData -} - -function clcGetGenuineState($AppId) -{ - $dwGenuine = 0 - - if ($NT7) { - $hrRet = $Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine) - } else { - $hrRet = $Win32::SLIsGenuineLocal([ref][Guid]$AppId, [ref]$dwGenuine, 0) - } - - if ($hrRet) - { - $dwGenuine = 4 - } - - if ($dwGenuine -LT 5) { - $rData = '{0}' -f $ppwszGenuineStates[$dwGenuine] - } else { - $rData = $dwGenuine - } - return $rData -} - -function ClcRun -{ - $prs = $script:primary[0] - if ($null -EQ $prs) { - return - } - - $lState = clcGetLicensingState $prs.lst - $uState = clcGetGenuineState $winApp - $TbbKrn = clcGetExpireKrn - $TbbSys = clcGetExpireSys - if ($null -NE $TbbKrn) { - $ked = $TbbKrn - } elseif ($null -NE $TbbSys) { - $ked = $TbbSys - } - - & $isAll - CONOUT "Client Licensing Check information:" - - CONOUT (" AppId={0}" -f $winApp) - if ($prs.ged) { CONOUT (" GraceEndDate={0}" -f ([DateTime]::UtcNow.AddMinutes($prs.ged).ToString('yyyy/MM/dd:HH:mm:ss'))) } - if ($null -NE $ked) { CONOUT (" KernelTimebombDate={0}" -f $ked) } - CONOUT (" LastConsumptionReason=0x{0:x8}" -f $prs.lcr) - if ($prs.evl) { CONOUT (" LicenseExpirationDate={0}" -f ([DateTime]::FromFileTimeUtc($prs.evl).ToString('yyyy/MM/dd:HH:mm:ss'))) } - CONOUT (" LicenseState={0}" -f $lState) - CONOUT (" PartialProductKey={0}" -f $prs.ppk) - CONOUT (" ProductKeyType={0}" -f $prs.chn) - CONOUT (" SkuId={0}" -f $prs.aid) - CONOUT (" uxDifferentiator={0}" -f $prs.dff) - CONOUT (" IsWindowsGenuine={0}" -f $uState) - - CONOUT "$line3" - & $noAll -} -#endregion - $Host.UI.RawUI.WindowTitle = "Check Activation Status" if ($All.IsPresent) { $B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B; @@ -1439,38 +1040,14 @@ $osls = "OfficeSoftwareProtectionService" $winApp = "55c92734-d682-4d71-983e-d6ec3f16059f" $o14App = "59a52881-a989-479d-af46-f275c6370663" $o15App = "0ff1ce15-a989-479d-af46-f275c6370663" -$isSub = ($winbuild -GE 26000) -And (Select-String -Path "$SysPath\wbem\sppwmi.mof" -Encoding unicode -Pattern "SubscriptionType") +$cSub = ($winbuild -GE 19041) -And (Select-String -Path "$SysPath\wbem\sppwmi.mof" -Encoding unicode -Pattern "SubscriptionType") $DllDigital = ($winbuild -GE 14393) -And (Test-Path "$SysPath\EditionUpgradeManagerObj.dll") $DllSubscription = ($winbuild -GE 14393) -And (Test-Path "$SysPath\Clipc.dll") $VLActTypes = @("All", "AD", "KMS", "Token") -$OPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" -$SPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" $SLKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL" $NSKeyPath = "HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL" -$propPrd = 'Name', 'Description', 'TrustedTime', 'VLActivationType' -$propPkey = 'PartialProductKey', 'Channel', 'DigitalPID', 'DigitalPID2' -$propKMSServer = 'KeyManagementServiceCurrentCount', 'KeyManagementServiceTotalRequests', 'KeyManagementServiceFailedRequests', 'KeyManagementServiceUnlicensedRequests', 'KeyManagementServiceLicensedRequests', 'KeyManagementServiceOOBGraceRequests', 'KeyManagementServiceOOTGraceRequests', 'KeyManagementServiceNonGenuineGraceRequests', 'KeyManagementServiceNotificationRequests' -$propKMSClient = 'CustomerPID', 'KeyManagementServiceName', 'KeyManagementServicePort', 'DiscoveredKeyManagementServiceName', 'DiscoveredKeyManagementServicePort', 'DiscoveredKeyManagementServiceIpAddress', 'VLActivationInterval', 'VLRenewalInterval', 'KeyManagementServiceLookupDomain' -$propKMSVista = 'CustomerPID', 'KeyManagementServiceName', 'VLActivationInterval', 'VLRenewalInterval' -$propADBA = 'ADActivationObjectName', 'ADActivationObjectDN', 'ADActivationCsvlkPID', 'ADActivationCsvlkSkuID' -$propAVMA = 'InheritedActivationId', 'InheritedActivationHostMachineName', 'InheritedActivationHostDigitalPid2', 'InheritedActivationActivationTime' -$primary = @() -$ppwszGenuineStates = @( - "SL_GEN_STATE_IS_GENUINE", - "SL_GEN_STATE_INVALID_LICENSE", - "SL_GEN_STATE_TAMPERED", - "SL_GEN_STATE_OFFLINE", - "SL_GEN_STATE_LAST" -) -$ppwszLicensingStates = @( - "SL_LICENSING_STATUS_UNLICENSED", - "SL_LICENSING_STATUS_LICENSED", - "SL_LICENSING_STATUS_IN_GRACE_PERIOD", - "SL_LICENSING_STATUS_NOTIFICATION", - "SL_LICENSING_STATUS_LAST" -) -'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ @()} +'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ $false} $offsvc = "osppsvc" if ($NT7 -Or -Not $NT6) {$winsvc = "sppsvc"} else {$winsvc = "slsvc"} @@ -1478,102 +1055,83 @@ if ($NT7 -Or -Not $NT6) {$winsvc = "sppsvc"} else {$winsvc = "slsvc"} try {gsv $winsvc -EA 1 | Out-Null; $WsppHook = 1} catch {$WsppHook = 0} try {gsv $offsvc -EA 1 | Out-Null; $OsppHook = 1} catch {$OsppHook = 0} -if (Test-Path "$SysPath\sppc.dll") { - $SLdll = 'sppc.dll' -} elseif (Test-Path "$SysPath\slc.dll") { - $SLdll = 'slc.dll' -} else { - $WsppHook = 0 +if ($WsppHook -NE 0) { + try {sasv $winsvc -EA 1} catch {} + $cW1nd0ws = DetectID $wslp $winApp + $c0ff1ce15 = DetectID $wslp $o15App + $c0ff1ce14 = DetectID $wslp $o14App } if ($OsppHook -NE 0) { - $OLdll = (strGetRegistry $OPKeyPath "Path") + 'osppc.dll' - if (!(Test-Path "$OLdll")) {$OsppHook = 0} + try {sasv $offsvc -EA 1} catch {} + $ospp15 = DetectID $oslp $o15App + $ospp14 = DetectID $oslp $o14App } -if ($WsppHook -NE 0) { - if ($NT6 -And -Not $NT7 -And -Not $Admin) { - if ($null -EQ [Diagnostics.Process]::GetProcessesByName("$winsvc")[0].ProcessName) {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"} - } else { - try {sasv $winsvc -EA 1} catch {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"} - } -} - -if ($WsppHook -NE 0) { - . InitializePInvoke $SLdll $false - $hSLC = 0 - [void]$Win32::SLOpen([ref]$hSLC) - - $cW1nd0ws = SlGetInfoSLID $winApp - $c0ff1ce15 = SlGetInfoSLID $o15App - $c0ff1ce14 = SlGetInfoSLID $o14App -} - -if ($cW1nd0ws.Count -GT 0) +if ($cW1nd0ws) { echoWindows - ParseList $wslp $winApp $cW1nd0ws + GetID $wslp $winApp | foreach -EA 1 { + GetResult $wslp $wsls $_ + CONOUT "$line3" + & $noAll + } } elseif ($NT6) { echoWindows - CONOUT "Error: product key not found.`n" + CONOUT "`nError: product key not found." } -if ($NT6 -And -Not $NT8) { - ClcRun -} - -if ($NT8) { +if ($winbuild -GE 9200) { + . InitializePInvoke ClicRun } +if ($c0ff1ce15 -Or $ospp15) { + CheckOhook +} + $doMSG = 1 -if ($c0ff1ce15.Count -GT 0) -{ - CheckOhook - echoOffice - ParseList $wslp $o15App $c0ff1ce15 -} - -if ($c0ff1ce14.Count -GT 0) +if ($c0ff1ce15) { echoOffice - ParseList $wslp $o14App $c0ff1ce14 + GetID $wslp $o15App | foreach -EA 1 { + GetResult $wslp $wsls $_ + CONOUT "$line3" + & $noAll + } } -if ($hSLC) { - [void]$Win32::SLClose($hSLC) -} - -if ($OsppHook -NE 0) { - try {sasv $offsvc -EA 1} catch {$OsppHook = 0; CONOUT "`nError: failed to start $offsvc Service.`n"} -} - -if ($OsppHook -NE 0) { - . InitializePInvoke "$OLdll" $true - $hSLC = 0 - [void]$Win32::SLOpen([ref]$hSLC) - - $ospp15 = SlGetInfoSLID $o15App - $ospp14 = SlGetInfoSLID $o14App -} - -if ($ospp15.Count -GT 0) +if ($c0ff1ce14) { echoOffice - ParseList $oslp $o15App $ospp15 + GetID $wslp $o14App | foreach -EA 1 { + GetResult $wslp $wsls $_ + CONOUT "$line3" + & $noAll + } } -if ($ospp14.Count -GT 0) +if ($ospp15) { echoOffice - ParseList $oslp $o14App $ospp14 + GetID $oslp $o15App | foreach -EA 1 { + GetResult $oslp $osls $_ + CONOUT "$line3" + & $noAll + } } -if ($hSLC) { - [void]$Win32::SLClose($hSLC) +if ($ospp14) +{ + echoOffice + GetID $oslp $o14App | foreach -EA 1 { + GetResult $oslp $osls $_ + CONOUT "$line3" + & $noAll + } } if ($NT7) { diff --git a/MAS/Separate-Files-Version/Extract_OEM_Folder.cmd b/MAS/Separate-Files-Version/Extract_OEM_Folder.cmd index ddbe84e..bae7818 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.0 @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 @@ -71,7 +69,7 @@ echo: echo Null service is not running, script may crash... echo: echo: -echo Check this webpage for help - %mas%fix_service +echo Help - %mas%fix_service echo: echo: ping 127.0.0.1 -n 20 @@ -86,7 +84,7 @@ 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 Help - %mas%troubleshoot echo: echo: ping 127.0.0.1 -n 20 >nul @@ -130,41 +128,14 @@ echo Failed to detect Windows build number. echo: setlocal EnableDelayedExpansion set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" -goto done2 +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" +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 done2 -) -) - -if %winbuild% LSS 6001 ( +if %winbuild% LSS 7600 ( %nceline% echo Unsupported OS version detected [%winbuild%]. -echo MAS only supports Windows Vista/7/8/8.1/10/11 and their Server equivalents. -if %winbuild% EQU 6000 ( -echo: -echo Windows Vista RTM is not supported because Powershell cannot be installed. -echo Upgrade to Windows Vista SP1 or SP2. -) -goto done2 -) - -if %winbuild% LSS 7600 if not exist "%SysPath%\WindowsPowerShell\v1.0\Modules" ( -%nceline% -if not exist %ps% ( -echo PowerShell is not installed in your system. -) -echo Install PowerShell 2.0 using the following URL. -echo: -echo https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 -if %_unattended%==0 start https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 +echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. goto done2 ) @@ -200,6 +171,33 @@ goto done2 ::======================================================================================================================================== +:: Check PowerShell + +REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +echo: +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% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto done2 +) + +::======================================================================================================================================== + :: Elevate script as admin and pass arguments and preventing loop %nul1% fltmc || ( @@ -212,86 +210,6 @@ goto done2 ::======================================================================================================================================== -:: Check PowerShell - -::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) - -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: - -REM check LanguageMode - -echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( -echo FullLanguage mode not found in PowerShell. Aborting... -echo If you have applied restrictions on Powershell then undo those changes. -echo: -set fixes=%fixes% %mas%fix_powershell -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell" -goto done2 -) - -REM check Powershell core version - -cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( -echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... -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 for Mal-ware that may cause issues with Powershell - -for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" ( -echo "%%f" -echo Mal%blank%ware found, PowerShell is not working properly. -echo: -set fixes=%fixes% %mas%remove_mal%w%ware -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" -goto done2 -) - -REM check 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 ', '))}""" -) - -echo: -set fixes=%fixes% %mas%troubleshoot -call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" -goto done2 -) - -::======================================================================================================================================== - :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app if %winbuild% GEQ 17763 ( @@ -302,35 +220,34 @@ set terminal= :: Check if script is running in Terminal app +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + if defined terminal ( -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 -) -if !lines! GEQ 100 set terminal= +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= ) +if defined ps32onArm goto :skipQE 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 +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" ) +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) :skipQE ::======================================================================================================================================== @@ -339,18 +256,12 @@ exit /b 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= -) +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 activ%-%ated.win') do ( +if not "%%#"=="" set old=1 +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck%upver%.activ%-%ated.win') do ( +if not "%%#"=="" set old= ) ) @@ -367,7 +278,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 +316,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 +325,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 +356,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 +478,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 +620,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 +670,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 @@ -734,8 +684,7 @@ 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 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -753,15 +702,9 @@ exit /b :dk_setvar -set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe -set psc=%ps% -nop -c +set psc=powershell.exe 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" - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set _NCS=1 if %winbuild% LSS 10586 set _NCS=0 @@ -809,7 +752,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 ::======================================================================================================================================== @@ -818,10 +761,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -) else if not exist %ps% ( -echo %~3 ) exit /b @@ -829,10 +770,8 @@ exit /b if %_NCS% EQU 1 ( echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m -) else if exist %ps% ( +) else ( %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' -) else if not exist %ps% ( -echo %~3 %~6 ) exit /b diff --git a/MAS/Separate-Files-Version/Troubleshoot.cmd b/MAS/Separate-Files-Version/Troubleshoot.cmd index 124220c..fb32306 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.0 @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 @@ -71,7 +69,7 @@ echo: echo Null service is not running, script may crash... echo: echo: -echo Check this webpage for help - %mas%fix_service +echo Help - %mas%fix_service echo: echo: ping 127.0.0.1 -n 20 @@ -86,7 +84,7 @@ 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 Help - %mas%troubleshoot echo: echo: ping 127.0.0.1 -n 20 >nul @@ -131,41 +129,14 @@ 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" +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" 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 ( +if %winbuild% LSS 7600 ( %nceline% echo Unsupported OS version detected [%winbuild%]. -echo MAS only supports Windows Vista/7/8/8.1/10/11 and their Server equivalents. -if %winbuild% EQU 6000 ( -echo: -echo Windows Vista RTM is not supported because Powershell cannot be installed. -echo Upgrade to Windows Vista SP1 or SP2. -) -goto dk_done -) - -if %winbuild% LSS 7600 if not exist "%SysPath%\WindowsPowerShell\v1.0\Modules" ( -%nceline% -if not exist %ps% ( -echo PowerShell is not installed in your system. -) -echo Install PowerShell 2.0 using the following URL. -echo: -echo https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 -if %_unattended%==0 start https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930 +echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. goto dk_done ) @@ -201,6 +172,33 @@ goto dk_done ::======================================================================================================================================== +:: Check PowerShell + +REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest: + +cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || ( +%eline% +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +echo: +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && ( +echo Failed to run Powershell command but Powershell is working. +echo: +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% "Help - " %_Yellow% " %mas%troubleshoot" +) || ( +echo PowerShell is not working. Aborting... +echo If you have applied restrictions on Powershell then undo those changes. +echo: +set fixes=%fixes% %mas%fix_powershell +call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" +) +goto dk_done +) + +::======================================================================================================================================== + :: Elevate script as admin and pass arguments and preventing loop %nul1% fltmc || ( @@ -213,86 +211,6 @@ goto dk_done ::======================================================================================================================================== -:: Check PowerShell - -::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) - -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: - -REM check LanguageMode - -echo: !tstresult2! | 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... -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 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 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 ', '))}""" -) - -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 ( @@ -303,35 +221,34 @@ set terminal= :: Check if script is running in Terminal app +set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); +set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128); +set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128); +set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow(); +set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero); + if defined terminal ( -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 -) -if !lines! GEQ 100 set terminal= +%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= ) +if defined ps32onArm goto :skipQE 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 +set "launchcmd=start conhost.exe %psc%" +) else ( +set "launchcmd=%psc%" ) +:: Disable QuickEdit in current session + +set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);" +set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);" +set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);" +set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);" + +%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1) :skipQE ::======================================================================================================================================== @@ -340,18 +257,12 @@ exit /b 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= -) +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 activ%-%ated.win') do ( +if not "%%#"=="" set old=1 +for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck%upver%.activ%-%ated.win') do ( +if not "%%#"=="" set old= ) ) @@ -368,7 +279,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 +340,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 ::======================================================================================================================================== @@ -574,13 +485,6 @@ mode 125, 32 ) title Fix Licensing ^(ClipSVC ^+ SPP ^+ OSPP^) -if %winbuild% EQU 6001 ( -%eline% -echo This option is not supported on Windows Vista SP1. -echo Upgrade to Windows Vista SP2. -goto :at_back -) - echo: echo %line% echo: @@ -597,7 +501,7 @@ echo - Clear ClipSVC, SPP and OSPP licenses. echo - Fix permissions of SPP tokens folder and registries. echo - Trigger the repair option for Office. echo: -call :dk_color2 %_White% " - " %Blue% "Apply this option only when it is necessary." +call :dk_color2 %_White% " - " %Red% "Apply this option only when it is necessary." echo: echo %line% echo: @@ -618,7 +522,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 +533,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 +627,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 +652,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]" @@ -814,21 +665,21 @@ echo [No Error Found] ) echo: -echo Stopping %_slser% service... -%psc% Stop-Service %_slser% -force %nul% +echo Stopping sppsvc service... +%psc% Stop-Service sppsvc -force %nul% set w= set _sppint= -for %%# in (SppEx%w%tComObj.exe %_slexe%) do (reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (set _sppint=1)) +for %%# in (SppEx%w%tComObj.exe sppsvc.exe) do (reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (set _sppint=1)) if defined _sppint ( echo: echo Removing SPP IFEO registry keys... -for %%# in (SppE%w%xtComObj.exe %_slexe%) do (reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul%) +for %%# in (SppE%w%xtComObj.exe sppsvc.exe) do (reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul%) ) -if %winbuild% LSS 9200 if not defined _vis ( +if %winbuild% LSS 9200 ( REM Fix issues caused by Update KB971033 in Windows 7 -REM 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% @@ -845,7 +696,6 @@ del /f /q %SysPath%\7B296FB0-376B-497e-B012-9C450E1B7327-*.C7483456-A289-439d-81 :: Delete registry keys that are not deleted by activation scripts -if not defined _vis ( echo: echo Cleaning some licensing-related registry keys... %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "ServiceSessionId" /f @@ -853,7 +703,6 @@ echo Cleaning some licensing-related registry keys... %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "PolicyValuesArray" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform\data" /f -) echo: call :scandat delete @@ -865,14 +714,10 @@ call :dk_color %Red% "Failed to delete .dat files." echo: ) -if defined _vis ( -%psc% Start-Service %_slser% %nul% -) - 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% "Stop-Service sppsvc -force; $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% +if %errorlevel% NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% if %errorlevel% EQU 0 ( echo [Successful] ) else ( @@ -888,7 +733,7 @@ call :dk_color %Red% "Failed to rebuild tokens.dat file." echo tokens.dat file was rebuilt successfully. ) -if %winbuild% LSS 9200 if not defined _vis ( +if %winbuild% LSS 9200 ( sc config sppuinotify start= demand ) @@ -969,17 +814,17 @@ set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office reg query %_68%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_68=Office 14.0 C2R x86/x64" & set "c2r14repair68=") reg query %_86%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_86=Office 14.0 C2R x86" & set "c2r14repair86=") -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi14_86=Office 14.0 MSI x86" & call :getrepairsetup msi14repair86 14) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi14_68=Office 14.0 MSI x86/x64" & call :getrepairsetup msi14repair68 14) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi15_86=Office 15.0 MSI x86" & call :getrepairsetup msi15repair86 15) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi15_68=Office 15.0 MSI x86/x64" & call :getrepairsetup msi15repair68 15) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi16_86=Office 16.0 MSI x86" & call :getrepairsetup msi16repair86 16) -for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*Picker.dll" (set "msi16_68=Office 16.0 MSI x86/x64" & call :getrepairsetup msi16repair68 16) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_86=Office 14.0 MSI x86" & call :getrepairsetup msi14repair86 14) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_68=Office 14.0 MSI x86/x64" & call :getrepairsetup msi14repair68 14) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi15_86=Office 15.0 MSI x86" & call :getrepairsetup msi15repair86 15) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi15_68=Office 15.0 MSI x86/x64" & call :getrepairsetup msi15repair68 15) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi16_86=Office 16.0 MSI x86" & call :getrepairsetup msi16repair86 16) +for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi16_68=Office 16.0 MSI x86/x64" & call :getrepairsetup msi16repair68 16) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (set "c2r15_86=Office 15.0 C2R x86" & call :getc2rrepair c2r15repair86 integratedoffice.exe) for /f "skip=2 tokens=2*" %%a in ('"reg query %_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 +866,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 +899,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 +928,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 +1118,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 +1170,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 +1184,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 +1216,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 @@ -1512,13 +1299,13 @@ function InstallLicenseArr($Str) { ForEach ($x in $a) {InstallLicenseFile "$x"} } function InstallLicenseDir($Loc) { - Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName} + dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} } function ReinstallLicenses() { - $Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens") - foreach ($Path in $Paths) { - if (Test-Path $Path) { InstallLicenseDir "$Path" } - } + $Oem = "$env:SysPath\oem" + $Spp = "$env:SysPath\spp\tokens" + InstallLicenseDir "$Spp" + If (Test-Path $Oem) {InstallLicenseDir "$Oem"} } :xrm: @@ -1532,7 +1319,6 @@ for %%# in ( %SysPath%\spp\store\ %SysPath%\spp\store\2.0\ %Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\ -%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareLicensing\ ) do ( if %1==check ( @@ -1576,7 +1362,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,71 +1394,14 @@ $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 ( -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 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#)) +if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) ) if defined terminal ( @@ -1682,7 +1411,26 @@ choice /c 0 /n call :dk_color %_Yellow% "Press any key to %_exitmsg%..." pause %nul1% ) +exit /b +::======================================================================================================================================== + +:dk_color + +if %_NCS% EQU 1 ( +echo %esc%[%~1%~2%esc%[0m +) else ( +%psc% write-host -back '%1' -fore '%2' '%3' +) +exit /b + +:dk_color2 + +if %_NCS% EQU 1 ( +echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m +) else ( +%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' +) exit /b ::======================================================================================================================================== @@ -1691,15 +1439,9 @@ exit /b :dk_setvar -set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe -set psc=%ps% -nop -c +set psc=powershell.exe 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" - -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 +for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G set _NCS=1 if %winbuild% LSS 10586 set _NCS=0 diff --git a/README.md b/README.md index 02115e2..0fca6c6 100644 --- a/README.md +++ b/README.md @@ -1,111 +1,109 @@ -

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.

+ +
+ +## Download / How to use it? + +### Method 1 - PowerShell (Windows 8 and later) ❤️ + +1. Open PowerShell (Not CMD). To do that, right-click on the Windows start menu and select PowerShell or Terminal. +2. Copy and paste the code below and press enter +``` +irm https://get.activated.win | iex +``` +Alternatively, you can use the following (It will be deprecated in the future.) +``` +irm https://massgrave.dev/get | iex +``` +3. You will see the activation options. Choose (1) HWID for Windows activation. Choose (2) Ohook for Office activation. +4. That's all. + +--- + +### Method 2 - Traditional (Windows 7 and later) + +
+ Click here for info + +1. Download the file using the links provided 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 +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. + +
+ +--- + +### 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. + +--- + +To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches). + +``` +Latest Version: 3.0 +Release date: 14-Feb-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 ❤️