1
0
mirror of https://github.com/massgravel/Microsoft-Activation-Scripts.git synced 2025-07-05 09:21:19 +01:00

67 Commits

Author SHA1 Message Date
c817ae8bd9 Add detection for Microsoft Defender for Endpoint 2025-07-02 23:46:34 +05:30
ef411e14ca Evade AV detection 2025-07-02 23:35:17 +05:30
5aa7d4f3de Revert "Evade AV detection"
This reverts commit 409c4f71ad.
2025-07-02 23:12:04 +05:30
409c4f71ad Evade AV detection 2025-06-26 22:49:57 +05:30
d7a6994363 Fix a bug in detecting Terminal app 2025-06-25 02:34:34 +05:30
5ad6226f37 Revert export-ignore 2025-06-03 18:37:59 +05:30
ae9f4e34ff export-ignore 2025-06-03 18:31:39 +05:30
67abcd0c89 3.4 2025-06-03 18:25:10 +05:30
faf3bf3a08 Update KMS server list 2025-06-03 17:23:00 +05:30
482600c890 Show info related to expired Office preview products 2025-06-03 16:44:13 +05:30
dc90e1ff0f Update info message related to ZCID 2025-06-03 14:55:20 +05:30
f969378f6b Fix a bug in unattended mode in TSforge 2025-06-03 13:35:40 +05:30
c89bebdee8 Revert export-ignore 2025-06-01 21:10:50 +05:30
be7d101df5 Merge branch 'dev' 2025-06-01 20:57:31 +05:30
55b6fce50a Update readme 2025-06-01 20:46:56 +05:30
6566bb53c1 export-ignore 2025-06-01 20:31:23 +05:30
2e44a4a77b 3.3 2025-06-01 20:30:48 +05:30
9073a35fe0 Add StaticCID and KMS4k method in TSforge 2025-06-01 20:27:57 +05:30
9f244ddc17 Fix grammar 2025-05-27 22:10:02 +05:30
8ed0c6874b Suggest TSforge for Office where Windows is not supposed to get feature upgrades 2025-05-27 22:04:35 +05:30
a99acbb025 Update Powershell error detection code 2025-05-27 20:43:23 +05:30
be867f6616 Update links 2025-05-27 19:32:44 +05:30
fc80735dac Improve fix info in the script 2025-05-25 00:38:43 +05:30
69c469a997 Update old Office version detection with subscription license 2025-05-23 18:56:14 +05:30
6e74d49721 Minor fix 2025-05-23 18:20:53 +05:30
ae93f547f5 Add the option to change Office update channel to VL and from VL to retail 2025-05-23 17:54:17 +05:30
830755f6b6 Fix an issue in detecting Office preview licenses in TSforge 2025-05-18 18:11:04 +05:30
a149fc5f20 Change hash 2025-05-18 13:08:08 +05:30
b75ba72bc5 Change hash 2025-05-18 12:52:40 +05:30
206c31ece5 Open mirror pages along with massgrave.dev 2025-05-18 12:09:25 +05:30
133d3b9720 Edit the info related to Mondo conversion 2025-05-18 10:46:12 +05:30
fc2348bf53 Add some info related to O365 to Mondo conversion in TSforge 2025-05-18 03:39:29 +05:30
966fbd14f6 Don't ask to run other fixes if file infector malware is detected 2025-05-18 02:47:41 +05:30
691e6088d5 Use user temp folder or random name in Windows/Temp 2025-05-18 02:41:47 +05:30
74b7c74218 Continue to activate in case of errors 2025-05-18 01:40:41 +05:30
4c53e6231b Fix Microsoft links 2025-05-08 05:31:04 +05:30
2d00dfa704 Revert export-ignore 2025-05-06 23:10:58 +05:30
bf28e4fbdd export-ignore 2025-05-06 22:37:54 +05:30
2a2352428e 3.2 2025-05-06 22:36:13 +05:30
be9215b728 Fix goback button in change Office edition script 2025-05-06 20:01:06 +05:30
93cf3864f5 Directly go back when asked to press key to ignore opening support page 2025-05-06 19:53:15 +05:30
d47a750bad Detect Powershell 1.0 on Server 2008 and ask to install Powershell 2.0 2025-05-06 19:29:19 +05:30
817bfe84de Don't ask to run SFC scan if malware is found 2025-05-06 18:26:33 +05:30
2b40259b33 Add fixes for CAS 2025-05-06 18:09:33 +05:30
a514a99d0e Update an error message in KMS script 2025-05-06 17:47:27 +05:30
2a806c2e0c Fix ARM32 Office detection 2025-05-06 17:39:26 +05:30
b3aaff5110 Update Windows 7 ESU 4-6y info 2025-05-06 17:14:27 +05:30
bcc4214e8a Add O365AppsBasicRetail conversion in KMS script 2025-05-05 22:38:51 +05:30
9e80556df5 Add O365AppsBasicRetail support 2025-05-05 22:25:54 +05:30
b24bb9bde1 Remove () from product name 2025-05-04 17:04:06 +05:30
dfebdefeba Add Office 2010 Publisher Retail key 2025-05-04 02:21:50 +05:30
1bdee1ce6f Improve edition package detection 2025-05-04 01:03:13 +05:30
4e702068be Revert export-ignore 2025-04-29 23:06:43 +05:30
6945236590 Merge branch 'dev' 2025-04-29 22:45:01 +05:30
5872b7df53 3.1
Added Ohook support for OSPP based Office on Vista and later
2025-04-29 22:40:56 +05:30
b8ad749bac Fix issue related to URL opening in unattended mode 2025-04-21 20:22:13 +05:30
5090cde0a0 Use wmic.exe on builds below 9200 2025-04-21 18:01:09 +05:30
af18bd773c Fix a missing echo 2025-04-21 02:29:22 +05:30
52ba9f138f Ask to run DISM restore and SFC scan when system files are missing 2025-04-21 00:53:08 +05:30
98ef9db3ce Add TSforge and Online KMS support for Vista/Server2008 2025-04-20 19:35:53 +05:30
172fd7b1c5 Fix crash issue when scripts are running under a path with special characters 2025-04-17 03:11:21 +05:30
372eb73a02 Add updated TSforge code 2025-04-17 01:47:13 +05:30
a1614e1283 Convert HomeStudentARM IDs to Mondo because phone license isn't available for them 2025-04-16 08:03:58 +05:30
e8bf344f74 Add support for O365 15.0 in TSforge because phone license exist 2025-04-16 06:14:40 +05:30
70162c4130 Add support for external LibTSforge.dll if found in BIN folder 2025-04-16 05:30:31 +05:30
294837dfe0 Add the updated CAS by abbodi1406 2025-04-16 03:47:15 +05:30
313f240448 Change file hash 2025-03-14 15:30:16 +05:30
12 changed files with 9214 additions and 2784 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
@set masver=3.0 @set masver=3.4
@echo off @echo off
@ -100,6 +100,8 @@ set "nul="
set "blank=" set "blank="
set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" 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 :: Check if Null service is working, it's important for the batch script
@ -235,16 +237,18 @@ goto dk_done
::pstst $ExecutionContext.SessionState.LanguageMode :pstst ::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) 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" ( if /i not "%tstresult%"=="FullLanguage" (
%eline% %eline%
echo: %tstresult% for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a)
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" echo Test 1 - %tstresult%
echo Test 2 - !tstresult2!
echo:
REM check LanguageMode REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting... echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes. echo If you have applied restrictions on Powershell then undo those changes.
echo: echo:
@ -274,7 +278,17 @@ goto dk_done
REM check antivirus and other errors REM check antivirus and other errors
echo PowerShell is not working properly. Aborting... echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
if /i "!tstresult2!"=="FullLanguage" (
echo:
echo Your antivirus software might be blocking the script, or PowerShell on your system might be corrupted.
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: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
@ -295,7 +309,9 @@ set terminal=
if defined terminal ( if defined terminal (
set lines=0 set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A 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= if !lines! GEQ 100 set terminal=
) )
@ -356,7 +372,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b)
) )
) )
@ -381,8 +397,13 @@ if not exist %SysPath%\%%# (
%eline% %eline%
echo [%SysPath%\%%#] file is missing, aborting... echo [%SysPath%\%%#] file is missing, aborting...
echo: echo:
if not defined results (
call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run DISM Restore and SFC Scan options."
call :dk_color %Blue% "After that, restart system and try activation again."
echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
)
goto dk_done goto dk_done
) )
) )
@ -490,7 +511,7 @@ set notworking=
call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f
if defined allapps call :hwiddata key if defined allapps call :hwiddata key
if not defined key ( if not defined key (
for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getactivationid\:.*';iex ($f[1])"') do (set altapplist=%%a) for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getactivationid\:.*';& ([scriptblock]::Create($f[1]))"') do (set altapplist=%%a)
if defined altapplist call :hwiddata key if defined altapplist call :hwiddata key
) )
@ -538,6 +559,7 @@ call :dk_color %Blue% "Windows Subscription [SKU ID-%slcSKU%] detected. Script w
echo: echo:
) )
set generickey=1
call :dk_inskey "[%key%]" call :dk_inskey "[%key%]"
::======================================================================================================================================== ::========================================================================================================================================
@ -808,10 +830,16 @@ goto :dk_done
:dk_setvar :dk_setvar
set psc=powershell.exe -nop -c set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
@ -894,7 +922,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 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 %_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 %winbuild% GEQ 15063 %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';& ([scriptblock]::Create($f[1]))" %nul2% | find /i "Subscription_is_activated" %nul% && (
if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" ( if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" (
set winsub=1 set winsub=1
set osSKU=%regSKU% set osSKU=%regSKU%
@ -951,11 +979,12 @@ set keyerror=%errorlevel%
cmd /c exit /b %keyerror% cmd /c exit /b %keyerror%
if %keyerror% NEQ 0 set "keyerror=[0x%=ExitCode%]" if %keyerror% NEQ 0 set "keyerror=[0x%=ExitCode%]"
if defined generickey (set "keyecho=Installing Generic Product Key ") else (set "keyecho=Installing Product Key ")
if %keyerror% EQU 0 ( if %keyerror% EQU 0 (
if %sps%==SoftwareLicensingService call :dk_refresh if %sps%==SoftwareLicensingService call :dk_refresh
echo Installing Generic Product Key %~1 [Successful] echo %keyecho% %~1 [Successful]
) else ( ) else (
call :dk_color %Red% "Installing Generic Product Key %~1 [Failed] %keyerror%" call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%"
if not defined error ( if not defined error (
if defined altapplist call :dk_color %Red% "Activation ID not found for this key." if defined altapplist call :dk_color %Red% "Activation ID not found for this key."
call :dk_color %Blue% "%_fixmsg%" call :dk_color %Blue% "%_fixmsg%"
@ -964,6 +993,7 @@ set showfix=1
set error=1 set error=1
) )
set generickey=
exit /b exit /b
:: Activation command :: Activation command
@ -1002,6 +1032,8 @@ exit /b
:dk_reeval :dk_reeval
if %winbuild% LSS 7600 exit /b
:: This key is left by the system in rearm process and sppsvc sometimes fails to delete it, it causes issues in working of the Scheduled Tasks of SPP :: This key is left by the system in rearm process and sppsvc sometimes fails to delete it, it causes issues in working of the Scheduled Tasks of SPP
set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState" set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState"
@ -1047,13 +1079,13 @@ function InstallLicenseArr($Str) {
ForEach ($x in $a) {InstallLicenseFile "$x"} ForEach ($x in $a) {InstallLicenseFile "$x"}
} }
function InstallLicenseDir($Loc) { function InstallLicenseDir($Loc) {
dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName}
} }
function ReinstallLicenses() { function ReinstallLicenses() {
$Oem = "$env:SysPath\oem" $Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens")
$Spp = "$env:SysPath\spp\tokens" foreach ($Path in $Paths) {
InstallLicenseDir "$Spp" if (Test-Path $Path) { InstallLicenseDir "$Path" }
If (Test-Path $Oem) {InstallLicenseDir "$Oem"} }
} }
:xrm: :xrm:
@ -1061,6 +1093,7 @@ function ReinstallLicenses() {
:dk_ckeckwmic :dk_ckeckwmic
if %winbuild% LSS 9200 (set _wmic=1&exit /b)
set _wmic=0 set _wmic=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1 cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1
@ -1071,16 +1104,16 @@ exit /b
:dk_sppissue :dk_sppissue
sc start sppsvc %nul% sc start %_slser% %nul%
set spperror=%errorlevel% set spperror=%errorlevel%
if %spperror% NEQ 1056 if %spperror% NEQ 0 ( if %spperror% NEQ 1056 if %spperror% NEQ 0 (
%eline% %eline%
echo sc start sppsvc [Error Code: %spperror%] echo sc start %_slser% [Error Code: %spperror%]
) )
echo: echo:
%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc 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 '%_slser% is not working correctly. Check this webpage for help - %mas%troubleshoot'}"
exit /b exit /b
:: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used)
@ -1088,7 +1121,7 @@ exit /b
:dk_product :dk_product
set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3); set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') -replace [string][char]0xa9, '' -replace [string][char]0xae, '' -replace [string][char]0x2122, ''
set winos= set winos=
for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s)
@ -1144,17 +1177,17 @@ for %%# in (avira.com kaspersky.com virustotal.com mcafee.com) do (
find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1) find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1)
if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]" if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]"
sc start sppsvc %nul% sc start %_slser% %nul%
echo "%errorlevel%" | findstr "577 225" %nul% && ( echo "%errorlevel%" | findstr "577 225" %nul% && (
set "results=%results%[Likely File Infector]" set "results=%results%[Likely File Infector]"
) || ( ) || (
if not exist %SysPath%\sppsvc.exe if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]") if not exist %SysPath%\%_slexe% if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]")
) )
if not "%results%%pupfound%"=="" ( if not "%results%%pupfound%"=="" (
if defined pupfound call :dk_color %Gray% "Checking PUP Activators [Found%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% "Checking Probable Mal%w%ware Infection..."
if defined results call :dk_color %Red% "%results%" if defined results (call :dk_color %Red% "%results%"&set showfix=1)
set fixes=%fixes% %mas%remove_mal%w%ware set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
echo: echo:
@ -1228,6 +1261,7 @@ for %%# in (%serv_ste%) do (
if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%) if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%)
if /i %%#==wlidsvc sc config %%# start= demand %nul% if /i %%#==wlidsvc sc config %%# start= demand %nul%
if /i %%#==sppsvc (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "2" /f %nul% & sc config %%# start= delayed-auto %nul%) if /i %%#==sppsvc (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "2" /f %nul% & sc config %%# start= delayed-auto %nul%)
if /i %%#==SLsvc sc config %%# start= auto %nul%
if /i %%#==KeyIso sc config %%# start= demand %nul% if /i %%#==KeyIso sc config %%# start= demand %nul%
if /i %%#==LicenseManager sc config %%# start= demand %nul% if /i %%#==LicenseManager sc config %%# start= demand %nul%
if /i %%#==Winmgmt sc config %%# start= auto %nul% if /i %%#==Winmgmt sc config %%# start= auto %nul%
@ -1292,7 +1326,7 @@ call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option
) )
:: https://learn.microsoft.com/windows-hardware/manufacture/desktop/windows-setup-states :: 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) for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B)
@ -1319,7 +1353,7 @@ call :dk_color2 %Red% "Checking WinPE " %Blue% "[WinPE
set wpainfo= set wpainfo=
set wpaerror= set wpaerror=
for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1])" %nul6%') do (set wpainfo=%%a) for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wpatest\:.*';& ([scriptblock]::Create($f[1]))" %nul6%') do (set wpainfo=%%a)
echo "%wpainfo%" | find /i "Error Found" %nul% && ( echo "%wpainfo%" | find /i "Error Found" %nul% && (
set error=1 set error=1
set wpaerror=1 set wpaerror=1
@ -1357,19 +1391,22 @@ if %osedition%==0 (
call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" call :dk_color %Red% "Checking Edition Name [Not Found In Registry]"
) else ( ) else (
if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" if not exist "%SysPath%\licensing\skus\Security-Licensing-SLC-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" (
set skunotfound=1 set skunotfound=1
call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]" call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]"
) )
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" ( if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" (
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-%osedition%Edition*.mum" (
call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" 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% 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% set error_code=%errorlevel%
cmd /c exit /b %error_code% cmd /c exit /b %error_code%
if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" if %error_code% NEQ 0 set "error_code=0x%=ExitCode%"
@ -1439,7 +1476,7 @@ call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %m
) )
for %%# in (SppEx%w%tComObj.exe sppsvc.exe sppsvc.exe\PerfOptions) do ( for %%# in (SppEx%w%tComObj.exe SLsvc.exe sppsvc.exe sppsvc.exe\PerfOptions) do (
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#")) reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#"))
) )
if defined _sppint ( if defined _sppint (
@ -1453,14 +1490,14 @@ 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 ( if %winbuild% GEQ 7600 for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" %nul6%') do if /i %%b NEQ 0x0 (
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul% reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul%
call :dk_color %Red% "Checking SkipRearm [Default 0 Value Not Found. Changing To 0]" call :dk_color %Red% "Checking SkipRearm [Default 0 Value Not Found. Changing To 0]"
%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null"
) )
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Plugins\Objects\msft:rm/algorithm/hwid/4.0" /f ba02fed39662 /d %nul% || ( 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]" call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]"
set fixes=%fixes% %mas%issues_due_to_gaming_spoofers set fixes=%fixes% %mas%issues_due_to_gaming_spoofers
call :dk_color2 %Blue% "Most likely caused by gaming spoofers. Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" call :dk_color2 %Blue% "Most likely caused by gaming spoofers. Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers"
@ -1470,21 +1507,22 @@ set showfix=1
set tokenstore= set tokenstore=
if %winbuild% GEQ 7600 (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b"
if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform" if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform"
if %winbuild% GEQ 9200 if /i not "%tokenstore%"=="%SysPath%\spp\store" if /i not "%tokenstore%"=="%SysPath%\spp\store\2.0" if /i not "%tokenstore%"=="%SysPath%\spp\store_test\2.0" ( if %winbuild% GEQ 9200 if /i not "!tokenstore!"=="%SysPath%\spp\store" if /i not "!tokenstore!"=="%SysPath%\spp\store\2.0" if /i not "!tokenstore!"=="%SysPath%\spp\store_test\2.0" (
set toerr=1 set toerr=1
set error=1 set error=1
set showfix=1 set showfix=1
call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [%tokenstore%]" call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
)
:: This code creates token folder only if it's missing and sets default permission for it :: This code creates token folder only if it's missing and sets default permission for it
if not defined toerr if not exist "%tokenstore%\" ( if %winbuild% GEQ 7600 if not defined toerr if not exist "%tokenstore%\" (
mkdir "%tokenstore%" %nul% mkdir "%tokenstore%" %nul%
if %winbuild% LSS 9200 set "d=$sddl = 'O:NSG:NSD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;NS)';" if %winbuild% LSS 9200 set "d=$sddl = 'O:NSG:NSD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;NS)';"
if %winbuild% GEQ 9200 set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';" if %winbuild% GEQ 9200 set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';"
@ -1505,7 +1543,7 @@ set showfix=1
if not defined notwinact ( if not defined notwinact (
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
%psc% "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% %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%
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
set "_notfoundids=Key Not Installed / Act ID Not Found" set "_notfoundids=Key Not Installed / Act ID Not Found"
@ -1520,7 +1558,7 @@ call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]"
) )
if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" (
set error=1 set error=1
call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]" call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]"
) )
@ -1559,7 +1597,7 @@ set "permerror=Error Found In SPP Registries"
) )
) )
REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application
if not defined permerror ( if not defined permerror (
reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && (
@ -1655,8 +1693,10 @@ $wpaKey.Close()
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -1664,8 +1704,10 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b
@ -1680,7 +1722,8 @@ if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " 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" call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==2 exit /b
if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#))
) )
if defined terminal ( if defined terminal (

View File

@ -1,4 +1,4 @@
@set masver=3.0 @set masver=3.4
@echo off @echo off
@ -103,6 +103,8 @@ set "nul="
set "blank=" set "blank="
set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" 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 :: Check if Null service is working, it's important for the batch script
@ -238,16 +240,18 @@ goto dk_done
::pstst $ExecutionContext.SessionState.LanguageMode :pstst ::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) 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" ( if /i not "%tstresult%"=="FullLanguage" (
%eline% %eline%
echo: %tstresult% for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a)
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" echo Test 1 - %tstresult%
echo Test 2 - !tstresult2!
echo:
REM check LanguageMode REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting... echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes. echo If you have applied restrictions on Powershell then undo those changes.
echo: echo:
@ -277,7 +281,17 @@ goto dk_done
REM check antivirus and other errors REM check antivirus and other errors
echo PowerShell is not working properly. Aborting... echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
if /i "!tstresult2!"=="FullLanguage" (
echo:
echo Your antivirus software might be blocking the script, or PowerShell on your system might be corrupted.
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: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
@ -298,7 +312,9 @@ set terminal=
if defined terminal ( if defined terminal (
set lines=0 set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A 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= if !lines! GEQ 100 set terminal=
) )
@ -359,7 +375,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b)
) )
) )
cls cls
@ -421,8 +437,13 @@ if defined _fmiss (
%eline% %eline%
echo [%_fmiss%] file is missing, aborting... echo [%_fmiss%] file is missing, aborting...
echo: echo:
if not defined results (
call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run DISM Restore and SFC Scan options."
call :dk_color %Blue% "After that, restart system and try activation again."
echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
)
goto dk_done goto dk_done
) )
@ -617,6 +638,7 @@ call echo Checking Installed Product Key [Partial Key - %%_partial%%] [
) )
if defined key ( if defined key (
set generickey=1
call :dk_inskey "[%key%]" call :dk_inskey "[%key%]"
) )
@ -645,7 +667,7 @@ echo:
%nul% reg delete "HKU\S-1-5-20\%specific_kms%" /f %nul% reg delete "HKU\S-1-5-20\%specific_kms%" /f
%nul% reg query "HKLM\%specific_kms%" && ( %nul% reg query "HKLM\%specific_kms%" && (
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regdel\:.*';iex ($f[1])" %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':regdel\:.*';& ([scriptblock]::Create($f[1]))"
%nul% reg delete "HKLM\%specific_kms%" /f %nul% reg delete "HKLM\%specific_kms%" /f
) )
@ -715,12 +737,6 @@ set "_xmlexist=if exist "%tdir%\GenuineTicket.xml""
%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null" %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% ( %_xmlexist% (
%psc% "Start-Job { Restart-Service ClipSVC } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Restart-Service ClipSVC } | Wait-Job -Timeout 20 | Out-Null"
%_xmlexist% timeout /t 2 %nul% %_xmlexist% timeout /t 2 %nul%
@ -821,7 +837,7 @@ echo Removing the Added Specific KMS Host [Successful]
:: Protect KMS38 if opted by the user and conditions are correct :: Protect KMS38 if opted by the user and conditions are correct
if defined _k38 ( if defined _k38 (
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regdel\:.*';& ([ScriptBlock]::Create($f[1])) -protect" %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':regdel\:.*';& ([ScriptBlock]::Create($f[1])) -protect"
%nul% reg delete "HKLM\%specific_kms%" /f %nul% reg delete "HKLM\%specific_kms%" /f
%nul% reg query "HKLM\%specific_kms%" && ( %nul% reg query "HKLM\%specific_kms%" && (
echo Protect KMS38 From KMS [Successful] [Locked a Registry Key] echo Protect KMS38 From KMS [Successful] [Locked a Registry Key]
@ -865,7 +881,7 @@ title Remove KMS38 Protection %masver%
%nul% reg delete "HKU\S-1-5-20\%specific_kms%" /f %nul% reg delete "HKU\S-1-5-20\%specific_kms%" /f
%nul% reg query "HKLM\%specific_kms%" && ( %nul% reg query "HKLM\%specific_kms%" && (
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regdel\:.*';iex ($f[1])" %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':regdel\:.*';& ([scriptblock]::Create($f[1]))"
%nul% reg delete "HKLM\%specific_kms%" /f %nul% reg delete "HKLM\%specific_kms%" /f
) )
@ -914,10 +930,16 @@ $key.SetAccessControl($acl)
:dk_setvar :dk_setvar
set psc=powershell.exe -nop -c set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
@ -1000,7 +1022,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 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 %_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 %winbuild% GEQ 15063 %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';& ([scriptblock]::Create($f[1]))" %nul2% | find /i "Subscription_is_activated" %nul% && (
if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" ( if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" (
set winsub=1 set winsub=1
set osSKU=%regSKU% set osSKU=%regSKU%
@ -1076,11 +1098,12 @@ set keyerror=%errorlevel%
cmd /c exit /b %keyerror% cmd /c exit /b %keyerror%
if %keyerror% NEQ 0 set "keyerror=[0x%=ExitCode%]" if %keyerror% NEQ 0 set "keyerror=[0x%=ExitCode%]"
if defined generickey (set "keyecho=Installing Generic Product Key ") else (set "keyecho=Installing Product Key ")
if %keyerror% EQU 0 ( if %keyerror% EQU 0 (
if %sps%==SoftwareLicensingService call :dk_refresh if %sps%==SoftwareLicensingService call :dk_refresh
echo Installing Generic Product Key %~1 [Successful] echo %keyecho% %~1 [Successful]
) else ( ) else (
call :dk_color %Red% "Installing Generic Product Key %~1 [Failed] %keyerror%" call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%"
if not defined error ( if not defined error (
if defined altapplist call :dk_color %Red% "Activation ID not found for this key." if defined altapplist call :dk_color %Red% "Activation ID not found for this key."
call :dk_color %Blue% "%_fixmsg%" call :dk_color %Blue% "%_fixmsg%"
@ -1089,6 +1112,7 @@ set showfix=1
set error=1 set error=1
) )
set generickey=
exit /b exit /b
:: Get Windows installed key channel :: Get Windows installed key channel
@ -1124,6 +1148,8 @@ exit /b
:dk_reeval :dk_reeval
if %winbuild% LSS 7600 exit /b
:: This key is left by the system in rearm process and sppsvc sometimes fails to delete it, it causes issues in working of the Scheduled Tasks of SPP :: This key is left by the system in rearm process and sppsvc sometimes fails to delete it, it causes issues in working of the Scheduled Tasks of SPP
set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState" set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState"
@ -1151,13 +1177,13 @@ function InstallLicenseArr($Str) {
ForEach ($x in $a) {InstallLicenseFile "$x"} ForEach ($x in $a) {InstallLicenseFile "$x"}
} }
function InstallLicenseDir($Loc) { function InstallLicenseDir($Loc) {
dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName}
} }
function ReinstallLicenses() { function ReinstallLicenses() {
$Oem = "$env:SysPath\oem" $Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens")
$Spp = "$env:SysPath\spp\tokens" foreach ($Path in $Paths) {
InstallLicenseDir "$Spp" if (Test-Path $Path) { InstallLicenseDir "$Path" }
If (Test-Path $Oem) {InstallLicenseDir "$Oem"} }
} }
:xrm: :xrm:
@ -1165,6 +1191,7 @@ function ReinstallLicenses() {
:dk_ckeckwmic :dk_ckeckwmic
if %winbuild% LSS 9200 (set _wmic=1&exit /b)
set _wmic=0 set _wmic=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1 cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1
@ -1175,16 +1202,16 @@ exit /b
:dk_sppissue :dk_sppissue
sc start sppsvc %nul% sc start %_slser% %nul%
set spperror=%errorlevel% set spperror=%errorlevel%
if %spperror% NEQ 1056 if %spperror% NEQ 0 ( if %spperror% NEQ 1056 if %spperror% NEQ 0 (
%eline% %eline%
echo sc start sppsvc [Error Code: %spperror%] echo sc start %_slser% [Error Code: %spperror%]
) )
echo: echo:
%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc 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 '%_slser% is not working correctly. Check this webpage for help - %mas%troubleshoot'}"
exit /b exit /b
:: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used)
@ -1192,7 +1219,7 @@ exit /b
:dk_product :dk_product
set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3); set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') -replace [string][char]0xa9, '' -replace [string][char]0xae, '' -replace [string][char]0x2122, ''
set winos= set winos=
for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s)
@ -1293,17 +1320,17 @@ for %%# in (avira.com kaspersky.com virustotal.com mcafee.com) do (
find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1) find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1)
if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]" if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]"
sc start sppsvc %nul% sc start %_slser% %nul%
echo "%errorlevel%" | findstr "577 225" %nul% && ( echo "%errorlevel%" | findstr "577 225" %nul% && (
set "results=%results%[Likely File Infector]" set "results=%results%[Likely File Infector]"
) || ( ) || (
if not exist %SysPath%\sppsvc.exe if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]") if not exist %SysPath%\%_slexe% if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]")
) )
if not "%results%%pupfound%"=="" ( if not "%results%%pupfound%"=="" (
if defined pupfound call :dk_color %Gray% "Checking PUP Activators [Found%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% "Checking Probable Mal%w%ware Infection..."
if defined results call :dk_color %Red% "%results%" if defined results (call :dk_color %Red% "%results%"&set showfix=1)
set fixes=%fixes% %mas%remove_mal%w%ware set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
echo: echo:
@ -1377,6 +1404,7 @@ for %%# in (%serv_ste%) do (
if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%) if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%)
if /i %%#==wlidsvc sc config %%# start= demand %nul% if /i %%#==wlidsvc sc config %%# start= demand %nul%
if /i %%#==sppsvc (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "2" /f %nul% & sc config %%# start= delayed-auto %nul%) if /i %%#==sppsvc (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "2" /f %nul% & sc config %%# start= delayed-auto %nul%)
if /i %%#==SLsvc sc config %%# start= auto %nul%
if /i %%#==KeyIso sc config %%# start= demand %nul% if /i %%#==KeyIso sc config %%# start= demand %nul%
if /i %%#==LicenseManager sc config %%# start= demand %nul% if /i %%#==LicenseManager sc config %%# start= demand %nul%
if /i %%#==Winmgmt sc config %%# start= auto %nul% if /i %%#==Winmgmt sc config %%# start= auto %nul%
@ -1441,7 +1469,7 @@ call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option
) )
:: https://learn.microsoft.com/windows-hardware/manufacture/desktop/windows-setup-states :: 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) for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B)
@ -1468,7 +1496,7 @@ call :dk_color2 %Red% "Checking WinPE " %Blue% "[WinPE
set wpainfo= set wpainfo=
set wpaerror= set wpaerror=
for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1])" %nul6%') do (set wpainfo=%%a) for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wpatest\:.*';& ([scriptblock]::Create($f[1]))" %nul6%') do (set wpainfo=%%a)
echo "%wpainfo%" | find /i "Error Found" %nul% && ( echo "%wpainfo%" | find /i "Error Found" %nul% && (
set error=1 set error=1
set wpaerror=1 set wpaerror=1
@ -1506,19 +1534,22 @@ if %osedition%==0 (
call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" call :dk_color %Red% "Checking Edition Name [Not Found In Registry]"
) else ( ) else (
if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" if not exist "%SysPath%\licensing\skus\Security-Licensing-SLC-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" (
set skunotfound=1 set skunotfound=1
call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]" call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]"
) )
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" ( if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" (
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-%osedition%Edition*.mum" (
call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" 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% 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% set error_code=%errorlevel%
cmd /c exit /b %error_code% cmd /c exit /b %error_code%
if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" if %error_code% NEQ 0 set "error_code=0x%=ExitCode%"
@ -1588,7 +1619,7 @@ call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %m
) )
for %%# in (SppEx%w%tComObj.exe sppsvc.exe sppsvc.exe\PerfOptions) do ( for %%# in (SppEx%w%tComObj.exe SLsvc.exe sppsvc.exe sppsvc.exe\PerfOptions) do (
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#")) reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#"))
) )
if defined _sppint ( if defined _sppint (
@ -1602,14 +1633,14 @@ 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 ( if %winbuild% GEQ 7600 for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" %nul6%') do if /i %%b NEQ 0x0 (
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul% reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul%
call :dk_color %Red% "Checking SkipRearm [Default 0 Value Not Found. Changing To 0]" call :dk_color %Red% "Checking SkipRearm [Default 0 Value Not Found. Changing To 0]"
%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null"
) )
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Plugins\Objects\msft:rm/algorithm/hwid/4.0" /f ba02fed39662 /d %nul% || ( 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]" call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]"
set fixes=%fixes% %mas%issues_due_to_gaming_spoofers set fixes=%fixes% %mas%issues_due_to_gaming_spoofers
call :dk_color2 %Blue% "Most likely caused by gaming spoofers. Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" call :dk_color2 %Blue% "Most likely caused by gaming spoofers. Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers"
@ -1619,21 +1650,22 @@ set showfix=1
set tokenstore= set tokenstore=
if %winbuild% GEQ 7600 (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b"
if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform" if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform"
if %winbuild% GEQ 9200 if /i not "%tokenstore%"=="%SysPath%\spp\store" if /i not "%tokenstore%"=="%SysPath%\spp\store\2.0" if /i not "%tokenstore%"=="%SysPath%\spp\store_test\2.0" ( if %winbuild% GEQ 9200 if /i not "!tokenstore!"=="%SysPath%\spp\store" if /i not "!tokenstore!"=="%SysPath%\spp\store\2.0" if /i not "!tokenstore!"=="%SysPath%\spp\store_test\2.0" (
set toerr=1 set toerr=1
set error=1 set error=1
set showfix=1 set showfix=1
call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [%tokenstore%]" call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
)
:: This code creates token folder only if it's missing and sets default permission for it :: This code creates token folder only if it's missing and sets default permission for it
if not defined toerr if not exist "%tokenstore%\" ( if %winbuild% GEQ 7600 if not defined toerr if not exist "%tokenstore%\" (
mkdir "%tokenstore%" %nul% mkdir "%tokenstore%" %nul%
if %winbuild% LSS 9200 set "d=$sddl = 'O:NSG:NSD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;NS)';" if %winbuild% LSS 9200 set "d=$sddl = 'O:NSG:NSD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;NS)';"
if %winbuild% GEQ 9200 set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';" if %winbuild% GEQ 9200 set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';"
@ -1654,7 +1686,7 @@ set showfix=1
if not defined notwinact ( if not defined notwinact (
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
%psc% "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% %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%
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
set "_notfoundids=Key Not Installed / Act ID Not Found" set "_notfoundids=Key Not Installed / Act ID Not Found"
@ -1669,7 +1701,7 @@ call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]"
) )
if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" (
set error=1 set error=1
call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]" call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]"
) )
@ -1708,7 +1740,7 @@ set "permerror=Error Found In SPP Registries"
) )
) )
REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application
if not defined permerror ( if not defined permerror (
reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && (
@ -1804,8 +1836,10 @@ $wpaKey.Close()
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -1813,8 +1847,10 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b
@ -1829,7 +1865,8 @@ if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " 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" call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==2 exit /b
if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#))
) )
if defined terminal ( if defined terminal (

View File

@ -1,4 +1,4 @@
@set masver=3.0 @set masver=3.4
@echo off @echo off
@ -125,6 +125,8 @@ set "nul="
set "blank=" set "blank="
set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" 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 :: Check if Null service is working, it's important for the batch script
@ -202,10 +204,27 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble
goto dk_done goto dk_done
) )
if %winbuild% LSS 7600 ( if %winbuild% LSS 6001 (
%nceline% %nceline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo MAS only supports Windows 7/8/8.1/10/11 and their Server equivalents. 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
goto dk_done goto dk_done
) )
@ -257,16 +276,18 @@ goto dk_done
::pstst $ExecutionContext.SessionState.LanguageMode :pstst ::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) 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" ( if /i not "%tstresult%"=="FullLanguage" (
%eline% %eline%
echo: %tstresult% for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a)
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" echo Test 1 - %tstresult%
echo Test 2 - !tstresult2!
echo:
REM check LanguageMode REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting... echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes. echo If you have applied restrictions on Powershell then undo those changes.
echo: echo:
@ -296,7 +317,17 @@ goto dk_done
REM check antivirus and other errors REM check antivirus and other errors
echo PowerShell is not working properly. Aborting... echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
if /i "!tstresult2!"=="FullLanguage" (
echo:
echo Your antivirus software might be blocking the script, or PowerShell on your system might be corrupted.
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: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
@ -317,7 +348,9 @@ set terminal=
if defined terminal ( if defined terminal (
set lines=0 set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A 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= if !lines! GEQ 100 set terminal=
) )
@ -378,7 +411,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b)
) )
) )
@ -468,12 +501,17 @@ echo:
echo Initializing... echo Initializing...
call :dk_chkmal call :dk_chkmal
if not exist %SysPath%\sppsvc.exe ( if not exist %SysPath%\%_slexe% (
%eline% %eline%
echo [%SysPath%\sppsvc.exe] file is missing, aborting... echo [%SysPath%\%_slexe%] 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: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
)
goto dk_done goto dk_done
) )
@ -522,7 +560,7 @@ call :dk_color %Blue% "Internet is required for Online %KS% Activation."
echo Initiating Diagnostic Tests... echo Initiating Diagnostic Tests...
set "_serv=sppsvc Winmgmt" set "_serv=%_slser% Winmgmt"
:: Software Protection :: Software Protection
:: Windows Management Instrumentation :: Windows Management Instrumentation
@ -612,9 +650,11 @@ echo [%winos% ^| %winbuild% ^| SKU:%osSKU%]
if %winbuild% GEQ 9200 if exist "%SysPath%\spp\tokens\skus\%osedition%\*GVLK*.xrm-ms" set sppks=1 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%\*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 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 ( if defined skunotfound (
call :dk_color %Red% "Required license files not found in %SysPath%\spp\tokens\skus\" call :dk_color %Red% "Required license files not found."
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
@ -655,6 +695,7 @@ call echo Checking Installed Product Key [Partial Key - %%_partial%%] [
) )
if defined key ( if defined key (
set generickey=1
call :dk_inskey "[%key%]" call :dk_inskey "[%key%]"
) )
@ -664,7 +705,7 @@ call :dk_inskey "[%key%]"
if not %_actoff%==1 goto :ks_activate if not %_actoff%==1 goto :ks_activate
call :ks_setspp call :oh_setspp
:: Check ohook install :: Check ohook install
@ -709,7 +750,7 @@ set ohub=1
:: Check supported office versions :: Check supported office versions
call :ks_getpath call :oh_getpath
set o16uwp= set o16uwp=
set o16uwp_path= set o16uwp_path=
@ -749,7 +790,7 @@ call :dk_color %Red% "Checking Installed Office [Not Found]"
if defined ohub ( if defined ohub (
echo: echo:
echo You have only Office dashboard app installed, you need to install full Office version. echo You only have the Office Dashboard app installed. You need to install the full version of Office.
) )
call :dk_color %Blue% "Download and install Office from below URL and try again." call :dk_color %Blue% "Download and install Office from below URL and try again."
set fixes=%fixes% %mas%genuine-installation-media set fixes=%fixes% %mas%genuine-installation-media
@ -841,6 +882,7 @@ set error=1
goto :ks_starto16c2r goto :ks_starto16c2r
) )
call :oh_expiredpreview 2013
if "%_actprojvis%"=="0" call :oh_fixprids if "%_actprojvis%"=="0" call :oh_fixprids
call :ks_process call :ks_process
@ -881,6 +923,7 @@ set error=1
goto :ks_startmsi goto :ks_startmsi
) )
call :oh_expiredpreview 2016 2019 2021 2024
if "%_actprojvis%"=="0" call :oh_fixprids if "%_actprojvis%"=="0" call :oh_fixprids
call :ks_process call :ks_process
@ -888,9 +931,9 @@ call :ks_process
:ks_startmsi :ks_startmsi
if defined o14msi call :ks_setspp 14 if defined o14msi call :oh_setspp 14
if defined o14msi call :ks_processmsi 14 %o14msi_reg% if defined o14msi call :ks_processmsi 14 %o14msi_reg%
call :ks_setspp call :oh_setspp
if defined o15msi call :ks_processmsi 15 %o15msi_reg% if defined o15msi call :ks_processmsi 15 %o15msi_reg%
if defined o16msi call :ks_processmsi 16 %o16msi_reg% if defined o16msi call :ks_processmsi 16 %o16msi_reg%
@ -906,7 +949,7 @@ call :oh_licrefresh
:ks_activate :ks_activate
:: Opt out of sending KMSclient activation data to Microsoft :: Opt out of sending KMSclient activation data to Microsoft
:: https://learn.microsoft.com/windows/privacy/manage-connections-from-windows-operating-system-components-to-microsoft-services#19-software-protection-platform :: https://learn.microsoft.com/en-us/windows/privacy/manage-connections-from-windows-operating-system-components-to-microsoft-services#19-software-protection-platform
if %winbuild% GEQ 9600 ( 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% reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform" /v NoGenTicket /t REG_DWORD /d 1 /f %nul%
@ -974,7 +1017,7 @@ echo Cleared %KS% Server from the registry.
) )
) )
:: https://learn.microsoft.com/azure/virtual-desktop/windows-10-multisession-faq :: https://learn.microsoft.com/en-us/azure/virtual-desktop/windows-10-multisession-faq
if %_actwin%==1 for %%# in (407) do if %osSKU%==%%# ( if %_actwin%==1 for %%# in (407) do if %osSKU%==%%# (
call :dk_color %Red% "%winos% does not support activation on non-azure platforms." call :dk_color %Red% "%winos% does not support activation on non-azure platforms."
@ -1034,7 +1077,7 @@ exit /b
::======================================================================================================================================== ::========================================================================================================================================
:ks_getpath :oh_getpath
set o16c2r= set o16c2r=
set o15c2r= set o15c2r=
@ -1050,12 +1093,27 @@ 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 %_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 %_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 %_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\EntityPicker.dll" (set o16msi=1&set o16msi_reg=%_68%\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\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_86%\15.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\EntityPicker.dll" (set o15msi=1&set o15msi_reg=%_68%\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\EntityPicker.dll" (set o14msi=1&set o14msi_reg=%_86%\14.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\EntityPicker.dll" (set o14msi=1&set o14msi_reg=%_68%\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
for %%# in (%*) do (
if exist "!_oLPath!\ProPlus%%#PreviewVL_*.xrm-ms" if not exist "!_oLPath!\ProPlus%%#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 exit /b
@ -1121,16 +1179,19 @@ exit /b
::======================================================================================================================================== ::========================================================================================================================================
:ks_setspp :oh_setspp
set isOspp=
if %winbuild% GEQ 9200 ( if %winbuild% GEQ 9200 (
set spp=SoftwareLicensingProduct set spp=SoftwareLicensingProduct
set sps=SoftwareLicensingService set sps=SoftwareLicensingService
) else ( ) else (
set isOspp=1
set spp=OfficeSoftwareProtectionProduct set spp=OfficeSoftwareProtectionProduct
set sps=OfficeSoftwareProtectionService set sps=OfficeSoftwareProtectionService
) )
if "%1"=="14" ( if "%1"=="14" (
set isOspp=1
set spp=OfficeSoftwareProtectionProduct set spp=OfficeSoftwareProtectionProduct
set sps=OfficeSoftwareProtectionService set sps=OfficeSoftwareProtectionService
) )
@ -1184,12 +1245,17 @@ call :ksdata getinfo !_prod!
if defined _altoffid ( if defined _altoffid (
set _License=!_altoffid! set _License=!_altoffid!
echo Converting Retail To Volume [!_prod! To !_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! set _prod=!_altoffid!
call :ks_osppready call :ks_osppready
) )
if not "!key!"=="" ( if not "!key!"=="" (
echo "!allapps!" | find /i "!_actid!" %nul1% || call :oh_installlic echo "!allapps!" | find /i "!_actid!" %nul1% || call :oh_installlic
set generickey=1
call :dk_inskey "[!key!] [!_prod!]" call :dk_inskey "[!key!] [!_prod!]"
) else ( ) else (
if not defined _oMSI ( if not defined _oMSI (
@ -1198,7 +1264,7 @@ call :dk_color %Red% "Checking Product In Script [Office %oVer%.0 !
call :dk_color %Blue% "Make sure you are using Latest MAS script." call :dk_color %Blue% "Make sure you are using Latest MAS script."
) else ( ) else (
call :dk_color %Red% "Checking Product In Script [!_prod! MSI Retail is not supported]" call :dk_color %Red% "Checking Product In Script [!_prod! MSI Retail is not supported]"
call :dk_color %Blue% "Uninstall this and Install C2R or MSI VL version of Office." call :dk_color %Blue% "Use Ohook option to activate it. To activate with %KS%, you need to install Volume version of Office."
) )
set fixes=%fixes% %mas%genuine-installation-media set fixes=%fixes% %mas%genuine-installation-media
call :dk_color %_Yellow% "%mas%genuine-installation-media" call :dk_color %_Yellow% "%mas%genuine-installation-media"
@ -1232,10 +1298,6 @@ echo "%2" | find /i "Wow6432Node" %nul1% && set _oArch=x86
if not "%osarch%"=="x86" if not defined _oArch set _oArch=x64 if not "%osarch%"=="x86" if not defined _oArch set _oArch=x64
if "%osarch%"=="x86" set _oArch=x86 if "%osarch%"=="x86" set _oArch=x86
set "_common=%CommonProgramFiles%"
if defined PROCESSOR_ARCHITEW6432 set "_common=%CommonProgramW6432%"
set "_common2=%CommonProgramFiles(x86)%"
call :msiofficedata %2 call :msiofficedata %2
echo: echo:
@ -1290,7 +1352,7 @@ for %%# in ("!_oLPath!\%_License%*.xrm-ms") do (
if defined _arr (set "_arr=!_arr!;"!_oLPath!\%%~nx#"") else (set "_arr="!_oLPath!\%%~nx#"") if defined _arr (set "_arr=!_arr!;"!_oLPath!\%%~nx#"") else (set "_arr="!_oLPath!\%%~nx#"")
) )
%psc% "$sls = Get-WmiObject %sps%; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_oLPath!\pkeyconfig-office.xrm-ms"'" %nul% %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%
call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663 call :dk_actids 0ff1ce15-a989-479d-af46-f275c6370663
echo "!allapps!" | find /i "!_actid!" %nul1% || ( echo "!allapps!" | find /i "!_actid!" %nul1% || (
@ -1305,7 +1367,7 @@ exit /b
:oh_clearblock :oh_clearblock
:: Find remnants of Office vNext/shared/device license block and remove it because it stops other licenses from appearing :: Find remnants of Office vNext/shared/device license block and remove it because it stops other licenses from appearing
:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state :: https://learn.microsoft.com/en-us/office/troubleshoot/activation/reset-office-365-proplus-activation-state
set _sidlist= 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)) 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))
@ -1401,12 +1463,12 @@ reg delete HKLM\SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration /v Share
) )
:: Clear device-based-licensing :: Clear device-based-licensing
:: https://learn.microsoft.com/deployoffice/device-based-licensing :: https://learn.microsoft.com/en-us/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% 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 :: Remove OEM registry key
:: https://support.microsoft.com/office/office-repeatedly-prompts-you-to-activate-on-a-new-pc-a9a6b05f-f6ce-4d1f-8d49-eb5007b64ba1 :: https://support.microsoft.com/en-us/office/office-repeatedly-prompts-you-to-activate-on-a-new-pc-a9a6b05f-f6ce-4d1f-8d49-eb5007b64ba1
for %%# in (15 16) do ( for %%# in (15 16) do (
reg delete "HKLM\SOFTWARE\Microsoft\Office\%%#.0\Common\OEM" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\Office\%%#.0\Common\OEM" /f %nul%
@ -1495,8 +1557,8 @@ exit /b
:oh_licrefresh :oh_licrefresh
if exist "%SysPath%\spp\store_test\2.0\tokens.dat" ( if exist "%SysPath%\spp\store_test\2.0\tokens.dat" (
%psc% "Stop-Service sppsvc -force; $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% %psc% "Stop-Service sppsvc -force; $sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';& ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul%
if !errorlevel! NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% if !errorlevel! NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[System.IO.File]::ReadAllText('!_batp!') -split ':xrm\:.*';& ([scriptblock]::Create($f[1])); ReinstallLicenses" %nul%
) )
exit /b exit /b
@ -1648,6 +1710,11 @@ set "nul=>nul 2>&1"
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set psc=powershell.exe -nop -c 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
set run_once= set run_once=
set t_name=Renewal Task set t_name=Renewal Task
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\taskcache\tasks" /f Path /s | find /i "\Activation-Run_Once" >nul && ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\taskcache\tasks" /f Path /s | find /i "\Activation-Run_Once" >nul && (
@ -1659,6 +1726,7 @@ set _wmic=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" 2>nul | find /i "computersystem" 1>nul && set _wmic=1 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 setlocal EnableDelayedExpansion
if exist "%ProgramFiles%\Activation-Renewal\" call :_taskstart>>"%ProgramFiles%\Activation-Renewal\Logs.txt" if exist "%ProgramFiles%\Activation-Renewal\" call :_taskstart>>"%ProgramFiles%\Activation-Renewal\Logs.txt"
@ -1711,7 +1779,7 @@ call :_taskclear-cache
:: Check WMI and sppsvc Errors :: Check WMI and sppsvc Errors
set applist= set applist=
net start sppsvc /y %nul% net start %_slser% /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 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')" 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")) %chkapp% do (if defined applist (call set "applist=!applist! %%a") else (call set "applist=%%a"))
@ -2013,12 +2081,20 @@ exit /b
:_taskclear-cache :_taskclear-cache
set w= set w=
for %%# in (SppE%w%xtComObj.exe sppsvc.exe) do ( 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% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul%
) )
set "OPPk=SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" 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 "SPPk=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
)
set "slp=SoftwareLicensingProduct" set "slp=SoftwareLicensingProduct"
set "ospp=OfficeSoftwareProtectionProduct" set "ospp=OfficeSoftwareProtectionProduct"
@ -2084,8 +2160,8 @@ set srvlist=
set -= 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=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.my%-%ds.cloud" 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%-%pym.com" 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 n=1 set n=1
for %%a in (%srvlist%) do (set %%a=&set server!n!=%%a&set /a n+=1) for %%a in (%srvlist%) do (set %%a=&set server!n!=%%a&set /a n+=1)
@ -2134,16 +2210,17 @@ for /f %%G in ('%psc% "[Guid]::NewGuid().Guid"') do set "randguid=%%G"
set "_temp=%SystemRoot%\Temp\%Random%%randguid%" set "_temp=%SystemRoot%\Temp\%Random%%randguid%"
set nil= set nil=
if %winbuild% LSS 7600 (set _vista=_vista)
if exist "%_temp%\.*" rmdir /s /q "%_temp%\" %nul% if exist "%_temp%\.*" rmdir /s /q "%_temp%\" %nul%
md "%_temp%\" %nul% md "%_temp%\" %nul%
call :ks_RenExport renewal "%_temp%\Renewal.xml" Unicode call :ks_RenExport renewal%_vista% "%_temp%\Renewal.xml" Unicode
if not defined _int (call :ks_RenExport run_once "%_temp%\Run_Once.xml" Unicode) if not defined _int (call :ks_RenExport run_once%_vista% "%_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% 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 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% if exist "%_temp%\.*" rmdir /s /q "%_temp%\" %nul%
call :ks_createInfo.txt call :ks_createInfo.txt
%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)" %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)"
::======================================================================================================================================== ::========================================================================================================================================
@ -2173,7 +2250,7 @@ exit /b
:ks_RenExport :ks_RenExport
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('%~2',$f[1].Trim(),[System.Text.Encoding]::%~3);" %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split \":%~1\:.*`r`n\"; [io.file]::WriteAllText('%~2',$f[1].Trim(),[System.Text.Encoding]::%~3);"
exit /b exit /b
::======================================================================================================================================== ::========================================================================================================================================
@ -2326,16 +2403,137 @@ exit /b
</Task> </Task>
:run_once: :run_once:
:renewal_vista:
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>1999-01-01T12:00:00.34375</Date>
<Author>WindowsAddict</Author>
<Description>Online K-M-S Activation-Renewal - Weekly Task</Description>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>1999-01-01T12:00:00.34375</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByWeek>
<DaysOfWeek>
<Sunday />
</DaysOfWeek>
<WeeksInterval>1</WeeksInterval>
</ScheduleByWeek>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-18</UserId>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<IdleSettings>
<Duration>PT10M</Duration>
<WaitTimeout>PT1H</WaitTimeout>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>
<NetworkSettings />
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT10M</ExecutionTimeLimit>
<Priority>7</Priority>
<RestartOnFailure>
<Interval>PT5M</Interval>
<Count>3</Count>
</RestartOnFailure>
</Settings>
<Actions Context="Author">
<Exec>
<Command>%ProgramFiles%\Activation-Renewal\Activation_task.cmd</Command>
<Arguments>Task</Arguments>
</Exec>
</Actions>
</Task>
:renewal_vista:
:run_once_vista:
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>1999-01-01T12:00:00.34375</Date>
<Author>WindowsAddict</Author>
<Description>Online K-M-S Activation Run Once - Run and Delete itself on first Internet Contact</Description>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
</LogonTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-18</UserId>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<IdleSettings>
<Duration>PT10M</Duration>
<WaitTimeout>PT1H</WaitTimeout>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>
<NetworkSettings />
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT10M</ExecutionTimeLimit>
<Priority>7</Priority>
<RestartOnFailure>
<Interval>PT5M</Interval>
<Count>3</Count>
</RestartOnFailure>
</Settings>
<Actions Context="Author">
<Exec>
<Command>%ProgramFiles%\Activation-Renewal\Activation_task.cmd</Command>
<Arguments>Task</Arguments>
</Exec>
</Actions>
</Task>
:run_once_vista:
::======================================================================================================================================== ::========================================================================================================================================
:: Set variables :: Set variables
:dk_setvar :dk_setvar
set psc=powershell.exe -nop -c set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
@ -2418,7 +2616,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 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 %_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 %winbuild% GEQ 15063 %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':winsubstatus\:.*';& ([scriptblock]::Create($f[1]))" %nul2% | find /i "Subscription_is_activated" %nul% && (
if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" ( if defined regSKU if defined slcSKU if not "%regSKU%"=="%slcSKU%" (
set winsub=1 set winsub=1
set osSKU=%regSKU% set osSKU=%regSKU%
@ -2475,11 +2673,12 @@ set keyerror=%errorlevel%
cmd /c exit /b %keyerror% cmd /c exit /b %keyerror%
if %keyerror% NEQ 0 set "keyerror=[0x%=ExitCode%]" if %keyerror% NEQ 0 set "keyerror=[0x%=ExitCode%]"
if defined generickey (set "keyecho=Installing Generic Product Key ") else (set "keyecho=Installing Product Key ")
if %keyerror% EQU 0 ( if %keyerror% EQU 0 (
if %sps%==SoftwareLicensingService call :dk_refresh if %sps%==SoftwareLicensingService call :dk_refresh
echo Installing Generic Product Key %~1 [Successful] echo %keyecho% %~1 [Successful]
) else ( ) else (
call :dk_color %Red% "Installing Generic Product Key %~1 [Failed] %keyerror%" call :dk_color %Red% "%keyecho% %~1 [Failed] %keyerror%"
if not defined error ( if not defined error (
if defined altapplist call :dk_color %Red% "Activation ID not found for this key." if defined altapplist call :dk_color %Red% "Activation ID not found for this key."
call :dk_color %Blue% "%_fixmsg%" call :dk_color %Blue% "%_fixmsg%"
@ -2488,6 +2687,7 @@ set showfix=1
set error=1 set error=1
) )
set generickey=
exit /b exit /b
:: Get Windows installed key channel :: Get Windows installed key channel
@ -2512,9 +2712,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 ( if defined allapps if %1==0ff1ce15-a989-479d-af46-f275c6370663 (
set len=0 set len=0
echo:!allapps!> %SystemRoot%\Temp\chklen echo:!allapps!> "!_ttemp!\chklen"
for %%A in (%SystemRoot%\Temp\chklen) do (set len=%%~zA) for %%A in ("!_ttemp!\chklen") do (set len=%%~zA)
del %SystemRoot%\Temp\chklen %nul% del "!_ttemp!\chklen" %nul%
if !len! GTR 6000 ( if !len! GTR 6000 (
%eline% %eline%
@ -2539,6 +2739,8 @@ exit /b
:dk_reeval :dk_reeval
if %winbuild% LSS 7600 exit /b
:: This key is left by the system in rearm process and sppsvc sometimes fails to delete it, it causes issues in working of the Scheduled Tasks of SPP :: This key is left by the system in rearm process and sppsvc sometimes fails to delete it, it causes issues in working of the Scheduled Tasks of SPP
set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState" set "ruleskey=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\PersistedSystemState"
@ -2566,13 +2768,13 @@ function InstallLicenseArr($Str) {
ForEach ($x in $a) {InstallLicenseFile "$x"} ForEach ($x in $a) {InstallLicenseFile "$x"}
} }
function InstallLicenseDir($Loc) { function InstallLicenseDir($Loc) {
dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName}
} }
function ReinstallLicenses() { function ReinstallLicenses() {
$Oem = "$env:SysPath\oem" $Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens")
$Spp = "$env:SysPath\spp\tokens" foreach ($Path in $Paths) {
InstallLicenseDir "$Spp" if (Test-Path $Path) { InstallLicenseDir "$Path" }
If (Test-Path $Oem) {InstallLicenseDir "$Oem"} }
} }
:xrm: :xrm:
@ -2580,6 +2782,7 @@ function ReinstallLicenses() {
:dk_ckeckwmic :dk_ckeckwmic
if %winbuild% LSS 9200 (set _wmic=1&exit /b)
set _wmic=0 set _wmic=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1 cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1
@ -2590,16 +2793,16 @@ exit /b
:dk_sppissue :dk_sppissue
sc start sppsvc %nul% sc start %_slser% %nul%
set spperror=%errorlevel% set spperror=%errorlevel%
if %spperror% NEQ 1056 if %spperror% NEQ 0 ( if %spperror% NEQ 1056 if %spperror% NEQ 0 (
%eline% %eline%
echo sc start sppsvc [Error Code: %spperror%] echo sc start %_slser% [Error Code: %spperror%]
) )
echo: echo:
%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc 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 '%_slser% is not working correctly. Check this webpage for help - %mas%troubleshoot'}"
exit /b exit /b
:: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used) :: Get Product name (WMI/REG methods are not reliable in all conditions, hence winbrand.dll method is used)
@ -2607,7 +2810,7 @@ exit /b
:dk_product :dk_product
set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3); set d1=%ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') set d1=%d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%%WINDOWS_LONG%%') -replace [string][char]0xa9, '' -replace [string][char]0xae, '' -replace [string][char]0x2122, ''
set winos= set winos=
for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s) for /f "delims=" %%s in ('"%psc% %d1%"') do if not errorlevel 1 (set winos=%%s)
@ -2708,17 +2911,17 @@ for %%# in (avira.com kaspersky.com virustotal.com mcafee.com) do (
find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1) find /i "%%#" %SysPath%\drivers\etc\hosts %nul% && set /a hcount+=1)
if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]" if %hcount%==4 set "results=[Antivirus URLs are blocked in hosts]"
sc start sppsvc %nul% sc start %_slser% %nul%
echo "%errorlevel%" | findstr "577 225" %nul% && ( echo "%errorlevel%" | findstr "577 225" %nul% && (
set "results=%results%[Likely File Infector]" set "results=%results%[Likely File Infector]"
) || ( ) || (
if not exist %SysPath%\sppsvc.exe if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]") if not exist %SysPath%\%_slexe% if not exist %SysPath%\alg.exe (set "results=%results%[Likely File Infector]")
) )
if not "%results%%pupfound%"=="" ( if not "%results%%pupfound%"=="" (
if defined pupfound call :dk_color %Gray% "Checking PUP Activators [Found%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% "Checking Probable Mal%w%ware Infection..."
if defined results call :dk_color %Red% "%results%" if defined results (call :dk_color %Red% "%results%"&set showfix=1)
set fixes=%fixes% %mas%remove_mal%w%ware set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
echo: echo:
@ -2792,6 +2995,7 @@ for %%# in (%serv_ste%) do (
if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%) if /i %%#==ClipSVC (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "3" /f %nul% & sc config %%# start= demand %nul%)
if /i %%#==wlidsvc sc config %%# start= demand %nul% if /i %%#==wlidsvc sc config %%# start= demand %nul%
if /i %%#==sppsvc (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "2" /f %nul% & sc config %%# start= delayed-auto %nul%) if /i %%#==sppsvc (reg add "HKLM\SYSTEM\CurrentControlSet\Services\%%#" /v "Start" /t REG_DWORD /d "2" /f %nul% & sc config %%# start= delayed-auto %nul%)
if /i %%#==SLsvc sc config %%# start= auto %nul%
if /i %%#==KeyIso sc config %%# start= demand %nul% if /i %%#==KeyIso sc config %%# start= demand %nul%
if /i %%#==LicenseManager sc config %%# start= demand %nul% if /i %%#==LicenseManager sc config %%# start= demand %nul%
if /i %%#==Winmgmt sc config %%# start= auto %nul% if /i %%#==Winmgmt sc config %%# start= auto %nul%
@ -2856,7 +3060,7 @@ call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option
) )
:: https://learn.microsoft.com/windows-hardware/manufacture/desktop/windows-setup-states :: 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) for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B)
@ -2883,7 +3087,7 @@ call :dk_color2 %Red% "Checking WinPE " %Blue% "[WinPE
set wpainfo= set wpainfo=
set wpaerror= set wpaerror=
for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1])" %nul6%') do (set wpainfo=%%a) for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':wpatest\:.*';& ([scriptblock]::Create($f[1]))" %nul6%') do (set wpainfo=%%a)
echo "%wpainfo%" | find /i "Error Found" %nul% && ( echo "%wpainfo%" | find /i "Error Found" %nul% && (
set error=1 set error=1
set wpaerror=1 set wpaerror=1
@ -2921,19 +3125,22 @@ if %osedition%==0 (
call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" call :dk_color %Red% "Checking Edition Name [Not Found In Registry]"
) else ( ) else (
if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" if not exist "%SysPath%\licensing\skus\Security-Licensing-SLC-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" (
set skunotfound=1 set skunotfound=1
call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]" call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]"
) )
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" ( if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" (
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-%osedition%Edition*.mum" (
call :dk_color %Red% "Checking Package Files [Not Found] [%osedition%]" 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% 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% set error_code=%errorlevel%
cmd /c exit /b %error_code% cmd /c exit /b %error_code%
if %error_code% NEQ 0 set "error_code=0x%=ExitCode%" if %error_code% NEQ 0 set "error_code=0x%=ExitCode%"
@ -3003,7 +3210,7 @@ call :dk_color2 %Blue% "In case of activation issues, do this - " %_Yellow% " %m
) )
for %%# in (SppEx%w%tComObj.exe sppsvc.exe sppsvc.exe\PerfOptions) do ( for %%# in (SppEx%w%tComObj.exe SLsvc.exe sppsvc.exe sppsvc.exe\PerfOptions) do (
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#")) reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" %nul% && (if defined _sppint (set "_sppint=!_sppint!, %%#") else (set "_sppint=%%#"))
) )
if defined _sppint ( if defined _sppint (
@ -3017,14 +3224,14 @@ 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 ( if %winbuild% GEQ 7600 for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" %nul6%') do if /i %%b NEQ 0x0 (
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul% reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "SkipRearm" /t REG_DWORD /d "0" /f %nul%
call :dk_color %Red% "Checking SkipRearm [Default 0 Value Not Found. Changing To 0]" call :dk_color %Red% "Checking SkipRearm [Default 0 Value Not Found. Changing To 0]"
%psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Stop-Service sppsvc -force } | Wait-Job -Timeout 20 | Out-Null"
) )
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Plugins\Objects\msft:rm/algorithm/hwid/4.0" /f ba02fed39662 /d %nul% || ( 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]" call :dk_color %Red% "Checking SPP Registry Key [Incorrect ModuleId Found]"
set fixes=%fixes% %mas%issues_due_to_gaming_spoofers set fixes=%fixes% %mas%issues_due_to_gaming_spoofers
call :dk_color2 %Blue% "Most likely caused by gaming spoofers. Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers" call :dk_color2 %Blue% "Most likely caused by gaming spoofers. Check this webpage for help - " %_Yellow% " %mas%issues_due_to_gaming_spoofers"
@ -3034,21 +3241,22 @@ set showfix=1
set tokenstore= set tokenstore=
if %winbuild% GEQ 7600 (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b"
if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform" if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform"
if %winbuild% GEQ 9200 if /i not "%tokenstore%"=="%SysPath%\spp\store" if /i not "%tokenstore%"=="%SysPath%\spp\store\2.0" if /i not "%tokenstore%"=="%SysPath%\spp\store_test\2.0" ( if %winbuild% GEQ 9200 if /i not "!tokenstore!"=="%SysPath%\spp\store" if /i not "!tokenstore!"=="%SysPath%\spp\store\2.0" if /i not "!tokenstore!"=="%SysPath%\spp\store_test\2.0" (
set toerr=1 set toerr=1
set error=1 set error=1
set showfix=1 set showfix=1
call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [%tokenstore%]" call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
)
:: This code creates token folder only if it's missing and sets default permission for it :: This code creates token folder only if it's missing and sets default permission for it
if not defined toerr if not exist "%tokenstore%\" ( if %winbuild% GEQ 7600 if not defined toerr if not exist "%tokenstore%\" (
mkdir "%tokenstore%" %nul% mkdir "%tokenstore%" %nul%
if %winbuild% LSS 9200 set "d=$sddl = 'O:NSG:NSD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;NS)';" if %winbuild% LSS 9200 set "d=$sddl = 'O:NSG:NSD:AI(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;NS)';"
if %winbuild% GEQ 9200 set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';" if %winbuild% GEQ 9200 set "d=$sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)';"
@ -3069,7 +3277,7 @@ set showfix=1
if not defined notwinact ( if not defined notwinact (
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
%psc% "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% %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%
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
set "_notfoundids=Key Not Installed / Act ID Not Found" set "_notfoundids=Key Not Installed / Act ID Not Found"
@ -3084,7 +3292,7 @@ call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]"
) )
if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" ( if %winbuild% GEQ 7600 if exist "%tokenstore%\" if not exist "%tokenstore%\tokens.dat" (
set error=1 set error=1
call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]" call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%tokenstore%\]"
) )
@ -3123,7 +3331,7 @@ set "permerror=Error Found In SPP Registries"
) )
) )
REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application
if not defined permerror ( if not defined permerror (
reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && (
@ -3219,8 +3427,10 @@ $wpaKey.Close()
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -3228,8 +3438,10 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b
@ -3244,7 +3456,8 @@ if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " 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" call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==2 exit /b
if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#))
) )
if defined terminal ( if defined terminal (
@ -3266,47 +3479,30 @@ exit /b
:: 5th column = Other Edition IDs if they are part of the same primary product (For reference only) :: 5th column = Other Edition IDs if they are part of the same primary product (For reference only)
:: Separator = "_" :: Separator = "_"
:: EditionID Notes:
:: For Office 2013 and later, all Edition IDs are clearly defined, and each ID corresponds to its specific licensing.
:: In Office 2010, the situation is a bit more complicated.
:: Products typically fall into two separate categories: Volume License (VL) and Non-VL. This is because a single installation cannot include both Retail and VL licensing types.
:: Some Edition IDs share the same primary product ID. For example, installing ProPlusVL also installs ProPlusAcadVL licenses, as both use 0011 as the primary product ID.
:: Therefore, in the script, we grouped VL and Non-VL versions by primary product ID and selected the highest Edition ID when multiple Edition IDs existed for the same primary product ID.
:: There are a few exceptions to this 2010 rule: Visio (Premium, Pro, Standard) and OEM-SingleImage.
:: For Visio, the issue is that branding.xml lists incorrect primary product IDs. The correct primary product ID for all three Visio variants is 0057. Based on the criteria above, we chose Visio-Premium as the representative Edition ID among the three.
:: For OEM-SingleImage, it installs multiple Edition IDs and uses 003D as the primary product ID. Following our method, we selected the highest available Edition ID—ProfessionalR in this case.
:msiofficedata :msiofficedata
for %%# in ( for %%# in (
14_4d463c2c-0505-4626-8cdb-a4da82e2d8ed_0015_AccessR 14_4d463c2c-0505-4626-8cdb-a4da82e2d8ed_0015_AccessR
14_745fb377-0a59-4ca9-b9a9-c359557a2c4e_001C_AccessRuntimeR 14_745fb377-0a59-4ca9-b9a9-c359557a2c4e_001C_AccessRuntimeR
14_95ab3ec8-4106-4f9d-b632-03c019d1d23f_0015_AccessVL 14_95ab3ec8-4106-4f9d-b632-03c019d1d23f_0015_AccessVL
14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_0016_ExcelR 14_4eaff0d0-c6cb-4187-94f3-c7656d49a0aa_0016_ExcelR_[HSExcelR]
14_71dc86ff-f056-40d0-8ffb-9592705c9b76_0016_ExcelVL 14_71dc86ff-f056-40d0-8ffb-9592705c9b76_0016_ExcelVL
14_7004b7f0-6407-4f45-8eac-966e5f868bde_00BA_GrooveR 14_7004b7f0-6407-4f45-8eac-966e5f868bde_00BA_GrooveR
14_fdad0dfa-417d-4b4f-93e4-64ea8867b7fd_00BA_GrooveVL 14_fdad0dfa-417d-4b4f-93e4-64ea8867b7fd_00BA_GrooveVL
14_7b7d1f17-fdcb-4820-9789-9bec6e377821_0013_HomeBusinessR_[HomeBusinessDemoR] 14_7b7d1f17-fdcb-4820-9789-9bec6e377821_0013_HomeBusinessR_[HomeBusinessDemoR]
14_19316117-30a8-4773-8fd9-7f7231f4e060_011E_HomeBusinessSubR 14_19316117-30a8-4773-8fd9-7f7231f4e060_011E_HomeBusinessSubR
14_09e2d37e-474b-4121-8626-58ad9be5776f_002F_HomeStudentR_[HomeStudentDemoR] 14_09e2d37e-474b-4121-8626-58ad9be5776f_002F_HomeStudentR_[HomeStudentDemoR]
14_c3ae020c-5a71-4cc5-a27a-2a97c2d46860_0029_HSExcelR
14_25fe4611-b44d-49cc-ae87-2143d299194e_00A3_HSOneNoteR
14_d652ad8d-da5c-4358-b928-7fb1b4de7a7c_0037_HSPowerPointR
14_a963d7ae-7a88-41a7-94da-8bb5635a8af9_002B_HSWordR
14_ef1da464-01c8-43a6-91af-e4e5713744f9_0044_InfoPathR 14_ef1da464-01c8-43a6-91af-e4e5713744f9_0044_InfoPathR
14_85e22450-b741-430c-a172-a37962c938af_0044_InfoPathVL 14_85e22450-b741-430c-a172-a37962c938af_0044_InfoPathVL
14_14f5946a-debc-4716-babc-7e2c240fec08_000F_MondoR 14_14f5946a-debc-4716-babc-7e2c240fec08_000F_MondoR
14_533b656a-4425-480b-8e30-1a2358898350_000F_MondoVL 14_533b656a-4425-480b-8e30-1a2358898350_000F_MondoVL
14_c1ceda8b-c578-4d5d-a4aa-23626be4e234_003D_ProfessionalR_[OEM-SingleImage]Exception 14_c1ceda8b-c578-4d5d-a4aa-23626be4e234_003D_ProfessionalR_[OEM-SingleImage]Exception
14_3f7aa693-9a7e-44fc-9309-bb3d8e604925_00A1_OneNoteR 14_3f7aa693-9a7e-44fc-9309-bb3d8e604925_00A1_OneNoteR_[HSOneNoteR]
14_6860b31f-6a67-48b8-84b9-e312b3485c4b_00A1_OneNoteVL 14_6860b31f-6a67-48b8-84b9-e312b3485c4b_00A1_OneNoteVL
14_fbf4ac36-31c8-4340-8666-79873129cf40_001A_OutlookR 14_fbf4ac36-31c8-4340-8666-79873129cf40_001A_OutlookR
14_a9aeabd8-63b8-4079-a28e-f531807fd6b8_001A_OutlookVL 14_a9aeabd8-63b8-4079-a28e-f531807fd6b8_001A_OutlookVL
14_acb51361-c0db-4895-9497-1831c41f31a6_0033_PersonalR_[PersonalDemoR,PersonalPrepaidR] 14_acb51361-c0db-4895-9497-1831c41f31a6_0033_PersonalR_[PersonalDemoR,PersonalPrepaidR]
14_133c8359-4e93-4241-8118-30bb18737ea0_0018_PowerPointR 14_133c8359-4e93-4241-8118-30bb18737ea0_0018_PowerPointR_[HSPowerPointR]
14_38252940-718c-4aa6-81a4-135398e53851_0018_PowerPointVL 14_38252940-718c-4aa6-81a4-135398e53851_0018_PowerPointVL
14_8b559c37-0117-413e-921b-b853aeb6e210_0014_ProfessionalR_[ProfessionalAcadR,ProfessionalDemoR] 14_8b559c37-0117-413e-921b-b853aeb6e210_0014_ProfessionalR_[ProfessionalAcadR,ProfessionalDemoR]
14_725714d7-d58f-4d12-9fa8-35873c6f7215_003B_ProjectProR_[ProjectProMSDNR] 14_725714d7-d58f-4d12-9fa8-35873c6f7215_003B_ProjectProR_[ProjectProMSDNR]
@ -3327,7 +3523,7 @@ for %%# in (
14_2745e581-565a-4670-ae90-6bf7c57ffe43_0066_StarterR 14_2745e581-565a-4670-ae90-6bf7c57ffe43_0066_StarterR
14_66cad568-c2dc-459d-93ec-2f3cb967ee34_0057_VisioSIR_Prem[Pro,Std]Exception 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_36756cb8-8e69-4d11-9522-68899507cd6a_0057_VisioSIVL_Prem[Pro,Std]Exception
14_db3bbc9c-ce52-41d1-a46f-1a1d68059119_001B_WordR 14_db3bbc9c-ce52-41d1-a46f-1a1d68059119_001B_WordR_[HSWordR]
14_98d4050e-9c98-49bf-9be1-85e12eb3ab13_001B_WordVL 14_98d4050e-9c98-49bf-9be1-85e12eb3ab13_001B_WordVL
:: Office 2013 :: Office 2013
15_ab4d047b-97cf-4126-a69f-34df08e2f254_0015_AccessRetail 15_ab4d047b-97cf-4126-a69f-34df08e2f254_0015_AccessRetail
@ -3445,6 +3641,7 @@ if "%oVer%"=="%%A" (
reg query "%1\Registration\{%%B}" /v ProductCode %nul2% | find /i "-%%C-" %nul% && ( reg query "%1\Registration\{%%B}" /v ProductCode %nul2% | find /i "-%%C-" %nul% && (
reg query "%1\Common\InstalledPackages" %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 defined _oIds (set _oIds=!_oIds! %%D) else (set _oIds=%%D)
if /i 003D==%%C set SingleImage=1
) )
) )
) )
@ -3588,7 +3785,22 @@ 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 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 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 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 :: Office 2010
8ce7e872-188c-4b98-9d90-f8f90b7aad02_V7Y44-9T38C-R2VJK-666HK-T7%f%DDX__14_AccessVL 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 cee5d470-6e3b-4fcc-8c2b-d17428568a9f_H62QG-HXVKF-PP4HP-66KMR-CW%f%9BM__14_ExcelVL
@ -3635,7 +3847,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- 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- 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 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_-O365BusinessRetail-O365EduCloudRetail-O365HomePremRetail-O365ProPlusRetail-O365SmallBusPremRetail- 9caabccb-61b1-4b4b-8bec-d10a3c3ac2ce_HFTND-W9MK4-8B7MJ-B6C4G-XQ%f%BR2__16_MondoVolume_-O365AppsBasicRetail-O365BusinessRetail-O365EduCloudRetail-O365HomePremRetail-O365ProPlusRetail-O365SmallBusPremRetail-
436366de-5579-4f24-96db-3893e4400030_XYNTG-R96FY-369HX-YFPHY-F9%f%CPM__16_OneNoteFreeRetail_[Bypass] 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- 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- ec9d9265-9d1e-4ed0-838a-cdc20f2551a1_R69KK-NTPKF-7M3Q4-QYBHW-6M%f%T9B__16_OutlookVolume_-OutlookRetail-

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
@set masver=3.0 @set masver=3.4
@echo off @echo off
@ -60,6 +60,8 @@ exit /b
set "blank=" set "blank="
set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" 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 :: Check if Null service is working, it's important for the batch script
@ -134,9 +136,9 @@ goto dk_done
) )
if %winbuild% LSS 7600 ( if %winbuild% LSS 7600 (
%nceline% %eline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. echo This option is supported only for Windows 7/8/8.1/10/11 and their Server equivalents.
goto dk_done goto dk_done
) )
@ -188,16 +190,18 @@ goto dk_done
::pstst $ExecutionContext.SessionState.LanguageMode :pstst ::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) 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" ( if /i not "%tstresult%"=="FullLanguage" (
%eline% %eline%
echo: %tstresult% for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a)
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" echo Test 1 - %tstresult%
echo Test 2 - !tstresult2!
echo:
REM check LanguageMode REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting... echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes. echo If you have applied restrictions on Powershell then undo those changes.
echo: echo:
@ -227,7 +231,17 @@ goto dk_done
REM check antivirus and other errors REM check antivirus and other errors
echo PowerShell is not working properly. Aborting... echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
if /i "!tstresult2!"=="FullLanguage" (
echo:
echo Your antivirus software might be blocking the script, or PowerShell on your system might be corrupted.
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: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
@ -248,7 +262,9 @@ set terminal=
if defined terminal ( if defined terminal (
set lines=0 set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A 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= if !lines! GEQ 100 set terminal=
) )
@ -309,7 +325,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b)
) )
) )
@ -323,15 +339,6 @@ echo:
echo Initializing... echo Initializing...
echo: echo:
if not exist %SysPath%\sppsvc.exe (
%eline%
echo [%SysPath%\sppsvc.exe] file is missing. Aborting...
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::======================================================================================================================================== ::========================================================================================================================================
set spp=SoftwareLicensingProduct set spp=SoftwareLicensingProduct
@ -365,8 +372,7 @@ if %osedition%==0 (
%eline% %eline%
echo Failed to detect OS Edition. Aborting... echo Failed to detect OS Edition. Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot call :dk_color %Blue% "To fix this issue, activate Windows from the main menu."
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -415,6 +421,7 @@ _updch
_lang _lang
_clversion _clversion
_version _version
_AudienceData
_oIds _oIds
_c2rXml _c2rXml
_c2rExe _c2rExe
@ -544,7 +551,7 @@ goto :oe_edition
cls cls
call :ch_getinfo call :ch_getinfo
call :oe_tempcleanup call :oe_tempcleanup
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getlist\:.*';iex ($f[1])" %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getlist\:.*';& ([scriptblock]::Create($f[1]))"
:oe_editionchange :oe_editionchange
@ -618,7 +625,7 @@ cls
set suites= set suites=
echo %list% | find /i "Suites" %nul1% && ( echo %list% | find /i "Suites" %nul1% && (
set suites=1 set suites=1
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getappnames\:.*';iex ($f[1])" %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getappnames\:.*';& ([scriptblock]::Create($f[1]))"
if not exist %SystemRoot%\Temp\getAppIds.txt ( if not exist %SystemRoot%\Temp\getAppIds.txt (
%eline% %eline%
echo Failed to generate available apps list. echo Failed to generate available apps list.
@ -802,8 +809,40 @@ set errorcode=%errorlevel%
timeout /t 10 %nul% timeout /t 10 %nul%
echo: echo:
set suggestchannel=
if %errorcode% EQU 0 ( if %errorcode% EQU 0 (
call :dk_color %Gray% "Now run the Office activation option from the main menu." 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."
) else ( ) else (
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
@ -980,6 +1019,12 @@ echo Installed Office editions: %_oIds%
echo Unsupported Office edition is installed on your Windows build version %winbuild%. echo Unsupported Office edition is installed on your Windows build version %winbuild%.
goto :oe_goback 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
)
) )
::=============== ::===============
@ -988,49 +1033,52 @@ set inpt=
set counter=0 set counter=0
set verified=0 set verified=0
set targetFFN= set targetFFN=
set bypassFFN=
set targetchannel= set targetchannel=
%line% %line%
echo: echo:
call :dk_color %Gray% "Installed update channel: %_AudienceData%, %_version%, Client: %_clversion%" call :dk_color %Gray% "Installed update channel: %_AudienceData%, %_version%, Client: %_clversion%"
call :dk_color %Gray% "Unsupported update channels are excluded from this list." call :dk_color %Gray% "Installed Office editions: %_oIds%"
%line% %line%
echo: echo:
for %%# in ( for %%# in (
"5440FD1F-7ECB-4221-8110-145EFAA6372F_Insider Fast [Beta] - Insiders::DevMain" "5440fd1f-7ecb-4221-8110-145efaa6372f_Insider Fast [Beta] - Insiders::DevMain -"
"64256AFE-F5D9-4F86-8936-8840A6A4F5BE_Monthly Preview - Insiders::CC" "64256afe-f5d9-4f86-8936-8840a6a4f5be_Monthly Preview - Insiders::CC -"
"492350F6-3A01-4F97-B9C0-C7C6DDF67D60_Monthly [Current] - Production::CC" "492350f6-3a01-4f97-b9c0-c7c6ddf67d60_Monthly [Current] - Production::CC -"
"55336B82-A18D-4DD6-B5F6-9E5095C314A6_Monthly Enterprise - Production::MEC" "55336b82-a18d-4dd6-b5f6-9e5095c314a6_Monthly Enterprise - Production::MEC -"
"B8F9B850-328D-4355-9145-C59439A0C4CF_Semi Annual Preview - Insiders::FRDC" "b8f9b850-328d-4355-9145-c59439a0c4cf_Semi Annual Preview - Insiders::FRDC -"
"7FFBC6BF-BC32-4F92-8982-F9DD17FD3114_Semi Annual - Production::DC" "7ffbc6bf-bc32-4f92-8982-f9dd17fd3114_Semi Annual - Production::DC -"
"EA4A4090-DE26-49D7-93C1-91BFF9E53FC3_DevMain Channel - Dogfood::DevMain" "ea4a4090-de26-49d7-93c1-91bff9e53fc3_DevMain Channel - Dogfood::DevMain -"
"B61285DD-D9F7-41F2-9757-8F61CBA4E9C8_Microsoft Elite - Microsoft::DevMain" "b61285dd-d9f7-41f2-9757-8f61cba4e9c8_Microsoft Elite - Microsoft::DevMain -"
"F2E724C1-748F-4B47-8FB8-8E0D210E9208_Perpetual2019 VL - Production::LTSC" "f2e724c1-748f-4b47-8fb8-8e0d210e9208_Perpetual2019 VL - Production::LTSC -"
"1D2D2EA6-1680-4C56-AC58-A441C8C24FF9_Microsoft2019 VL - Microsoft::LTSC" "1d2d2ea6-1680-4c56-ac58-a441c8c24ff9_Microsoft2019 VL - Microsoft::LTSC -"
"5030841D-C919-4594-8D2D-84AE4F96E58E_Perpetual2021 VL - Production::LTSC2021" "5030841d-c919-4594-8d2d-84ae4f96e58e_Perpetual2021 VL - Production::LTSC2021 -"
"86752282-5841-4120-AC80-DB03AE6B5FDB_Microsoft2021 VL - Microsoft::LTSC2021" "86752282-5841-4120-ac80-db03ae6b5fdb_Microsoft2021 VL - Microsoft::LTSC2021 -"
"7983BAC0-E531-40CF-BE00-FD24FE66619C_Perpetual2024 VL - Production::LTSC2024" "7983bac0-e531-40cf-be00-fd24fe66619c_Perpetual2024 VL - Production::LTSC2024 -"
"C02D8FE6-5242-4DA8-972F-82EE55E00671_Microsoft2024 VL - Microsoft::LTSC2024" "c02d8fe6-5242-4da8-972f-82ee55e00671_Microsoft2024 VL - Microsoft::LTSC2024 -"
) do ( ) do (
for /f "tokens=1-2 delims=_" %%A in ("%%~#") do ( for /f "tokens=1-2 delims=_" %%A in ("%%~#") do (
set bypass=
set supported= set supported=
if %winbuild% LSS 10240 (echo %%B | findstr /i "LTSC DevMain" %nul% || set supported=1) else (set supported=1) if %winbuild% LSS 10240 (echo %%B | findstr /i "LTSC DevMain" %nul% || set supported=1) else (set supported=1)
if %winbuild% GEQ 10240 ( if %winbuild% GEQ 10240 (
if defined ltsc19 echo %%B | find /i "2019 VL" %nul% || set supported= if defined ltsc19 echo %%B | find /i "2019 VL" %nul% || set bypass=1
if defined ltsc21 echo %%B | find /i "2021 VL" %nul% || set supported= if defined ltsc21 echo %%B | find /i "2021 VL" %nul% || set bypass=1
if defined ltsc24 echo %%B | find /i "2024 VL" %nul% || set supported= if defined ltsc24 echo %%B | find /i "2024 VL" %nul% || set bypass=1
if not defined ltscfound echo %%B | find /i "LTSC" %nul% && set supported= if not defined ltscfound echo %%B | find /i "LTSC" %nul% && set bypass=1
) )
if defined supported ( if defined supported (
set /a counter+=1 set /a counter+=1
if !counter! LSS 10 ( if !counter! LSS 10 (
echo [!counter!] %%B if defined bypass (echo [!counter!] %%B Unofficial change method will be used) else (echo [!counter!] %%B)
) else ( ) else (
echo [!counter!] %%B if defined bypass (echo [!counter!] %%B Unofficial change method will be used) else (echo [!counter!] %%B)
) )
set targetFFN!counter!=%%A set targetFFN!counter!=%%A
set targetchannel!counter!=%%B set targetchannel!counter!=%%B
if defined bypass set bypassFFN=!bypassFFN!%%A
) )
) )
) )
@ -1044,7 +1092,7 @@ call :dk_color %_Green% "Enter an option number using your keyboard and press En
set /p inpt= set /p inpt=
if "%inpt%"=="" goto :oe_changeupdchnl if "%inpt%"=="" goto :oe_changeupdchnl
if "%inpt%"=="0" goto :oemenu if "%inpt%"=="0" goto :oemenu
if /i "%inpt%"=="R" start https://learn.microsoft.com/microsoft-365-apps/updates/overview-update-channels & goto :oe_changeupdchnl if /i "%inpt%"=="R" start https://learn.microsoft.com/en-us/microsoft-365-apps/updates/overview-update-channels & goto :oe_changeupdchnl
for /l %%i in (1,1,%counter%) do (if "%inpt%"=="%%i" set verified=1) for /l %%i in (1,1,%counter%) do (if "%inpt%"=="%%i" set verified=1)
set targetFFN=!targetFFN%inpt%! set targetFFN=!targetFFN%inpt%!
set targetchannel=!targetchannel%inpt%! set targetchannel=!targetchannel%inpt%!
@ -1058,18 +1106,136 @@ 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 :: Get build number for the target FFN, using build number with OfficeC2RClient.exe command to trigger updates provides accurate results
set build= set build=
for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':getbuild\:.*';iex ($f[1])" %nul6%') do (set build=%%a) for /f "delims=" %%a in ('%psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':getbuild\:.*';& ([scriptblock]::Create($f[1]))" %nul6%') do (set build=%%a)
echo "%build%" | find /i "16." %nul% || set build= 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"
set "c2rcommand="%_c2rExe%" platform=%_oArch% culture=%_lang% productstoadd=%_firstoId%.16_%_lang%_x-none 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 :: 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://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 :: 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:
echo Cleaning Office update registry keys... echo Cleaning Office update registry keys...
echo Adding new update channel to 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 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 %nul% reg add %o16c2r_reg%\Configuration /v UpdateChannel /t REG_SZ /d "https://officecdn.microsoft.com/pr/%targetFFN%" /f
@ -1086,42 +1252,7 @@ echo Adding new update channel to registry keys...
%nul% reg delete HKLM\SOFTWARE\Policies\Microsoft\cloud\office\16.0\Common\officeupdate /f /reg:32 %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 %nul% reg delete HKCU\Software\Policies\Microsoft\cloud\office\16.0\Common\officeupdate /f
if not defined build ( exit /b
if %winbuild% GEQ 9200 call :dk_color %Gray% "Failed to detect build number for the target FFN."
set "updcommand="%_c2rCexe%" /update user"
) else (
set "updcommand="%_c2rCexe%" /update user updatetoversion=%build%"
)
echo Running the below command to trigger updates...
echo:
echo %updcommand%
%updcommand%
echo:
echo Check this webpage for help - %mas%troubleshoot
goto :oe_goback
::========================================================================================================================================
:oe_goback
call :oe_tempcleanup
echo:
if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. "
call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N
if !errorlevel!==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
::======================================================================================================================================== ::========================================================================================================================================
@ -1144,6 +1275,7 @@ set _oRoot=
set _oArch= set _oArch=
set _updch= set _updch=
set _oIds= set _oIds=
set _firstoId=
set _lang= set _lang=
set _cfolder= set _cfolder=
set _version= set _version=
@ -1174,9 +1306,13 @@ for /f "tokens=%_tok% delims=\" %%a in ('reg query "%o16c2r_reg%\ProductReleaseI
if defined _oIds (set "_oIds=!_oIds! %%a") else (set "_oIds=%%a") if defined _oIds (set "_oIds=!_oIds! %%a") else (set "_oIds=%%a")
) )
set _oIds=%_oIds:.16=% 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 verchk=0
set clverchk=0
for /f "tokens=3 delims=." %%a in ("%_version%") do set "verchk=%%a" 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" if exist "%_oRoot%\Licenses16\c2rpridslicensefiles_auto.xml" set "_c2rXml=%_oRoot%\Licenses16\c2rpridslicensefiles_auto.xml"
@ -1192,16 +1328,13 @@ if exist "%_cfolder%\OfficeC2RClient.exe" (
set "_c2rCexe=%_cfolder%\OfficeC2RClient.exe" set "_c2rCexe=%_cfolder%\OfficeC2RClient.exe"
) )
set "audidata4=%_AudienceData:~-4%" :: Check LTSC version files
if /i "%audidata4%"=="LTSC" set ltsc19=LTSC for /f "skip=2 tokens=2*" %%a in ('"reg query %o16c2r_reg%\ProductReleaseIDs\%_actconfig%" /s %nul6%') do (
echo %_clversion% %_version% | findstr "16.0.103 16.0.104 16.0.105" %nul% && set ltsc19=LTSC 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
if /i "%audidata4%"=="2021" set ltsc21=LTSC2021 echo "%%b" %nul2% | findstr "16.0.17932" %nul% && set ltsc24=LTSC2024
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 if not "%ltsc19%%ltsc21%%ltsc24%"=="" set ltscfound=1
@ -1352,10 +1485,16 @@ if ($appIdsList.Count -gt 0) {
:dk_setvar :dk_setvar
set psc=powershell.exe -nop -c set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
@ -1402,6 +1541,7 @@ exit /b
:dk_ckeckwmic :dk_ckeckwmic
if %winbuild% LSS 9200 (set _wmic=1&exit /b)
set _wmic=0 set _wmic=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1 cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1
@ -1412,16 +1552,16 @@ exit /b
:dk_sppissue :dk_sppissue
sc start sppsvc %nul% sc start %_slser% %nul%
set spperror=%errorlevel% set spperror=%errorlevel%
if %spperror% NEQ 1056 if %spperror% NEQ 0 ( if %spperror% NEQ 1056 if %spperror% NEQ 0 (
%eline% %eline%
echo sc start sppsvc [Error Code: %spperror%] echo sc start %_slser% [Error Code: %spperror%]
) )
echo: echo:
%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc 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 '%_slser% is not working correctly. Check this webpage for help - %mas%troubleshoot'}"
exit /b exit /b
:: Common lines used in PowerShell reflection code :: Common lines used in PowerShell reflection code
@ -1439,8 +1579,10 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -1448,8 +1590,10 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b
@ -1464,7 +1608,8 @@ if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " 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" call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==2 exit /b
if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#))
) )
if defined terminal ( if defined terminal (

View File

@ -1,4 +1,4 @@
@set masver=3.0 @set masver=3.4
@echo off @echo off
@ -65,6 +65,8 @@ exit /b
set "blank=" set "blank="
set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" 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 :: Check if Null service is working, it's important for the batch script
@ -139,9 +141,9 @@ goto dk_done
) )
if %winbuild% LSS 7600 ( if %winbuild% LSS 7600 (
%nceline% %eline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. echo This option is supported only for Windows 7/8/8.1/10/11 and their Server equivalents.
goto dk_done goto dk_done
) )
@ -193,16 +195,18 @@ goto dk_done
::pstst $ExecutionContext.SessionState.LanguageMode :pstst ::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) 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" ( if /i not "%tstresult%"=="FullLanguage" (
%eline% %eline%
echo: %tstresult% for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a)
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" echo Test 1 - %tstresult%
echo Test 2 - !tstresult2!
echo:
REM check LanguageMode REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting... echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes. echo If you have applied restrictions on Powershell then undo those changes.
echo: echo:
@ -232,7 +236,17 @@ goto dk_done
REM check antivirus and other errors REM check antivirus and other errors
echo PowerShell is not working properly. Aborting... echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
if /i "!tstresult2!"=="FullLanguage" (
echo:
echo Your antivirus software might be blocking the script, or PowerShell on your system might be corrupted.
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: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
@ -253,7 +267,9 @@ set terminal=
if defined terminal ( if defined terminal (
set lines=0 set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A 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= if !lines! GEQ 100 set terminal=
) )
@ -314,7 +330,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b)
) )
) )
@ -354,6 +370,9 @@ if not exist %SysPath%\%%# (
%eline% %eline%
echo [%SysPath%\%%#] file is missing, aborting... echo [%SysPath%\%%#] file is missing, aborting...
echo: echo:
call :dk_color %Blue% "Go back to Main Menu, select Troubleshoot and run DISM Restore and SFC Scan options."
call :dk_color %Blue% "After that, restart system and try activation again."
echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
@ -387,8 +406,7 @@ if not defined allapps (
%eline% %eline%
echo Failed to find activation IDs. Aborting... echo Failed to find activation IDs. Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot call :dk_color %Blue% "To fix this issue, activate Windows from the main menu."
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -410,8 +428,7 @@ if not defined osedition (
%eline% %eline%
echo Failed to detect OS edition, aborting... echo Failed to detect OS edition, aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot call :dk_color %Blue% "To fix this issue, activate Windows from the main menu."
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -434,7 +451,7 @@ set _ntarget=
set _wtarget= 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% 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=[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=[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% GEQ 10240 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( if %winbuild% GEQ 10240 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
if %winbuild% GEQ 17063 call :ced_edilist if %winbuild% GEQ 17063 call :ced_edilist
@ -640,7 +657,7 @@ echo:
call :ced_prep call :ced_prep
if defined preperror goto dk_done if defined preperror goto dk_done
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':dismapi\:.*';& ([ScriptBlock]::Create($f[1])) %targetedition% %key%" %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':dismapi\:.*';& ([ScriptBlock]::Create($f[1])) %targetedition% %key%"
call :ced_postprep call :ced_postprep
) )
%line% %line%
@ -678,7 +695,7 @@ call :ced_prep
if defined preperror goto dk_done if defined preperror goto dk_done
if %_stg%==0 (set stage=) else (set stage=-StageCurrent) if %_stg%==0 (set stage=) else (set stage=-StageCurrent)
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -SetEdition %targetedition% %stage%" %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -SetEdition %targetedition% %stage%"
call :ced_postprep call :ced_postprep
%line% %line%
@ -792,7 +809,7 @@ exit /b
:: https://stackoverflow.com/a/46268232 :: https://stackoverflow.com/a/46268232
set "ddf="%SystemRoot%\Temp\ddf"" set "ddf="%SystemRoot%\Temp\%Random%%Random%%Random%%Random%""
%nul% del /q /f %ddf% %nul% del /q /f %ddf%
echo/.New Cabinet>%ddf% echo/.New Cabinet>%ddf%
echo/.set Cabinet=ON>>%ddf% echo/.set Cabinet=ON>>%ddf%
@ -824,10 +841,16 @@ exit /b
:dk_setvar :dk_setvar
set psc=powershell.exe -nop -c set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
@ -901,6 +924,7 @@ exit /b
:dk_ckeckwmic :dk_ckeckwmic
if %winbuild% LSS 9200 (set _wmic=1&exit /b)
set _wmic=0 set _wmic=0
for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" ( for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1 cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" %nul2% | find /i "computersystem" %nul1% && set _wmic=1
@ -911,16 +935,16 @@ exit /b
:dk_sppissue :dk_sppissue
sc start sppsvc %nul% sc start %_slser% %nul%
set spperror=%errorlevel% set spperror=%errorlevel%
if %spperror% NEQ 1056 if %spperror% NEQ 0 ( if %spperror% NEQ 1056 if %spperror% NEQ 0 (
%eline% %eline%
echo sc start sppsvc [Error Code: %spperror%] echo sc start %_slser% [Error Code: %spperror%]
) )
echo: echo:
%psc% "$job = Start-Job { (Get-WmiObject -Query 'SELECT * FROM %sps%').Version }; if (-not (Wait-Job $job -Timeout 30)) {write-host 'sppsvc 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 '%_slser% is not working correctly. Check this webpage for help - %mas%troubleshoot'}"
exit /b exit /b
:: Common lines used in PowerShell reflection code :: Common lines used in PowerShell reflection code
@ -1018,8 +1042,10 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -1027,8 +1053,10 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b
@ -1043,7 +1071,8 @@ if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " 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" call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==2 exit /b
if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#))
) )
if defined terminal ( if defined terminal (

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
@set masver=3.0 @set masver=3.4
@echo off @echo off
@ -60,6 +60,8 @@ exit /b
set "blank=" set "blank="
set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" 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 :: Check if Null service is working, it's important for the batch script
@ -129,13 +131,30 @@ echo:
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto done2
) )
if %winbuild% LSS 7600 ( if %winbuild% LSS 6001 (
%nceline% %nceline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. 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
goto done2 goto done2
) )
@ -187,16 +206,18 @@ goto done2
::pstst $ExecutionContext.SessionState.LanguageMode :pstst ::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) 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" ( if /i not "%tstresult%"=="FullLanguage" (
%eline% %eline%
echo: %tstresult% for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a)
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" echo Test 1 - %tstresult%
echo Test 2 - !tstresult2!
echo:
REM check LanguageMode REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting... echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes. echo If you have applied restrictions on Powershell then undo those changes.
echo: echo:
@ -226,7 +247,17 @@ goto done2
REM check antivirus and other errors REM check antivirus and other errors
echo PowerShell is not working properly. Aborting... echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
if /i "!tstresult2!"=="FullLanguage" (
echo:
echo Your antivirus software might be blocking the script, or PowerShell on your system might be corrupted.
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: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
@ -247,7 +278,9 @@ set terminal=
if defined terminal ( if defined terminal (
set lines=0 set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A 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= if !lines! GEQ 100 set terminal=
) )
@ -308,7 +341,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b)
) )
) )
@ -714,7 +747,8 @@ if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " 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" call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==2 exit /b
if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#))
) )
if defined terminal ( if defined terminal (
@ -732,10 +766,16 @@ exit /b
:dk_setvar :dk_setvar
set psc=powershell.exe -nop -c set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)
@ -782,7 +822,7 @@ exit /b
:export :export
%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);" %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);"
exit /b exit /b
::======================================================================================================================================== ::========================================================================================================================================
@ -791,8 +831,10 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m echo %esc%[%~1%~2%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' %psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
) )
exit /b exit /b
@ -800,8 +842,10 @@ exit /b
if %_NCS% EQU 1 ( if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else ( ) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6' %psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
) )
exit /b exit /b

View File

@ -1,4 +1,4 @@
@set masver=3.0 @set masver=3.4
@echo off @echo off
@ -60,6 +60,8 @@ exit /b
set "blank=" set "blank="
set "mas=ht%blank%tps%blank%://mass%blank%grave.dev/" 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 :: Check if Null service is working, it's important for the batch script
@ -133,10 +135,27 @@ call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%trouble
goto dk_done goto dk_done
) )
if %winbuild% LSS 7600 ( if %winbuild% LSS 6001 (
%nceline% %nceline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo Project is supported only for Windows 7/8/8.1/10/11 and their Server equivalents. 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
goto dk_done goto dk_done
) )
@ -188,16 +207,18 @@ goto dk_done
::pstst $ExecutionContext.SessionState.LanguageMode :pstst ::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) 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" ( if /i not "%tstresult%"=="FullLanguage" (
%eline% %eline%
echo: %tstresult% for /f "delims=" %%a in ('%psc% "$ExecutionContext.SessionState.LanguageMode" %nul6%') do (set tstresult2=%%a)
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" echo Test 1 - %tstresult%
echo Test 2 - !tstresult2!
echo:
REM check LanguageMode REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( echo: !tstresult2! | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting... echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes. echo If you have applied restrictions on Powershell then undo those changes.
echo: echo:
@ -227,7 +248,17 @@ goto dk_done
REM check antivirus and other errors REM check antivirus and other errors
echo PowerShell is not working properly. Aborting... echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
if /i "!tstresult2!"=="FullLanguage" (
echo:
echo Your antivirus software might be blocking the script, or PowerShell on your system might be corrupted.
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: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
@ -248,7 +279,9 @@ set terminal=
if defined terminal ( if defined terminal (
set lines=0 set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A 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= if !lines! GEQ 100 set terminal=
) )
@ -309,7 +342,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start %mas% & exit /b) if !errorlevel!==1 (start %selfgit% & start %github% & start %mas% & exit /b)
) )
) )
@ -370,7 +403,7 @@ if %_erl%==5 goto:retokens
if %_erl%==4 goto:fixwmi if %_erl%==4 goto:fixwmi
if %_erl%==3 goto:sfcscan if %_erl%==3 goto:sfcscan
if %_erl%==2 goto:dism_rest if %_erl%==2 goto:dism_rest
if %_erl%==1 start %mas%troubleshoot.html &goto at_menu if %_erl%==1 (start %selfgit% & start %github% & start %mas%troubleshoot & goto at_menu)
goto :at_menu goto :at_menu
::======================================================================================================================================== ::========================================================================================================================================
@ -515,6 +548,13 @@ mode 125, 32
) )
title Fix Licensing ^(ClipSVC ^+ SPP ^+ OSPP^) title Fix Licensing ^(ClipSVC ^+ SPP ^+ OSPP^)
if %winbuild% EQU 6001 (
%eline%
echo This option is not supported on Windows Vista SP1.
echo Upgrade to Windows Vista SP2.
goto :at_back
)
echo: echo:
echo %line% echo %line%
echo: echo:
@ -531,7 +571,7 @@ echo - Clear ClipSVC, SPP and OSPP licenses.
echo - Fix permissions of SPP tokens folder and registries. echo - Fix permissions of SPP tokens folder and registries.
echo - Trigger the repair option for Office. echo - Trigger the repair option for Office.
echo: echo:
call :dk_color2 %_White% " - " %Red% "Apply this option only when it is necessary." call :dk_color2 %_White% " - " %Blue% "Apply this option only when it is necessary."
echo: echo:
echo %line% echo %line%
echo: echo:
@ -682,7 +722,7 @@ echo Checking SPP permission related issues...
call :checkperms call :checkperms
if defined permerror ( if defined permerror (
call :dk_color %Red% "[!permerror!]" call :dk_color %Red% "[!permerror!]"
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':fixsppperms\:.*';iex ($f[1])" %nul% %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':fixsppperms\:.*';& ([scriptblock]::Create($f[1]))" %nul%
call :checkperms call :checkperms
if defined permerror ( if defined permerror (
call :dk_color %Red% "[!permerror!] [Failed To Fix]" call :dk_color %Red% "[!permerror!] [Failed To Fix]"
@ -695,21 +735,21 @@ echo [No Error Found]
) )
echo: echo:
echo Stopping sppsvc service... echo Stopping %_slser% service...
%psc% Stop-Service sppsvc -force %nul% %psc% Stop-Service %_slser% -force %nul%
set w= set w=
set _sppint= set _sppint=
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)) 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))
if defined _sppint ( if defined _sppint (
echo: echo:
echo Removing SPP IFEO registry keys... echo Removing SPP IFEO registry keys...
for %%# in (SppE%w%xtComObj.exe sppsvc.exe) 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 %_slexe%) do (reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima%w%ge File Execu%w%tion Options\%%#" /f %nul%)
) )
if %winbuild% LSS 9200 ( if %winbuild% LSS 9200 if not defined _vis (
REM Fix issues caused by Update KB971033 in Windows 7 REM Fix issues caused by Update KB971033 in Windows 7
REM https://support.microsoft.com/help/4487266 REM https://support.microsoft.com/en-us/help/4487266
echo: echo:
echo Checking Update KB971033... echo Checking Update KB971033...
%psc% "if (Get-Hotfix -Id KB971033 -ErrorAction SilentlyContinue) {Exit 3}" %nul% %psc% "if (Get-Hotfix -Id KB971033 -ErrorAction SilentlyContinue) {Exit 3}" %nul%
@ -726,6 +766,7 @@ del /f /q %SysPath%\7B296FB0-376B-497e-B012-9C450E1B7327-*.C7483456-A289-439d-81
:: Delete registry keys that are not deleted by activation scripts :: Delete registry keys that are not deleted by activation scripts
if not defined _vis (
echo: echo:
echo Cleaning some licensing-related registry keys... echo Cleaning some licensing-related registry keys...
%nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "ServiceSessionId" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "ServiceSessionId" /f
@ -733,6 +774,7 @@ echo Cleaning some licensing-related registry keys...
%nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "PolicyValuesArray" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "PolicyValuesArray" /f
%nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f
%nul% reg delete "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform\data" /f %nul% reg delete "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform\data" /f
)
echo: echo:
call :scandat delete call :scandat delete
@ -744,10 +786,14 @@ call :dk_color %Red% "Failed to delete .dat files."
echo: echo:
) )
if defined _vis (
%psc% Start-Service %_slser% %nul%
)
echo: echo:
echo Reinstalling system licenses... echo Reinstalling system licenses...
%psc% "Stop-Service sppsvc -force; $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% %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=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($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%
if %errorlevel% EQU 0 ( if %errorlevel% EQU 0 (
echo [Successful] echo [Successful]
) else ( ) else (
@ -763,7 +809,7 @@ call :dk_color %Red% "Failed to rebuild tokens.dat file."
echo tokens.dat file was rebuilt successfully. echo tokens.dat file was rebuilt successfully.
) )
if %winbuild% LSS 9200 ( if %winbuild% LSS 9200 if not defined _vis (
sc config sppuinotify start= demand sc config sppuinotify start= demand
) )
@ -844,12 +890,12 @@ set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office
reg query %_68%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_68=Office 14.0 C2R x86/x64" & set "c2r14repair68=") reg query %_68%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_68=Office 14.0 C2R x86/x64" & set "c2r14repair68=")
reg query %_86%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_86=Office 14.0 C2R x86" & set "c2r14repair86=") reg query %_86%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_86=Office 14.0 C2R x86" & set "c2r14repair86=")
for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_86=Office 14.0 MSI x86" & call :getrepairsetup msi14repair86 14) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*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\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 %_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\EntityPicker.dll" (set "msi15_86=Office 15.0 MSI x86" & call :getrepairsetup msi15repair86 15) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*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\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 %_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\EntityPicker.dll" (set "msi16_86=Office 16.0 MSI x86" & call :getrepairsetup msi16repair86 16) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\*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\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 %_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%\15.0\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (set "c2r15_86=Office 15.0 C2R x86" & call :getc2rrepair c2r15repair86 integratedoffice.exe) for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\ClickToRun /v InstallPath" %nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (set "c2r15_86=Office 15.0 C2R x86" & 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 %_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)
@ -1148,7 +1194,7 @@ goto :at_menu
:: https://stackoverflow.com/a/46268232 :: https://stackoverflow.com/a/46268232
set "ddf="%SystemRoot%\Temp\ddf"" set "ddf="%SystemRoot%\Temp\%Random%%Random%%Random%%Random%""
%nul% del /q /f %ddf% %nul% del /q /f %ddf%
echo/.New Cabinet>%ddf% echo/.New Cabinet>%ddf%
echo/.set Cabinet=ON>>%ddf% echo/.set Cabinet=ON>>%ddf%
@ -1200,7 +1246,7 @@ set "permerror=Error Found In SPP Registries"
) )
) )
REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application REM https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application
if not defined permerror ( if not defined permerror (
reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && ( reg query "HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion" %nul% && (
@ -1246,7 +1292,7 @@ if ($env:permerror -eq 'Error Found In SPP Registries') {
} }
# Fix perms for SPP in HKU\S-1-5-20 # Fix perms for SPP in HKU\S-1-5-20
# https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application # https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application
if ($env:permerror -ne 'Error Found In S-1-5-20 SPP') { if ($env:permerror -ne 'Error Found In S-1-5-20 SPP') {
exit exit
@ -1329,13 +1375,13 @@ function InstallLicenseArr($Str) {
ForEach ($x in $a) {InstallLicenseFile "$x"} ForEach ($x in $a) {InstallLicenseFile "$x"}
} }
function InstallLicenseDir($Loc) { function InstallLicenseDir($Loc) {
dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"} Get-ChildItem $Loc -Recurse -Filter *.xrm-ms | ForEach-Object {InstallLicenseFile $_.FullName}
} }
function ReinstallLicenses() { function ReinstallLicenses() {
$Oem = "$env:SysPath\oem" $Paths = @("$env:SysPath\oem", "$env:SysPath\licensing", "$env:SysPath\spp\tokens")
$Spp = "$env:SysPath\spp\tokens" foreach ($Path in $Paths) {
InstallLicenseDir "$Spp" if (Test-Path $Path) { InstallLicenseDir "$Path" }
If (Test-Path $Oem) {InstallLicenseDir "$Oem"} }
} }
:xrm: :xrm:
@ -1349,6 +1395,7 @@ for %%# in (
%SysPath%\spp\store\ %SysPath%\spp\store\
%SysPath%\spp\store\2.0\ %SysPath%\spp\store\2.0\
%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\ %Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\
%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareLicensing\
) do ( ) do (
if %1==check ( if %1==check (
@ -1392,7 +1439,7 @@ exit /b
:regownstart :regownstart
%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':regown\:.*';iex ($f[1]);" %psc% "$f=[System.IO.File]::ReadAllText('!_batp!') -split ':regown\:.*';& ([scriptblock]::Create($f[1]));"
exit /b exit /b
:: Below code takes ownership of a volatile registry key and deletes it :: Below code takes ownership of a volatile registry key and deletes it
@ -1424,14 +1471,41 @@ $key.SetAccessControl($acl)
::======================================================================================================================================== ::========================================================================================================================================
:dk_color
if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m
) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3'
) else if not exist %ps% (
echo %~3
)
exit /b
:dk_color2
if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else if exist %ps% (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
) else if not exist %ps% (
echo %~3 %~6
)
exit /b
::========================================================================================================================================
:dk_done :dk_done
echo: echo:
if %_unattended%==1 timeout /t 2 & exit /b
if defined fixes ( if defined fixes (
call :dk_color %White% "Follow ALL the ABOVE blue lines. " call :dk_color %White% "Follow ALL the ABOVE blue lines. "
call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore" call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#)) if !errorlevel!==2 exit /b
if !errorlevel!==1 (start %selfgit% & start %github% & for %%# in (%fixes%) do (start %%#))
) )
if defined terminal ( if defined terminal (
@ -1441,26 +1515,7 @@ choice /c 0 /n
call :dk_color %_Yellow% "Press any key to %_exitmsg%..." call :dk_color %_Yellow% "Press any key to %_exitmsg%..."
pause %nul1% pause %nul1%
) )
exit /b
::========================================================================================================================================
:dk_color
if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[0m
) else (
%psc% write-host -back '%1' -fore '%2' '%3'
)
exit /b
:dk_color2
if %_NCS% EQU 1 (
echo %esc%[%~1%~2%esc%[%~3%~4%esc%[0m
) else (
%psc% write-host -back '%1' -fore '%2' '%3' -NoNewline; write-host -back '%4' -fore '%5' '%6'
)
exit /b exit /b
::======================================================================================================================================== ::========================================================================================================================================
@ -1469,10 +1524,16 @@ exit /b
:dk_setvar :dk_setvar
set psc=powershell.exe -nop -c set ps=%SysPath%\WindowsPowerShell\v1.0\powershell.exe
set psc=%ps% -nop -c
set winbuild=1 set winbuild=1
for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G for /f "tokens=6 delims=[]. " %%G in ('ver') do set winbuild=%%G
set _slexe=sppsvc.exe& set _slser=sppsvc
if %winbuild% LEQ 6300 (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %winbuild% LSS 7600 if exist "%SysPath%\SLsvc.exe" (set _slexe=SLsvc.exe& set _slser=SLsvc)
if %_slexe%==SLsvc.exe set _vis=1
set _NCS=1 set _NCS=1
if %winbuild% LSS 10586 set _NCS=0 if %winbuild% LSS 10586 set _NCS=0
if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0) if %winbuild% GEQ 10586 reg query "HKCU\Console" /v ForceV2 %nul2% | find /i "0x0" %nul1% && (set _NCS=0)

225
README.md
View File

@ -1,109 +1,116 @@
<p align="center"><img src="https://massgrave.dev/img/logo_small.png" alt="MAS Logo"></p> <p align="center"><img src="https://massgrave.dev/img/logo_small.png" alt="MAS Logo"></p>
<h1 align="center">Microsoft Activation Scripts (MAS)</h1> <h1 align="center">Microsoft Activation Scripts (MAS)</h1>
<p align="center">Open-source Windows and Office activator featuring HWID, Ohook, TSforge, KMS38, and Online KMS activation methods, along with advanced troubleshooting.</p> <p align="center">Open-source Windows and Office activator featuring HWID, Ohook, TSforge, KMS38, and Online KMS activation methods, along with advanced troubleshooting.</p>
<hr> <hr>
## Download / How to use it? ## How to Activate Windows / Office?
### Method 1 - PowerShell (Windows 8 and later) ❤️ ### 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. 1. **Open PowerShell**
2. Copy and paste the code below and press enter To do that, press the Windows key + X, then select PowerShell or Terminal.
```
irm https://get.activated.win | iex 2. **Copy and paste the code below, then press enter.**
``` ```
Alternatively, you can use the following (It will be deprecated in the future.) irm https://get.activated.win | iex
``` ```
irm https://massgrave.dev/get | iex Alternatively, you can use the following (this will be deprecated in the future):
``` ```
3. You will see the activation options. Choose (1) HWID for Windows activation. Choose (2) Ohook for Office activation. irm https://massgrave.dev/get | iex
4. That's all. ```
--- 3. You will see the activation options. Choose the activation options highlighted in green.
### Method 2 - Traditional (Windows 7 and later) 4. That's all
<details> ---
<summary>Click here for info</summary>
### Method 2 - Traditional (Windows Vista and later)
1. Download the file using the links provided below.
`https://github.com/massgravel/Microsoft-Activation-Scripts/archive/refs/heads/master.zip` <details>
or <summary>Click here to view</summary>
`https://git.activated.win/massgrave/Microsoft-Activation-Scripts/archive/master.zip`
2. Right-click on the downloaded zip file and extract 1. Download the file using one of the links below:
3. In the extracted folder, find the folder named `All-In-One-Version` `https://github.com/massgravel/Microsoft-Activation-Scripts/archive/refs/heads/master.zip`
4. Run the file named `MAS_AIO.cmd` or
5. You will see the activation options, follow the on-screen instructions. `https://git.activated.win/massgrave/Microsoft-Activation-Scripts/archive/master.zip`
6. That's all. 2. Right-click on the downloaded zip file and extract it.
3. In the extracted folder, find the folder named `All-In-One-Version`.
</details> 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 ❓ </details>
- 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). - 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]
> ### Not working ❓
> - 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. - If you are **unable to launch MAS** using the PowerShell method, please refer to **Method 2** listed above.
> - Be cautious, as some spread malware disguised as MAS by using different URLs in the IRM command. - 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).
---
---
To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches).
> [!NOTE]
``` >
Latest Version: 3.0 > - The IRM command in PowerShell downloads a script from a specified URL, and the IEX command executes it.
Release date: 14-Feb-2025 > - 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.
### [Troubleshooting / Help](https://massgrave.dev/troubleshoot) ---
### [Download Original Windows & Office](https://massgrave.dev/genuine-installation-media)
### Homepage - [https://massgrave.dev/](https://massgrave.dev/) ```
Latest Version: 3.4
<div align="center"> Release date: 3-June-2025
```
[![1.1]][1]
[![1.2]][2] ### [Troubleshooting / Help](https://massgrave.dev/troubleshoot)
[![1.3]][3] ### [Download Original Windows & Office](https://massgrave.dev/genuine-installation-media)
### Homepage - [https://massgrave.dev/](https://massgrave.dev/)
</div>
<div align="center">
<div align="center">
[![1.1]][1]
[![1.4]][4] [![1.2]][2]
[![1.5]][5] [![1.3]][3]
[![1.6]][6]
[![1.7]][7] </div>
</div> <div align="center">
[1.1]: https://massgrave.dev/img/logo_github.png (GitHub) [![1.4]][4]
[1.2]: https://massgrave.dev/img/logo_azuredevops.png (AzureDevOps) [![1.5]][5]
[1.3]: https://massgrave.dev/img/logo_gitea.png (Self-hosted Git) [![1.6]][6]
[![1.7]][7]
[1.4]: https://massgrave.dev/img/logo_discord.png (Chat with us without signup)
[1.5]: https://massgrave.dev/img/logo_reddit.png (Reddit) </div>
[1.6]: https://massgrave.dev/img/logo_bluesky.png (Bluesky)
[1.7]: https://massgrave.dev/img/logo_x.png (Twitter) [1.1]: https://massgrave.dev/img/logo_github.png (GitHub)
[1.2]: https://massgrave.dev/img/logo_azuredevops.png (AzureDevOps)
[1]: https://github.com/massgravel/Microsoft-Activation-Scripts [1.3]: https://massgrave.dev/img/logo_gitea.png (Self-hosted Git)
[2]: https://dev.azure.com/massgrave/_git/Microsoft-Activation-Scripts
[3]: https://git.activated.win/massgrave/Microsoft-Activation-Scripts [1.4]: https://massgrave.dev/img/logo_discord.png (Chat with us without signup)
[4]: https://discord.gg/j2yFsV5ZVC [1.5]: https://massgrave.dev/img/logo_reddit.png (Reddit)
[5]: https://www.reddit.com/r/MAS_Activator [1.6]: https://massgrave.dev/img/logo_bluesky.png (Bluesky)
[6]: https://bsky.app/profile/massgrave.dev [1.7]: https://massgrave.dev/img/logo_x.png (Twitter)
[7]: https://twitter.com/massgravel
[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
<p align="center">Made with Love ❤️</p> [4]: https://discord.gg/j2yFsV5ZVC
[5]: https://www.reddit.com/r/MAS_Activator
[6]: https://bsky.app/profile/massgrave.dev
[7]: https://twitter.com/massgravel
---
<p align="center">Made with Love ❤️</p>