Compare commits

..

57 Commits
2.9 ... master

Author SHA1 Message Date
WindowsAddict
4e702068be Revert export-ignore 2025-04-29 23:06:43 +05:30
WindowsAddict
6945236590 Merge branch 'dev' 2025-04-29 22:45:01 +05:30
WindowsAddict
5872b7df53 3.1
Added Ohook support for OSPP based Office on Vista and later
2025-04-29 22:40:56 +05:30
WindowsAddict
b8ad749bac Fix issue related to URL opening in unattended mode 2025-04-21 20:22:13 +05:30
WindowsAddict
5090cde0a0 Use wmic.exe on builds below 9200 2025-04-21 18:01:09 +05:30
WindowsAddict
af18bd773c Fix a missing echo 2025-04-21 02:29:22 +05:30
WindowsAddict
52ba9f138f Ask to run DISM restore and SFC scan when system files are missing 2025-04-21 00:53:08 +05:30
WindowsAddict
98ef9db3ce Add TSforge and Online KMS support for Vista/Server2008 2025-04-20 19:35:53 +05:30
WindowsAddict
172fd7b1c5 Fix crash issue when scripts are running under a path with special characters 2025-04-17 03:11:21 +05:30
WindowsAddict
372eb73a02 Add updated TSforge code 2025-04-17 01:47:13 +05:30
WindowsAddict
a1614e1283 Convert HomeStudentARM IDs to Mondo because phone license isn't available for them 2025-04-16 08:03:58 +05:30
WindowsAddict
e8bf344f74 Add support for O365 15.0 in TSforge because phone license exist 2025-04-16 06:14:40 +05:30
WindowsAddict
70162c4130 Add support for external LibTSforge.dll if found in BIN folder 2025-04-16 05:30:31 +05:30
WindowsAddict
294837dfe0 Add the updated CAS by abbodi1406 2025-04-16 03:47:15 +05:30
WindowsAddict
f5a0a63165 Cleanup leftover branding.xml related code 2025-04-15 08:39:39 +05:30
WindowsAddict
0d61475468 Fix an issue where Office doesn't need activation but TSforge would show phone license missing error 2025-04-15 07:02:19 +05:30
WindowsAddict
c316b42e5c Simplify the code related to "disable quickedit and avoid Terminal app" 2025-04-14 04:10:58 +05:30
WindowsAddict
3b739d7e2b Add malware check in Powershell test 2025-04-13 04:25:10 +05:30
WindowsAddict
8673fbbfda Add -nop -c with Powershell 2025-04-13 03:45:34 +05:30
WindowsAddict
60dd549a49 Don't add SharedComputerLicensing registry on Server for old Office versions 2025-04-12 20:07:24 +05:30
WindowsAddict
1e3c0aaedf Fix MSI Office detection for Visio and few other products 2025-04-12 19:00:48 +05:30
WindowsAddict
fe001e6c39 Elaborate help message 2025-03-16 03:04:40 +05:30
WindowsAddict
c4f33e96c4 Update WPA keys check code 2025-03-16 02:34:10 +05:30
WindowsAddict
313f240448 Change file hash 2025-03-14 15:30:16 +05:30
WindowsAddict
69f1a206fb Change file hash 2025-03-14 15:27:57 +05:30
WindowsAddict
ab0cd24f89 Add more checks for powershell 2025-02-24 00:36:35 +05:30
WindowsAddict
55afa30fcd Improve powershell test 2025-02-23 20:36:55 +05:30
WindowsAddict
5e7e42a446 Add a backup url in update check 2025-02-22 20:52:26 +05:30
WindowsAddict
a9eda8f572 Select 1 and 2Y ESU as well instead of only 3Y, just to be sure 2025-02-22 20:13:09 +05:30
WindowsAddict
a5bcfdd3e6 Update info in tsforge uninstall section 2025-02-22 19:50:37 +05:30
WindowsAddict
8d67d62c15 Update esu info 2025-02-18 04:44:35 +05:30
WindowsAddict
6adb247334 Update W10 ESU editions list as per 19045.5552 2025-02-18 03:42:42 +05:30
WindowsAddict
6c8732dd06 Correct the chart link in readme 2025-02-18 03:35:32 +05:30
WindowsAddict
9765e7d05f Revert-export-ignore 2025-02-13 23:17:18 +05:30
WindowsAddict
60c99742ce 3.0 2025-02-13 23:10:49 +05:30
WindowsAddict
8f3f392517 Add updated CAS 2025-02-03 23:57:37 +05:30
WindowsAddict
af69d79c5c check main domain 2025-02-03 19:32:03 +05:30
WindowsAddict
63045afc70 Remove activation not required line in HWID 2025-02-02 19:21:01 +05:30
WindowsAddict
19c6612a47 Optimize the tests 2025-02-02 18:25:46 +05:30
WindowsAddict
9e6f386819 Fix licensing servers tests 2025-02-02 18:13:28 +05:30
WindowsAddict
b5ba36c033 Remove UnQuickEdit in check activation script 2025-02-02 03:50:02 +05:30
WindowsAddict
d10b6d691e Update licensing servers test section 2025-02-01 21:18:21 +05:30
WindowsAddict
de812acdc5 show error info on screen when unable to connect to licensing servers 2025-01-31 18:25:56 +05:30
WindowsAddict
75c34cbf50 Add updated CAS by abbodi1406 2025-01-30 02:25:04 +05:30
WindowsAddict
0d533338a1 Use installed licences edition ids list only from 17063 2025-01-30 02:08:55 +05:30
WindowsAddict
411f387705 Fix a bug on 7 where it can't list multiple ids 2025-01-30 01:59:45 +05:30
WindowsAddict
be44b2d887 Don't check tasks if csvlk is installed, don't show wlms in red 2025-01-30 00:51:46 +05:30
WindowsAddict
0c88f6bc2c Change error detection for ImageState 2025-01-20 22:35:47 +05:30
WindowsAddict
d31e4ab0cb Remove error variable from non-critical errors 2025-01-17 21:58:29 +05:30
WindowsAddict
9fd5a661ab Change some variable names 2025-01-17 20:24:54 +05:30
WindowsAddict
b732e2c8d7 Remove permanent activated IDs check in Office scripts 2025-01-17 17:28:44 +05:30
WindowsAddict
8e2677b1f9 Check license files instead of folder in change edition 2025-01-17 04:34:03 +05:30
WindowsAddict
f2e40bf88e Fix an issue where the script doesn't show fix licensing suggestion 2025-01-09 00:44:02 +05:30
WindowsAddict
a4f9b219ab Change wordings 2025-01-09 00:21:13 +05:30
WindowsAddict
7262a44ba2 Add obscure product keys 2024-12-21 21:15:21 +05:30
WindowsAddict
37ec96504a Fix registry count 2024-12-21 15:48:02 +05:30
WindowsAddict
051b4f673f Revert export-ignore 2024-12-21 04:37:12 +05:30
15 changed files with 20786 additions and 2546 deletions

6
.gitattributes vendored
View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
@set masver=2.9 @set masver=3.1
@echo off @echo off
@ -109,7 +109,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Help - %mas%fix_service echo Check this webpage for help - %mas%fix_service
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -124,7 +124,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Help - %mas%troubleshoot echo Check this webpage for help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -161,19 +161,29 @@ for %%A in (%_act% %_NoEditionChange%) do (if "%%A"=="1" set _unattended=1)
call :dk_setvar call :dk_setvar
if %winbuild% EQU 1 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
if %winbuild% LSS 10240 ( if %winbuild% LSS 10240 (
%eline% %eline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo HWID Activation is only supported on Windows 10/11. echo HWID Activation is only supported on Windows 10/11.
echo: echo:
call :dk_color %Blue% "Use Online KMS activation option." call :dk_color %Blue% "Use TSforge activation option from the main menu."
goto dk_done goto dk_done
) )
if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
%eline% %eline%
echo HWID Activation is not supported on Windows Server. echo HWID Activation is not supported on Windows Server.
call :dk_color %Blue% "Use KMS38 or Online KMS activation option." call :dk_color %Blue% "Use TSforge activation option from the main menu."
goto dk_done goto dk_done
) )
@ -209,33 +219,6 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
echo:
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -248,6 +231,58 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto dk_done
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto dk_done
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto dk_done
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -258,34 +293,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if defined ps32onArm goto :skipQE
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
set "launchcmd=start conhost.exe %psc%" start conhost.exe "!_batf!" %_args% -qedit
) else ( start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
set "launchcmd=%psc%" exit /b
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -294,9 +328,19 @@ set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080)
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do ( for %%A in (
if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1)) activ%-%ated.win
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -312,7 +356,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 ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) if !errorlevel!==1 (start %mas% & exit /b)
) )
) )
@ -337,8 +381,11 @@ 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% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
) )
@ -363,7 +410,6 @@ cls
echo ___________________________________________________________________________________________ echo ___________________________________________________________________________________________
echo: echo:
call :dk_color2 %_White% " " %Green% "%winos% is already permanently activated." call :dk_color2 %_White% " " %Green% "%winos% is already permanently activated."
call :dk_color2 %_White% " " %Gray% "Activation is not required."
echo ___________________________________________________________________________________________ echo ___________________________________________________________________________________________
if %_unattended%==1 goto dk_done if %_unattended%==1 goto dk_done
echo: echo:
@ -382,9 +428,10 @@ reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2
echo [%winos% ^| %winbuild%] echo [%winos% ^| %winbuild%]
echo: echo:
echo Evaluation editions cannot be activated outside of their evaluation period. echo Evaluation editions cannot be activated outside of their evaluation period.
call :dk_color %Blue% "Use TSforge activation option from the main menu to reset evaluation period."
echo: echo:
set fixes=%fixes% %mas%evaluation_editions set fixes=%fixes% %mas%evaluation_editions
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions"
goto dk_done goto dk_done
) )
) )
@ -465,13 +512,13 @@ echo [%winos% ^| %winbuild% ^| SKU:%osSKU%]
if not defined skunotfound ( if not defined skunotfound (
echo This product does not support HWID activation. echo This product does not support HWID activation.
echo Make sure you are using the latest version of the script. echo Make sure you are using the latest version of the script.
echo If you are, then try KMS38 activation option. echo If you are, then try TSforge activation option from the main menu.
set fixes=%fixes% %mas% set fixes=%fixes% %mas%
echo %mas% echo %mas%
) else ( ) else (
echo Required license files not found in %SysPath%\spp\tokens\skus\ echo Required license files not found in %SysPath%\spp\tokens\skus\
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
echo: echo:
goto dk_done goto dk_done
@ -494,6 +541,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%]"
::======================================================================================================================================== ::========================================================================================================================================
@ -605,17 +653,18 @@ goto :dl_final
set "_ident=HKU\S-1-5-19\SOFTWARE\Microsoft\IdentityCRL" set "_ident=HKU\S-1-5-19\SOFTWARE\Microsoft\IdentityCRL"
if defined _int ( if %keyerror% EQU 0 if defined _int (
reg delete "%_ident%" /f %nul% reg delete "%_ident%" /f %nul%
reg query "%_ident%" %nul% && (
echo:
set error=1
call :dk_color %Red% "Deleting IdentityCRL Registry [Failed] [%_ident%]"
)
for %%# in (wlidsvc LicenseManager sppsvc) do (%psc% "Start-Job { Restart-Service %%# } | Wait-Job -Timeout 20 | Out-Null") for %%# in (wlidsvc LicenseManager sppsvc) do (%psc% "Start-Job { Restart-Service %%# } | Wait-Job -Timeout 20 | Out-Null")
call :dk_refresh call :dk_refresh
call :dk_act call :dk_act
call :dk_checkperm call :dk_checkperm
reg query "%_ident%" %nul% || (
set error=1
echo:
call :dk_color %Red% "Generating New IdentityCRL Registry [Failed] [%_ident%]"
)
) )
::========================================================================================================================================== ::==========================================================================================================================================
@ -623,43 +672,40 @@ call :dk_checkperm
:: Extended licensing servers tests incase error not found and activation failed :: Extended licensing servers tests incase error not found and activation failed
if %keyerror% EQU 0 if not defined _perm if defined _int ( if %keyerror% EQU 0 if not defined _perm if defined _int (
set resfail=
ipconfig /flushdns %nul% ipconfig /flushdns %nul%
set "tls=[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;" set "tls=[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;"
for %%# in ( for %%# in (
licensing.mp.microsoft.com/v7.0/licenses/content
login.live.com/ppsecure/deviceaddcredential.srf login.live.com/ppsecure/deviceaddcredential.srf
purchase.mp.microsoft.com/v7.0/users/me/orders purchase.mp.microsoft.com/v7.0/users/me/orders
) do if not defined resfail ( ) do if not defined resfail (
set "d1=Add-Type -AssemblyName System.Net.Http;" %psc% "try { !tls! irm https://%%# -Method POST } catch { if ($_.Exception.Response -eq $null) { Write-Host """"[%%#] $($_.Exception.Message)"""" -ForegroundColor Red -BackgroundColor Black; exit 3 } }"
set "d1=!d1! $client = [System.Net.Http.HttpClient]::new();" if !errorlevel!==3 set resfail=1
set "d1=!d1! $response = $client.GetAsync('https://%%#').GetAwaiter().GetResult();"
set "d1=!d1! $response.Content.ReadAsStringAsync().GetAwaiter().GetResult()"
%psc% "!tls! !d1!" %nul2% | findstr /i "PurchaseFD DeviceAddResponse" %nul1% || set resfail=1
) )
if not defined resfail (
%psc% "!tls! irm https://licensing.mp.microsoft.com/v7.0/licenses/content -Method POST" | find /i "traceId" %nul1% || set resfail=1
) )
if defined resfail ( if defined resfail (
set error=1 set error=1
echo: for %%# in (
call :dk_color %Red% "Checking Licensing Servers [Failed to Connect]" live.com
set fixes=%fixes% %mas%licensing-servers-issue microsoft.com
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%licensing-servers-issue" login.live.com
purchase.mp.microsoft.com
licensing.mp.microsoft.com
) do (
findstr /i "%%#" "%SysPath%\drivers\etc\hosts" %nul1% && set "hosfail= [%%# Blocked in Hosts]"
) )
call :dk_color %Red% "Checking Licensing Servers [Failed to Connect]!hosfail!"
set fixes=%fixes% %mas%licensing-servers-issue
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%licensing-servers-issue"
) )
::========================================================================================================================================== ::==========================================================================================================================================
if %keyerror% EQU 0 if not defined _perm if defined _int ( :: Windows update and store block check
reg query "%_ident%" %nul% || ( if %keyerror% EQU 0 if not defined _perm if defined _int (
set error=1
echo:
call :dk_color %Red% "Generating New IdentityCRL Registry [Failed] [%_ident%]"
)
reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWindowsUpdateAccess %nul2% | find /i "0x1" %nul% && set wublock=1 reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWindowsUpdateAccess %nul2% | find /i "0x1" %nul% && set wublock=1
reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DoNotConnectToWindowsUpdateInternetLocations %nul2% | find /i "0x1" %nul% && set wublock=1 reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DoNotConnectToWindowsUpdateInternetLocations %nul2% | find /i "0x1" %nul% && set wublock=1
@ -675,40 +721,46 @@ call :dk_color %Blue% "If you have used any tool to block Store, undo it."
) )
set wcount=0 set wcount=0
for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type ServiceSidType RequiredPrivileges FailureActions) do if not defined wucorrupt ( for %%G in (DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type ServiceSidType RequiredPrivileges FailureActions) do (
reg query HKLM\SYSTEM\CurrentControlSet\Services\wuauserv /v %%G %nul% || (set wucorrupt=1&set /a wcount+=1) reg query HKLM\SYSTEM\CurrentControlSet\Services\wuauserv /v %%G %nul% || (set wucorrupt=1&set /a wcount+=1)
) )
for %%G in (Parameters Security) do if not defined wucorrupt ( for %%G in (Parameters Security) do (
reg query HKLM\SYSTEM\CurrentControlSet\Services\wuauserv\%%G %nul% || (set wucorrupt=1&set /a wcount+=1) reg query HKLM\SYSTEM\CurrentControlSet\Services\wuauserv\%%G %nul% || (set wucorrupt=1&set /a wcount+=1)
) )
if defined wucorrupt ( if defined wucorrupt (
set error=1
call :dk_color %Red% "Checking Windows Update Registry [Corruption Found]" call :dk_color %Red% "Checking Windows Update Registry [Corruption Found]"
if !wcount! GTR 2 ( if !wcount! GTR 2 (
call :dk_color %Red% "Windows seems to be infected with Mal%w%ware." call :dk_color %Red% "Windows seems to be infected with Mal%w%ware."
set fixes=%fixes% %mas%remove_mal%w%ware set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
) else ( ) else (
call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it." call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it."
) )
) else ( ) else (
%psc% "Start-Job { Start-Service wuauserv } | Wait-Job -Timeout 20 | Out-Null" %psc% "Start-Job { Start-Service wuauserv } | Wait-Job -Timeout 20 | Out-Null"
sc query wuauserv | find /i "RUNNING" %nul% || ( sc query wuauserv | find /i "RUNNING" %nul% || (
set error=1
set wuerror=1 set wuerror=1
sc start wuauserv %nul% sc start wuauserv %nul%
call :dk_color %Red% "Starting Windows Update Service [Failed] [!errorlevel!]" call :dk_color %Red% "Starting Windows Update Service [Failed] [!errorlevel!]"
call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it." call :dk_color %Blue% "HWID activation needs working Windows updates, if you have used any tool to block updates, undo it."
) )
) )
)
REM Check Internet related error codes ::==========================================================================================================================================
if not defined wucorrupt if not defined wublock if not defined wuerror if not defined storeblock ( :: Check Internet related error codes
if %keyerror% EQU 0 if not defined _perm if defined _int (
if not defined wucorrupt if not defined wublock if not defined wuerror if not defined storeblock if not defined resfail (
echo "%error_code%" | findstr /i "0x80072e 0x80072f 0x800704cf 0x87e10bcf 0x800705b4" %nul% && ( echo "%error_code%" | findstr /i "0x80072e 0x80072f 0x800704cf 0x87e10bcf 0x800705b4" %nul% && (
call :dk_color %Red% "Checking Internet Issues [Found] %error_code%" call :dk_color %Red% "Checking Internet Issues [Found] %error_code%"
set fixes=%fixes% %mas%licensing-servers-issue set fixes=%fixes% %mas%licensing-servers-issue
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%licensing-servers-issue" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%licensing-servers-issue"
) )
) )
) )
@ -722,11 +774,11 @@ call :dk_color %Green% "%winos% is permanently activated with a digital license.
call :dk_color %Red% "Activation Failed %error_code%" call :dk_color %Red% "Activation Failed %error_code%"
if defined notworking ( if defined notworking (
call :dk_color %Blue% "At the time of writing, HWID Activation is not supported for this product." call :dk_color %Blue% "At the time of writing, HWID Activation is not supported for this product."
call :dk_color %Blue% "Use KMS38 activation option instead." call :dk_color %Blue% "Use TSforge activation option from the main menu instead."
) else ( ) else (
if not defined error call :dk_color %Blue% "%_fixmsg%" if not defined error call :dk_color %Blue% "%_fixmsg%"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
) )
@ -760,10 +812,16 @@ goto :dk_done
:dk_setvar :dk_setvar
set psc=powershell.exe 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)
@ -903,11 +961,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%"
@ -916,6 +975,7 @@ set showfix=1
set error=1 set error=1
) )
set generickey=
exit /b exit /b
:: Activation command :: Activation command
@ -954,6 +1014,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"
@ -999,13 +1061,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:
@ -1013,6 +1075,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
@ -1023,16 +1086,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. 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)
@ -1040,7 +1103,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, '(C)' -replace [string][char]0xae, '(R)' -replace [string][char]0x2122, '(TM)'
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)
@ -1096,11 +1159,11 @@ 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%"=="" (
@ -1108,7 +1171,7 @@ if defined pupfound call :dk_color %Gray% "Checking PUP Activators
if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..." if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..."
if defined results call :dk_color %Red% "%results%" if defined results call :dk_color %Red% "%results%"
set fixes=%fixes% %mas%remove_mal%w%ware set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
echo: echo:
) )
@ -1180,6 +1243,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%
@ -1228,7 +1292,7 @@ set showfix=1
) )
echo %serv_e% | findstr /i "sppsvc-1060" %nul% && ( echo %serv_e% | findstr /i "sppsvc-1060" %nul% && (
set fixes=%fixes% %mas%fix_service set fixes=%fixes% %mas%fix_service
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_service" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_service"
set showfix=1 set showfix=1
) )
) )
@ -1249,10 +1313,10 @@ call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option
for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B) for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B)
if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" ( if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" (
set error=1
set showfix=1
call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]" call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]"
echo "%imagestate%" | find /i "RESEAL" %nul% && ( echo "%imagestate%" | find /i "RESEAL" %nul% && (
set error=1
set showfix=1
call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode." call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode."
) )
echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && ( echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && (
@ -1281,12 +1345,11 @@ echo Checking WPA Registry Count [%wpainfo%]
) )
if not defined officeact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( if not defined notwinact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" (
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || (
set error=1
call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]" call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]"
set fixes=%fixes% %mas%evaluation_editions set fixes=%fixes% %mas%evaluation_editions
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions"
) )
) )
@ -1305,26 +1368,25 @@ if "%osSKU%"=="164" set osedition=ProfessionalEducation
if "%osSKU%"=="165" set osedition=ProfessionalEducationN if "%osSKU%"=="165" set osedition=ProfessionalEducationN
) )
if not defined officeact ( if not defined notwinact (
if %osedition%==0 ( if %osedition%==0 (
call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" call :dk_color %Red% "Checking Edition Name [Not Found In Registry]"
) else ( ) else (
if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( if not exist "%SysPath%\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 error=1
set skunotfound=1 set skunotfound=1
call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]" call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]"
) )
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" ( if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" (
set error=1
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%"
@ -1348,7 +1410,7 @@ set showfix=1
) )
if not defined officeact ( if not defined notwinact (
if %winbuild% GEQ 10240 ( if %winbuild% GEQ 10240 (
%nul% set /a "sum=%slcSKU%+%regSKU%+%wmiSKU%" %nul% set /a "sum=%slcSKU%+%regSKU%+%wmiSKU%"
set /a "sum/=3" set /a "sum/=3"
@ -1381,11 +1443,7 @@ call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System
:: This "WLMS" service was included in previous Eval editions (which were activable) to automatically shut down the system every hour after the evaluation period expired and prevent SPPSVC from stopping. :: This "WLMS" service was included in previous Eval editions (which were activable) to automatically shut down the system every hour after the evaluation period expired and prevent SPPSVC from stopping.
if exist "%SysPath%\wlms\wlms.exe" ( if exist "%SysPath%\wlms\wlms.exe" (
if %winbuild% LSS 9200 (
echo Checking Eval WLMS Service [Found] echo Checking Eval WLMS Service [Found]
) else (
call :dk_color %Red% "Checking Eval WLMS Service [Found]"
)
) )
@ -1398,7 +1456,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 (
@ -1412,39 +1470,39 @@ 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"
set error=1
) )
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 HWID spoofers. 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"
set error=1 set error=1
set showfix=1 set showfix=1
) )
set tokenstore= set tokenstore=
if %winbuild% GEQ 7600 (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b"
if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform" if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform"
if %winbuild% GEQ 9200 if /i not "%tokenstore%"=="%SysPath%\spp\store" if /i not "%tokenstore%"=="%SysPath%\spp\store\2.0" if /i not "%tokenstore%"=="%SysPath%\spp\store_test\2.0" ( if %winbuild% GEQ 9200 if /i not "!tokenstore!"=="%SysPath%\spp\store" if /i not "!tokenstore!"=="%SysPath%\spp\store\2.0" if /i not "!tokenstore!"=="%SysPath%\spp\store_test\2.0" (
set toerr=1 set toerr=1
set error=1 set error=1
set showfix=1 set showfix=1
call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [%tokenstore%]" call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "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)';"
@ -1462,35 +1520,40 @@ set showfix=1
) )
if not defined notwinact (
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
%psc% "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=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul%
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
set "_notfoundids=Key Not Installed / Act ID Not Found" set "_notfoundids=Key Not Installed / Act ID Not Found"
call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined allapps ( if not defined allapps (
set error=1
set "_notfoundids=Not found" set "_notfoundids=Not found"
) )
set error=1
call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]" call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]"
) )
) )
)
if 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%\]"
) )
if %winbuild% GEQ 9200 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( if %winbuild% GEQ 9200 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" (
%psc% "Get-WmiObject -Query 'SELECT Description FROM SoftwareLicensingProduct WHERE PartialProductKey IS NOT NULL AND LicenseDependsOn IS NULL' | Select-Object -Property Description" %nul2% | findstr /i "KMS_" %nul1% || (
for /f "delims=" %%a in ('%psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -TaskPath '\Microsoft\Windows\SoftwareProtectionPlatform\').State" %nul6%') do (set taskinfo=%%a) for /f "delims=" %%a in ('%psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -TaskPath '\Microsoft\Windows\SoftwareProtectionPlatform\').State" %nul6%') do (set taskinfo=%%a)
echo !taskinfo! | find /i "Ready" %nul% || ( echo !taskinfo! | find /i "Ready" %nul% || (
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul% reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul%
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTask" %nul% || set taskinfo=Removed reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTask" %nul% || set taskinfo=Removed
if "!taskinfo!"=="" set "taskinfo=Not Found" if "!taskinfo!"=="" set "taskinfo=Not Found"
call :dk_color %Red% "Checking SvcRestartTask Status [!taskinfo!, System might deactivate later]" call :dk_color %Red% "Checking SvcRestartTask Status [!taskinfo!, System might deactivate later]"
if not defined error call :dk_color %Blue% "Reboot your machine using the restart option."
)
) )
) )
@ -1558,7 +1621,7 @@ exit /b
$wpaKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("SYSTEM\\WPA") $wpaKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("SYSTEM\\WPA")
$count = 0 $count = 0
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
if ($subkeyName -match '.*-.*-.*-.*-.*-') { if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') {
$count++ $count++
} }
} }
@ -1567,7 +1630,7 @@ $minBuildNumber = 14393
if ($osVersion.Build -ge $minBuildNumber) { if ($osVersion.Build -ge $minBuildNumber) {
$subkeyHashTable = @{} $subkeyHashTable = @{}
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
if ($subkeyName -match '.*-.*-.*-.*-.*-') { if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') {
$keyNumber = $subkeyName -replace '.*-', '' $keyNumber = $subkeyName -replace '.*-', ''
$subkeyHashTable[$keyNumber] = $true $subkeyHashTable[$keyNumber] = $true
} }
@ -1581,7 +1644,7 @@ if ($osVersion.Build -ge $minBuildNumber) {
} }
} }
$wpaKey.GetSubKeyNames() | ForEach-Object { $wpaKey.GetSubKeyNames() | ForEach-Object {
if ($_ -match '.*-.*-.*-.*-.*-') { if ($_ -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') {
if ($PSVersionTable.PSVersion.Major -lt 3) { if ($PSVersionTable.PSVersion.Major -lt 3) {
cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1" cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1"
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
@ -1610,8 +1673,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
@ -1619,8 +1684,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=2.9 @set masver=3.1
@echo off @echo off
@ -112,7 +112,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Help - %mas%fix_service echo Check this webpage for help - %mas%fix_service
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -127,7 +127,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Help - %mas%troubleshoot echo Check this webpage for help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -167,15 +167,25 @@ set _k38=
call :dk_setvar call :dk_setvar
set "specific_kms=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f" set "specific_kms=SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\55c92734-d682-4d71-983e-d6ec3f16059f"
if %winbuild% EQU 1 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
if %winbuild% LSS 14393 ( if %winbuild% LSS 14393 (
%eline% %eline%
echo Unsupported OS version detected [%winbuild%]. echo Unsupported OS version detected [%winbuild%].
echo KMS38 activation is only supported on Windows 10/11/Server, build 14393 and later. echo KMS38 activation is only supported on Windows 10/11/Server, build 14393 and later.
echo: echo:
if %winbuild% LSS 10240 ( if %winbuild% LSS 10240 (
call :dk_color %Blue% "Use Online KMS activation option." call :dk_color %Blue% "Use TSforge activation option from the main menu."
) else ( ) else (
call :dk_color %Blue% "Use HWID activation option." call :dk_color %Blue% "Use HWID activation option from the main menu."
) )
goto dk_done goto dk_done
) )
@ -212,33 +222,6 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
echo:
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -251,6 +234,58 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto dk_done
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto dk_done
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto dk_done
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -261,34 +296,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if defined ps32onArm goto :skipQE
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
set "launchcmd=start conhost.exe %psc%" start conhost.exe "!_batf!" %_args% -qedit
) else ( start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
set "launchcmd=%psc%" exit /b
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -297,9 +331,19 @@ set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080)
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do ( for %%A in (
if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1)) activ%-%ated.win
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -315,7 +359,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 ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) if !errorlevel!==1 (start %mas% & exit /b)
) )
) )
cls cls
@ -377,8 +421,11 @@ if defined _fmiss (
%eline% %eline%
echo [%_fmiss%] file is missing, aborting... echo [%_fmiss%] 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% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -432,9 +479,10 @@ echo:
call :dk_color %Blue% "Go Back to main menu and use [Change Edition] option." call :dk_color %Blue% "Go Back to main menu and use [Change Edition] option."
) else ( ) else (
echo Evaluation editions cannot be activated outside of their evaluation period. echo Evaluation editions cannot be activated outside of their evaluation period.
call :dk_color %Blue% "Use TSforge activation option from the main menu to reset evaluation period."
echo: echo:
set fixes=%fixes% %mas%evaluation_editions set fixes=%fixes% %mas%evaluation_editions
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions"
) )
goto dk_done goto dk_done
) )
@ -450,7 +498,7 @@ if not exist "!_work!\clipup.exe" (
echo clipup.exe doesn't exist in Server Cor/Acor [No GUI] versions. echo clipup.exe doesn't exist in Server Cor/Acor [No GUI] versions.
echo The file is required for KMS38 activation. echo The file is required for KMS38 activation.
echo Check the below page for instructions on how to activate it. echo Check the below page for instructions on how to activate it.
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%kms38" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%kms38"
goto dk_done goto dk_done
) )
) )
@ -462,7 +510,7 @@ if defined a_cor (
if !errorlevel!==3 ( if !errorlevel!==3 (
%eline% %eline%
echo Valid digital signature not found in clipup.exe file. echo Valid digital signature not found in clipup.exe file.
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
) )
@ -530,18 +578,18 @@ if exist "%SysPath%\spp\tokens\skus\%osedition%\*GVLK*.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 in %SysPath%\spp\tokens\skus\"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
if defined sppks ( if defined sppks (
call :dk_color %Red% "KMS38 activation is supported but failed to find the key." call :dk_color %Red% "KMS38 activation is supported but failed to find the key."
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
if not defined skunotfound if not defined sppks ( if not defined skunotfound if not defined sppks (
call :dk_color %Red% "This product does not support KMS38 activation." call :dk_color %Red% "This product does not support KMS38 activation."
call :dk_color %Blue% "Make sure you are using the latest version of the script." call :dk_color %Blue% "Use TSforge activation option from the main menu."
set fixes=%fixes% %mas% set fixes=%fixes% %mas%
echo %mas% echo %mas%
) )
@ -572,6 +620,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%]"
) )
@ -586,7 +635,7 @@ if %_wmic% EQU 0 for /f "tokens=2 delims==" %%a in ('%psc% "(([WMISEARCHER]'SELE
if not defined app ( if not defined app (
call :dk_color %Red% "Checking Installed GVLK Activation ID [Not Found] Aborting..." call :dk_color %Red% "Checking Installed GVLK Activation ID [Not Found] Aborting..."
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto :dk_done goto :dk_done
) )
@ -670,12 +719,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%
@ -754,7 +797,7 @@ goto :k_final
call :dk_color %Red% "Activation Failed" call :dk_color %Red% "Activation Failed"
if not defined error call :dk_color %Blue% "%_fixmsg%" if not defined error call :dk_color %Blue% "%_fixmsg%"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
::======================================================================================================================================== ::========================================================================================================================================
@ -869,10 +912,16 @@ $key.SetAccessControl($acl)
:dk_setvar :dk_setvar
set psc=powershell.exe 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)
@ -1031,11 +1080,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%"
@ -1044,6 +1094,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
@ -1079,6 +1130,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"
@ -1106,13 +1159,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:
@ -1120,6 +1173,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
@ -1130,16 +1184,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. 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)
@ -1147,7 +1201,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, '(C)' -replace [string][char]0xae, '(R)' -replace [string][char]0x2122, '(TM)'
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)
@ -1248,11 +1302,11 @@ 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%"=="" (
@ -1260,7 +1314,7 @@ if defined pupfound call :dk_color %Gray% "Checking PUP Activators
if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..." if defined results call :dk_color %Red% "Checking Probable Mal%w%ware Infection..."
if defined results call :dk_color %Red% "%results%" if defined results call :dk_color %Red% "%results%"
set fixes=%fixes% %mas%remove_mal%w%ware set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%remove_mal%w%ware" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
echo: echo:
) )
@ -1332,6 +1386,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%
@ -1380,7 +1435,7 @@ set showfix=1
) )
echo %serv_e% | findstr /i "sppsvc-1060" %nul% && ( echo %serv_e% | findstr /i "sppsvc-1060" %nul% && (
set fixes=%fixes% %mas%fix_service set fixes=%fixes% %mas%fix_service
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_service" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_service"
set showfix=1 set showfix=1
) )
) )
@ -1401,10 +1456,10 @@ call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option
for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B) for /f "skip=2 tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState') do (set imagestate=%%B)
if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" ( if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" (
set error=1
set showfix=1
call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]" call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]"
echo "%imagestate%" | find /i "RESEAL" %nul% && ( echo "%imagestate%" | find /i "RESEAL" %nul% && (
set error=1
set showfix=1
call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode." call :dk_color %Blue% "You need to run it in normal mode in case you are running it in Audit Mode."
) )
echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && ( echo "%imagestate%" | find /i "UNDEPLOYABLE" %nul% && (
@ -1433,12 +1488,11 @@ echo Checking WPA Registry Count [%wpainfo%]
) )
if not defined officeact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( if not defined notwinact if exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" (
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || ( reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID %nul2% | find /i "Eval" %nul1% || (
set error=1
call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]" call :dk_color %Red% "Checking Eval Packages [Non-Eval Licenses are installed in Eval Windows]"
set fixes=%fixes% %mas%evaluation_editions set fixes=%fixes% %mas%evaluation_editions
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%evaluation_editions" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%evaluation_editions"
) )
) )
@ -1457,26 +1511,25 @@ if "%osSKU%"=="164" set osedition=ProfessionalEducation
if "%osSKU%"=="165" set osedition=ProfessionalEducationN if "%osSKU%"=="165" set osedition=ProfessionalEducationN
) )
if not defined officeact ( if not defined notwinact (
if %osedition%==0 ( if %osedition%==0 (
call :dk_color %Red% "Checking Edition Name [Not Found In Registry]" call :dk_color %Red% "Checking Edition Name [Not Found In Registry]"
) else ( ) else (
if not exist "%SysPath%\spp\tokens\skus\%osedition%\%osedition%*.xrm-ms" if not exist "%SysPath%\spp\tokens\skus\Security-SPP-Component-SKU-%osedition%\*-%osedition%-*.xrm-ms" ( if not exist "%SysPath%\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 error=1
set skunotfound=1 set skunotfound=1
call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]" call :dk_color %Red% "Checking License Files [Not Found] [%osedition%]"
) )
if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" ( if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*-%osedition%-*.mum" (
set error=1
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%"
@ -1500,7 +1553,7 @@ set showfix=1
) )
if not defined officeact ( if not defined notwinact (
if %winbuild% GEQ 10240 ( if %winbuild% GEQ 10240 (
%nul% set /a "sum=%slcSKU%+%regSKU%+%wmiSKU%" %nul% set /a "sum=%slcSKU%+%regSKU%+%wmiSKU%"
set /a "sum/=3" set /a "sum/=3"
@ -1533,11 +1586,7 @@ call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System
:: This "WLMS" service was included in previous Eval editions (which were activable) to automatically shut down the system every hour after the evaluation period expired and prevent SPPSVC from stopping. :: This "WLMS" service was included in previous Eval editions (which were activable) to automatically shut down the system every hour after the evaluation period expired and prevent SPPSVC from stopping.
if exist "%SysPath%\wlms\wlms.exe" ( if exist "%SysPath%\wlms\wlms.exe" (
if %winbuild% LSS 9200 (
echo Checking Eval WLMS Service [Found] echo Checking Eval WLMS Service [Found]
) else (
call :dk_color %Red% "Checking Eval WLMS Service [Found]"
)
) )
@ -1550,7 +1599,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 (
@ -1564,39 +1613,39 @@ 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"
set error=1
) )
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 HWID spoofers. 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"
set error=1 set error=1
set showfix=1 set showfix=1
) )
set tokenstore= set tokenstore=
if %winbuild% GEQ 7600 (
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b" for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b"
if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform" if %winbuild% LSS 9200 set "tokenstore=%Systemdrive%\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform"
if %winbuild% GEQ 9200 if /i not "%tokenstore%"=="%SysPath%\spp\store" if /i not "%tokenstore%"=="%SysPath%\spp\store\2.0" if /i not "%tokenstore%"=="%SysPath%\spp\store_test\2.0" ( if %winbuild% GEQ 9200 if /i not "!tokenstore!"=="%SysPath%\spp\store" if /i not "!tokenstore!"=="%SysPath%\spp\store\2.0" if /i not "!tokenstore!"=="%SysPath%\spp\store_test\2.0" (
set toerr=1 set toerr=1
set error=1 set error=1
set showfix=1 set showfix=1
call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [%tokenstore%]" call :dk_color %Red% "Checking TokenStore Registry Key [Correct Path Not Found] [!tokenstore!]"
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "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)';"
@ -1614,35 +1663,40 @@ set showfix=1
) )
if not defined notwinact (
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
%psc% "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=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul%
call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actid 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined apps ( if not defined apps (
set "_notfoundids=Key Not Installed / Act ID Not Found" set "_notfoundids=Key Not Installed / Act ID Not Found"
call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f call :dk_actids 55c92734-d682-4d71-983e-d6ec3f16059f
if not defined allapps ( if not defined allapps (
set error=1
set "_notfoundids=Not found" set "_notfoundids=Not found"
) )
set error=1
call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]" call :dk_color %Red% "Checking Activation IDs [!_notfoundids!]"
) )
) )
)
if 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%\]"
) )
if %winbuild% GEQ 9200 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" ( if %winbuild% GEQ 9200 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum" (
%psc% "Get-WmiObject -Query 'SELECT Description FROM SoftwareLicensingProduct WHERE PartialProductKey IS NOT NULL AND LicenseDependsOn IS NULL' | Select-Object -Property Description" %nul2% | findstr /i "KMS_" %nul1% || (
for /f "delims=" %%a in ('%psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -TaskPath '\Microsoft\Windows\SoftwareProtectionPlatform\').State" %nul6%') do (set taskinfo=%%a) for /f "delims=" %%a in ('%psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -TaskPath '\Microsoft\Windows\SoftwareProtectionPlatform\').State" %nul6%') do (set taskinfo=%%a)
echo !taskinfo! | find /i "Ready" %nul% || ( echo !taskinfo! | find /i "Ready" %nul% || (
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul% reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v "actionlist" /f %nul%
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTask" %nul% || set taskinfo=Removed reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\SoftwareProtectionPlatform\SvcRestartTask" %nul% || set taskinfo=Removed
if "!taskinfo!"=="" set "taskinfo=Not Found" if "!taskinfo!"=="" set "taskinfo=Not Found"
call :dk_color %Red% "Checking SvcRestartTask Status [!taskinfo!, System might deactivate later]" call :dk_color %Red% "Checking SvcRestartTask Status [!taskinfo!, System might deactivate later]"
if not defined error call :dk_color %Blue% "Reboot your machine using the restart option."
)
) )
) )
@ -1710,7 +1764,7 @@ exit /b
$wpaKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("SYSTEM\\WPA") $wpaKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("SYSTEM\\WPA")
$count = 0 $count = 0
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
if ($subkeyName -match '.*-.*-.*-.*-.*-') { if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') {
$count++ $count++
} }
} }
@ -1719,7 +1773,7 @@ $minBuildNumber = 14393
if ($osVersion.Build -ge $minBuildNumber) { if ($osVersion.Build -ge $minBuildNumber) {
$subkeyHashTable = @{} $subkeyHashTable = @{}
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) { foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
if ($subkeyName -match '.*-.*-.*-.*-.*-') { if ($subkeyName -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') {
$keyNumber = $subkeyName -replace '.*-', '' $keyNumber = $subkeyName -replace '.*-', ''
$subkeyHashTable[$keyNumber] = $true $subkeyHashTable[$keyNumber] = $true
} }
@ -1733,7 +1787,7 @@ if ($osVersion.Build -ge $minBuildNumber) {
} }
} }
$wpaKey.GetSubKeyNames() | ForEach-Object { $wpaKey.GetSubKeyNames() | ForEach-Object {
if ($_ -match '.*-.*-.*-.*-.*-') { if ($_ -match '8DEC0AF1-0341-4b93-85CD-72606C2DF94C.*') {
if ($PSVersionTable.PSVersion.Major -lt 3) { if ($PSVersionTable.PSVersion.Major -lt 3) {
cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1" cmd /c "reg query "HKLM\SYSTEM\WPA\$_" /ve /t REG_BINARY >nul 2>&1"
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
@ -1762,8 +1816,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
@ -1771,8 +1827,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,12 +0,0 @@
--------------------------------------------------------------------------------------
Activation Type Supported Product Activation Period
--------------------------------------------------------------------------------------
HWID - Windows 10-11 - Permanent
Ohook - Office - Permanent
KMS38 - Windows 10-11-Server - Till the Year 2038
Online KMS - Windows / Office - 180 Days. Lifetime With Renewal Task
--------------------------------------------------------------------------------------
For more details, use the respective docs section here https://massgrave.dev/

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,4 +1,4 @@
@set masver=2.9 @set masver=3.1
@echo off @echo off
@ -69,7 +69,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Help - %mas%fix_service echo Check this webpage for help - %mas%fix_service
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -84,7 +84,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Help - %mas%troubleshoot echo Check this webpage for help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -123,10 +123,20 @@ set "line=echo _________________________________________________________________
::======================================================================================================================================== ::========================================================================================================================================
if %winbuild% EQU 1 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
if %winbuild% LSS 7600 ( if %winbuild% LSS 7600 (
%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
) )
@ -162,33 +172,6 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
echo:
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -201,6 +184,58 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto dk_done
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto dk_done
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto dk_done
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -211,34 +246,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if defined ps32onArm goto :skipQE
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
set "launchcmd=start conhost.exe %psc%" start conhost.exe "!_batf!" %_args% -qedit
) else ( start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
set "launchcmd=%psc%" exit /b
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -247,9 +281,19 @@ set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080)
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do ( for %%A in (
if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1)) activ%-%ated.win
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -265,7 +309,7 @@ echo:
call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :" call :dk_color %_Green% "Choose a menu option using your keyboard [1,0] :"
choice /C:10 /N choice /C:10 /N
if !errorlevel!==2 rem if !errorlevel!==2 rem
if !errorlevel!==1 (start ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) if !errorlevel!==1 (start %mas% & exit /b)
) )
) )
@ -284,7 +328,7 @@ if not exist %SysPath%\sppsvc.exe (
echo [%SysPath%\sppsvc.exe] file is missing. Aborting... echo [%SysPath%\sppsvc.exe] file is missing. Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -322,7 +366,7 @@ if %osedition%==0 (
echo Failed to detect OS Edition. Aborting... echo Failed to detect OS Edition. Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -395,7 +439,7 @@ echo which is not officially supported on your Windows build version %winbuild%.
echo Aborting... echo Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -409,7 +453,7 @@ echo Unsupported Office %verchk% is installed on your Windows build version %win
echo Aborting... echo Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -515,7 +559,7 @@ if not exist %SystemRoot%\Temp\%list%.txt (
echo Failed to generate available editions list. echo Failed to generate available editions list.
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto :oe_goback goto :oe_goback
) )
@ -580,7 +624,7 @@ if not exist %SystemRoot%\Temp\getAppIds.txt (
echo Failed to generate available apps list. echo Failed to generate available apps list.
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto :oe_goback goto :oe_goback
) )
) )
@ -762,7 +806,7 @@ if %errorcode% EQU 0 (
call :dk_color %Gray% "Now run the Office activation option from the main menu." call :dk_color %Gray% "Now run the Office activation option from the main menu."
) else ( ) else (
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
call :oe_tempcleanup call :oe_tempcleanup
@ -905,7 +949,7 @@ echo %c2rcommand%
if %errorlevel% NEQ 0 ( if %errorlevel% NEQ 0 (
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
goto :oe_goback goto :oe_goback
@ -1053,7 +1097,7 @@ echo:
echo %updcommand% echo %updcommand%
%updcommand% %updcommand%
echo: echo:
echo Help - %mas%troubleshoot echo Check this webpage for help - %mas%troubleshoot
goto :oe_goback goto :oe_goback
::======================================================================================================================================== ::========================================================================================================================================
@ -1308,10 +1352,16 @@ if ($appIdsList.Count -gt 0) {
:dk_setvar :dk_setvar
set psc=powershell.exe 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)
@ -1358,6 +1408,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
@ -1368,16 +1419,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. 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
@ -1395,8 +1446,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
@ -1404,8 +1457,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=2.9 @set masver=3.1
@echo off @echo off
@ -74,7 +74,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Help - %mas%fix_service echo Check this webpage for help - %mas%fix_service
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -89,7 +89,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Help - %mas%troubleshoot echo Check this webpage for help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -128,10 +128,20 @@ set "line=echo _________________________________________________________________
::======================================================================================================================================== ::========================================================================================================================================
if %winbuild% EQU 1 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
if %winbuild% LSS 7600 ( if %winbuild% LSS 7600 (
%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
) )
@ -167,33 +177,6 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
echo:
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -206,6 +189,58 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto dk_done
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto dk_done
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto dk_done
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -216,34 +251,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if defined ps32onArm goto :skipQE
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
set "launchcmd=start conhost.exe %psc%" start conhost.exe "!_batf!" %_args% -qedit
) else ( start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
set "launchcmd=%psc%" exit /b
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -252,9 +286,19 @@ set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080)
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do ( for %%A in (
if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1)) activ%-%ated.win
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -270,7 +314,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 ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) if !errorlevel!==1 (start %mas% & exit /b)
) )
) )
@ -310,8 +354,11 @@ 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% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
) )
@ -344,7 +391,7 @@ if not defined allapps (
echo Failed to find activation IDs. Aborting... echo Failed to find activation IDs. Aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -367,7 +414,7 @@ if not defined osedition (
echo Failed to detect OS edition, aborting... echo Failed to detect OS edition, aborting...
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -393,7 +440,7 @@ if %winbuild% GEQ 10240 for /f "tokens=4" %%a in ('dism /online /english /Get-Ta
if %winbuild% LSS 10240 for /f "tokens=4" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -GetTargetEditions;" ^| findstr /i /c:"Target Edition : "') do (if defined _ptarget (set "_ptarget= !_ptarget! %%a ") else (set "_ptarget= %%a ")) if %winbuild% LSS 10240 for /f "tokens=4" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -GetTargetEditions;" ^| findstr /i /c:"Target Edition : "') do (if defined _ptarget (set "_ptarget= !_ptarget! %%a ") else (set "_ptarget= %%a "))
if %winbuild% GEQ 10240 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" ( if %winbuild% GEQ 10240 if not exist "%SystemRoot%\Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum" (
call :ced_edilist if %winbuild% GEQ 17063 call :ced_edilist
if /i "%osedition:~0,4%"=="Core" set _pro=Professional if /i "%osedition:~0,4%"=="Core" set _pro=Professional
if /i "%osedition%"=="CoreN" set _pro=ProfessionalN if /i "%osedition%"=="CoreN" set _pro=ProfessionalN
set "_dtarget= %_dtarget% !_wtarget! !_pro! " set "_dtarget= %_dtarget% !_wtarget! !_pro! "
@ -506,7 +553,7 @@ set _dismapi=0
:: Check if DISM API or slmgr.vbs is required for edition upgrade :: Check if DISM API or slmgr.vbs is required for edition upgrade
if not exist "%SysPath%\spp\tokens\skus\%targetedition%\" ( if not exist "%SysPath%\spp\tokens\skus\%targetedition%\%targetedition%*.xrm-ms" (
echo %_wtarget% | find /i " %targetedition% " || ( echo %_wtarget% | find /i " %targetedition% " || (
set _dismapi=1 set _dismapi=1
) )
@ -529,7 +576,7 @@ echo [%targetedition% ^| %winbuild%]
echo Failed to get product key from pkeyhelper.dll. echo Failed to get product key from pkeyhelper.dll.
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -584,7 +631,7 @@ call :dk_color %Gray% "Reboot is required to fully change the edition."
call :dk_color %Red% "[Unsuccessful] [Error Code: !keyerror!]" call :dk_color %Red% "[Unsuccessful] [Error Code: !keyerror!]"
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
) )
) )
@ -665,7 +712,7 @@ echo [%targetedition% ^| %winbuild%]
echo Failed to get product key from pkeyhelper.dll. echo Failed to get product key from pkeyhelper.dll.
echo: echo:
set fixes=%fixes% %mas%troubleshoot set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done goto dk_done
) )
@ -741,7 +788,7 @@ echo:
call :dk_color %Blue% "In case there are errors, you should restart the system before trying again." call :dk_color %Blue% "In case there are errors, you should restart the system before trying again."
echo: echo:
set fixes=%fixes% %mas%change_edition_issues set fixes=%fixes% %mas%change_edition_issues
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%change_edition_issues" call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%change_edition_issues"
exit /b exit /b
:compresslog :compresslog
@ -780,10 +827,16 @@ exit /b
:dk_setvar :dk_setvar
set psc=powershell.exe 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)
@ -857,6 +910,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
@ -867,16 +921,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. 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
@ -974,8 +1028,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
@ -983,8 +1039,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

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
@set masver=2.9 @set masver=3.1
@echo off @echo off
@ -69,7 +69,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Help - %mas%fix_service echo Check this webpage for help - %mas%fix_service
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -84,7 +84,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Help - %mas%troubleshoot echo Check this webpage for help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -122,10 +122,37 @@ call :dk_setvar
::======================================================================================================================================== ::========================================================================================================================================
if %winbuild% LSS 7600 ( if %winbuild% EQU 1 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto done2
)
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 not exist %ps% (
%nceline%
echo PowerShell is not installed in your system.
if %winbuild% LSS 7600 (
echo Install PowerShell 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
) )
@ -161,33 +188,6 @@ goto done2
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
echo:
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto done2
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -200,6 +200,58 @@ goto done2
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto done2
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto done2
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto done2
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto done2
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -210,34 +262,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if defined ps32onArm goto :skipQE
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
set "launchcmd=start conhost.exe %psc%" start conhost.exe "!_batf!" %_args% -qedit
) else ( start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
set "launchcmd=%psc%" exit /b
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -246,9 +297,19 @@ set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080)
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do ( for %%A in (
if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1)) activ%-%ated.win
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -264,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 ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) if !errorlevel!==1 (start %mas% & exit /b)
) )
) )
@ -305,6 +366,7 @@ set HWID_Activation.cmd=Activators\HWID_Activation.cmd
set KMS38_Activation.cmd=Activators\KMS38_Activation.cmd set KMS38_Activation.cmd=Activators\KMS38_Activation.cmd
set Online_KMS_Activation.cmd=Activators\Online_KMS_Activation.cmd set Online_KMS_Activation.cmd=Activators\Online_KMS_Activation.cmd
set Ohook_Activation_AIO.cmd=Activators\Ohook_Activation_AIO.cmd set Ohook_Activation_AIO.cmd=Activators\Ohook_Activation_AIO.cmd
set TSforge_Activation.cmd=Activators\TSforge_Activation.cmd
pushd "!_work!" pushd "!_work!"
set _nofile= set _nofile=
@ -313,6 +375,7 @@ for %%# in (
%KMS38_Activation.cmd% %KMS38_Activation.cmd%
%Online_KMS_Activation.cmd% %Online_KMS_Activation.cmd%
%Ohook_Activation_AIO.cmd% %Ohook_Activation_AIO.cmd%
%TSforge_Activation.cmd%
) do ( ) do (
if not exist "%%#" set _nofile=1 if not exist "%%#" set _nofile=1
) )
@ -338,36 +401,34 @@ echo:
echo: echo:
echo: echo:
echo: Extract $OEM$ folder on the desktop echo: Extract $OEM$ folder on the desktop
echo: ________________________________________________________ echo: ____________________________________________________________
echo: echo:
echo: [1] HWID echo: [1] HWID [Windows]
echo: [2] Ohook echo: [2] Ohook [Office]
echo: [3] KMS38 echo: [3] TSforge [Windows / ESU / Office]
echo: [4] Online KMS echo: [4] KMS38 [Windows]
echo: [5] Online KMS [Windows / Office]
echo: echo:
echo: [5] HWID ^(Windows^) ^+ Ohook ^(Office^) echo: [6] HWID [Windows] ^+ Ohook [Office]
echo: [6] HWID ^(Windows^) ^+ Online KMS ^(Office^) echo: [7] HWID [Windows] ^+ Ohook [Office] ^+ TSforge [ESU]
echo: [7] KMS38 ^(Windows^) ^+ Ohook ^(Office^) echo: [8] TSforge [Windows] ^+ Online KMS [Office]
echo: [8] KMS38 ^(Windows^) ^+ Online KMS ^(Office^)
echo: [9] Online KMS ^(Windows^) ^+ Ohook ^(Office^)
echo: echo:
call :dk_color2 %_White% " [R] " %_Green% "ReadMe" call :dk_color2 %_White% " [R] " %_Green% "ReadMe"
echo: [0] Exit echo: [0] Exit
echo: ________________________________________________________ echo: ____________________________________________________________
echo: echo:
call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard :" call :dk_color2 %_White% " " %_Green% "Choose a menu option using your keyboard :"
choice /C:123456789R0 /N choice /C:12345678R0 /N
set _erl=%errorlevel% set _erl=%errorlevel%
if %_erl%==11 exit /b if %_erl%==10 exit /b
if %_erl%==10 start %mas%oem-folder &goto :Menu if %_erl%==9 start %mas%oem-folder &goto :Menu
if %_erl%==9 goto:kms_ohook if %_erl%==8 goto:tsforge_kms
if %_erl%==8 goto:kms38_kms if %_erl%==7 goto:hwid_ohook_tsforge
if %_erl%==7 goto:kms38_ohook if %_erl%==6 goto:hwid_ohook
if %_erl%==6 goto:hwid_kms if %_erl%==5 goto:kms
if %_erl%==5 goto:hwid_ohook if %_erl%==4 goto:kms38
if %_erl%==4 goto:kms if %_erl%==3 goto:tsforge
if %_erl%==3 goto:kms38
if %_erl%==2 goto:ohook if %_erl%==2 goto:ohook
if %_erl%==1 goto:hwid if %_erl%==1 goto:hwid
goto :Menu goto :Menu
@ -434,6 +495,36 @@ cd \
::======================================================================================================================================== ::========================================================================================================================================
:tsforge
cls
md "!desktop!\$OEM$\$$\Setup\Scripts"
pushd "!_work!"
copy /y /b "%TSforge_Activation.cmd%" "!_dir!\TSforge_Activation.cmd" %nul%
popd
call :export tsforge_setup
set _error=
if not exist "!_dir!\TSforge_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound
set oem=TSforge
goto done
:tsforge_setup:
@echo off
fltmc >nul || exit /b
call "%~dp0TSforge_Activation.cmd" /Z-WindowsESUOffice
cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
:tsforge_setup:
::========================================================================================================================================
:kms38 :kms38
cls cls
@ -532,26 +623,28 @@ cd \
::======================================================================================================================================== ::========================================================================================================================================
:hwid_kms :hwid_ohook_tsforge
cls cls
md "!desktop!\$OEM$\$$\Setup\Scripts" md "!desktop!\$OEM$\$$\Setup\Scripts"
pushd "!_work!" pushd "!_work!"
copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul% copy /y /b "%HWID_Activation.cmd%" "!_dir!\HWID_Activation.cmd" %nul%
copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul% copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul%
copy /y /b "%TSforge_Activation.cmd%" "!_dir!\TSforge_Activation.cmd" %nul%
popd popd
call :export hwid_kms_setup call :export hwid_ohook_tsforge_setup
set _error= set _error=
if not exist "!_dir!\HWID_Activation.cmd" set _error=1 if not exist "!_dir!\HWID_Activation.cmd" set _error=1
if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1 if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1
if not exist "!_dir!\TSforge_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1 if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound if defined _error goto errorfound
set oem=HWID [Windows] + Online KMS [Office] set oem=HWID [Windows] + Ohook [Office] + TSforge [ESU]
goto done goto done
:hwid_kms_setup: :hwid_ohook_tsforge_setup:
@echo off @echo off
fltmc >nul || exit /b fltmc >nul || exit /b
@ -560,80 +653,46 @@ setlocal
call "%~dp0HWID_Activation.cmd" /HWID call "%~dp0HWID_Activation.cmd" /HWID
endlocal endlocal
setlocal
call "%~dp0Online_KMS_Activation.cmd" /K-Office
endlocal
cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
:hwid_kms_setup:
::========================================================================================================================================
:kms38_ohook
cls
md "!desktop!\$OEM$\$$\Setup\Scripts"
pushd "!_work!"
copy /y /b "%KMS38_Activation.cmd%" "!_dir!\KMS38_Activation.cmd" %nul%
copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul%
popd
call :export kms38_ohook_setup
set _error=
if not exist "!_dir!\KMS38_Activation.cmd" set _error=1
if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound
set oem=KMS38 [Windows] + Ohook [Office]
goto done
:kms38_ohook_setup:
@echo off
fltmc >nul || exit /b
setlocal
call "%~dp0KMS38_Activation.cmd" /KMS38
endlocal
setlocal setlocal
call "%~dp0Ohook_Activation_AIO.cmd" /Ohook call "%~dp0Ohook_Activation_AIO.cmd" /Ohook
endlocal endlocal
setlocal
call "%~dp0TSforge_Activation.cmd" /Z-ESU
endlocal
cd \ cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
:kms38_ohook_setup: :hwid_ohook_tsforge_setup:
::======================================================================================================================================== ::========================================================================================================================================
:kms38_kms :tsforge_kms
cls cls
md "!desktop!\$OEM$\$$\Setup\Scripts" md "!desktop!\$OEM$\$$\Setup\Scripts"
pushd "!_work!" pushd "!_work!"
copy /y /b "%KMS38_Activation.cmd%" "!_dir!\KMS38_Activation.cmd" %nul% copy /y /b "%TSforge_Activation.cmd%" "!_dir!\TSforge_Activation.cmd" %nul%
copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul% copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul%
popd popd
call :export kms38_kms_setup call :export tsforge_kms_setup
set _error= set _error=
if not exist "!_dir!\KMS38_Activation.cmd" set _error=1 if not exist "!_dir!\TSforge_Activation.cmd" set _error=1
if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1 if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1 if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound if defined _error goto errorfound
set oem=KMS38 [Windows] + Online KMS [Office] set oem=TSforge [Windows] + Online KMS [Office]
goto done goto done
:kms38_kms_setup: :tsforge_kms_setup:
@echo off @echo off
fltmc >nul || exit /b fltmc >nul || exit /b
setlocal setlocal
call "%~dp0KMS38_Activation.cmd" /KMS38 call "%~dp0TSforge_Activation.cmd" /Z-Windows
endlocal endlocal
setlocal setlocal
@ -642,45 +701,7 @@ endlocal
cd \ cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0") (goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
:kms38_kms_setup: :tsforge_kms_setup:
::========================================================================================================================================
:kms_ohook
cls
md "!desktop!\$OEM$\$$\Setup\Scripts"
pushd "!_work!"
copy /y /b "%Online_KMS_Activation.cmd%" "!_dir!\Online_KMS_Activation.cmd" %nul%
copy /y /b "%Ohook_Activation_AIO.cmd%" "!_dir!\Ohook_Activation_AIO.cmd" %nul%
popd
call :export kms_ohook_setup
set _error=
if not exist "!_dir!\Online_KMS_Activation.cmd" set _error=1
if not exist "!_dir!\Ohook_Activation_AIO.cmd" set _error=1
if not exist "!_dir!\SetupComplete.cmd" set _error=1
if defined _error goto errorfound
set oem=Online KMS [Windows] + Ohook [Office]
goto done
:kms_ohook_setup:
@echo off
fltmc >nul || exit /b
setlocal
call "%~dp0Online_KMS_Activation.cmd" /K-Windows
endlocal
setlocal
call "%~dp0Ohook_Activation_AIO.cmd" /Ohook
endlocal
cd \
(goto) 2>nul & (if "%~dp0"=="%SystemRoot%\Setup\Scripts\" rd /s /q "%~dp0")
:kms_ohook_setup:
::======================================================================================================================================== ::========================================================================================================================================
@ -698,7 +719,7 @@ call :dk_color %Blue% "%oem%"
call :dk_color %Green% "$OEM$ folder was successfully created on your Desktop." call :dk_color %Green% "$OEM$ folder was successfully created on your Desktop."
echo "%oem%" | find /i "38" %nul% && ( echo "%oem%" | find /i "38" %nul% && (
echo: echo:
echo To KMS38 activate Server Cor/Acor editions ^(No GUI Versions^), echo To KMS38 activate Server Cor/Acor editions [No GUI Versions],
echo Check this page %mas%oem-folder echo Check this page %mas%oem-folder
) )
echo ______________________________________________________________ echo ______________________________________________________________
@ -728,10 +749,16 @@ exit /b
:dk_setvar :dk_setvar
set psc=powershell.exe 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)
@ -787,8 +814,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
@ -796,8 +825,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=2.9 @set masver=3.1
@echo off @echo off
@ -69,7 +69,7 @@ echo:
echo Null service is not running, script may crash... echo Null service is not running, script may crash...
echo: echo:
echo: echo:
echo Help - %mas%fix_service echo Check this webpage for help - %mas%fix_service
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 ping 127.0.0.1 -n 20
@ -84,7 +84,7 @@ echo:
echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing. echo Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
echo: echo:
echo: echo:
echo Help - %mas%troubleshoot echo Check this webpage for help - %mas%troubleshoot
echo: echo:
echo: echo:
ping 127.0.0.1 -n 20 >nul ping 127.0.0.1 -n 20 >nul
@ -123,10 +123,37 @@ set "line=______________________________________________________________________
::======================================================================================================================================== ::========================================================================================================================================
if %winbuild% LSS 7600 ( if %winbuild% EQU 1 (
%eline%
echo Failed to detect Windows build number.
echo:
setlocal EnableDelayedExpansion
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
if %winbuild% LSS 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 not exist %ps% (
%nceline%
echo PowerShell is not installed in your system.
if %winbuild% LSS 7600 (
echo Install PowerShell 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
) )
@ -162,33 +189,6 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest:
cmd /c "%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])"" | find /i "FullLanguage" %nul1% || (
%eline%
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode""
echo:
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" %nul1% && (
echo Failed to run Powershell command but Powershell is working.
echo:
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%troubleshoot"
) || (
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell"
)
goto dk_done
)
::========================================================================================================================================
:: Elevate script as admin and pass arguments and preventing loop :: Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || ( %nul1% fltmc || (
@ -201,6 +201,58 @@ goto dk_done
::======================================================================================================================================== ::========================================================================================================================================
:: Check PowerShell
::pstst $ExecutionContext.SessionState.LanguageMode :pstst
for /f "delims=" %%a in ('%psc% "if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}" %nul6%') do (set tstresult=%%a)
if /i not "%tstresult%"=="FullLanguage" (
%eline%
echo: %tstresult%
cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode"
REM check LanguageMode
cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && (
echo FullLanguage mode not found in PowerShell. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo:
set fixes=%fixes% %mas%fix_powershell
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%fix_powershell"
goto dk_done
)
REM check Powershell core version
cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && (
echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
goto dk_done
)
REM check for Mal-ware that may cause issues with Powershell
for /r "%ProgramFiles%\" %%f in (secureboot.exe) do if exist "%%f" (
echo "%%f"
echo Mal%blank%ware found, PowerShell is not working properly.
echo:
set fixes=%fixes% %mas%remove_mal%w%ware
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%remove_mal%w%ware"
goto dk_done
)
REM check antivirus and other errors
echo PowerShell is not working properly. Aborting...
cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }"""
echo:
set fixes=%fixes% %mas%troubleshoot
call :dk_color2 %Blue% "Check this webpage for help - " %_Yellow% " %mas%troubleshoot"
goto dk_done
)
::========================================================================================================================================
:: Disable QuickEdit and launch from conhost.exe to avoid Terminal app :: Disable QuickEdit and launch from conhost.exe to avoid Terminal app
if %winbuild% GEQ 17763 ( if %winbuild% GEQ 17763 (
@ -211,34 +263,33 @@ set terminal=
:: Check if script is running in Terminal app :: Check if script is running in Terminal app
set r1=$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);
set r2=%r1% [void]$TB.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128);
set r3=%r2% [void]$TB.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128);
set d1=%r3% $hIcon = $TB.CreateType(); $hWnd = $hIcon::GetConsoleWindow();
set d2=%d1% echo $($hIcon::SendMessageW($hWnd, 127, 0, 0) -ne [IntPtr]::Zero);
if defined terminal ( if defined terminal (
%psc% "%d2%" %nul2% | find /i "True" %nul1% && set terminal= set lines=0
for /f "skip=2 tokens=2 delims=: " %%A in ('mode con') do if "!lines!"=="0" set lines=%%A
if !lines! GEQ 100 set terminal=
) )
if defined ps32onArm goto :skipQE
if %_unattended%==1 goto :skipQE if %_unattended%==1 goto :skipQE
for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE) for %%# in (%_args%) do (if /i "%%#"=="-qedit" goto :skipQE)
:: Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
:: This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
:: It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set resetQE=1
reg query HKCU\Console /v QuickEdit %nul2% | find /i "0x0" %nul1% && set resetQE=0
reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1%
if defined terminal ( if defined terminal (
set "launchcmd=start conhost.exe %psc%" start conhost.exe "!_batf!" %_args% -qedit
) else ( start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
set "launchcmd=%psc%" exit /b
) else if %resetQE% EQU 1 (
start cmd.exe /c ""!_batf!" %_args% -qedit"
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
exit /b
) )
:: Disable QuickEdit in current session
set "d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0);"
set "d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128);"
set "d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128);"
set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080);"
%launchcmd% "%d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit'" && (exit /b) || (set terminal=1)
:skipQE :skipQE
::======================================================================================================================================== ::========================================================================================================================================
@ -247,9 +298,19 @@ set "d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080)
set -= set -=
set old= set old=
set pingp=
set upver=%masver:.=%
for /f "delims=[] tokens=2" %%# in ('ping -4 -n 1 updatecheck.mass%-%grave.dev') do ( for %%A in (
if not "%%#"=="" (echo "%%#" | find "127.69" %nul1% && (echo "%%#" | find "127.69.%masver%" %nul1% || set old=1)) activ%-%ated.win
mass%-%grave.dev
) do if not defined pingp (
for /f "delims=[] tokens=2" %%B in ('ping -n 1 %%A') do (
if not "%%B"=="" (set old=1& set pingp=1)
for /f "delims=[] tokens=2" %%C in ('ping -n 1 updatecheck%upver%.%%A') do (
if not "%%C"=="" set old=
)
)
) )
if defined old ( if defined old (
@ -265,7 +326,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 ht%-%tps://github.com/mass%-%gravel/Microsoft-Acti%-%vation-Scripts & start %mas% & exit /b) if !errorlevel!==1 (start %mas% & exit /b)
) )
) )
@ -471,6 +532,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:
@ -487,7 +555,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:
@ -651,19 +719,19 @@ 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/help/4487266
echo: echo:
@ -682,6 +750,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
@ -689,6 +758,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
@ -700,9 +770,13 @@ 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=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul%
if %errorlevel% NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul% if %errorlevel% NEQ 0 %psc% "$sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses" %nul%
if %errorlevel% EQU 0 ( if %errorlevel% EQU 0 (
echo [Successful] echo [Successful]
@ -719,7 +793,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
) )
@ -1285,13 +1359,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:
@ -1305,6 +1379,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 (
@ -1380,9 +1455,35 @@ $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"
@ -1397,26 +1498,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
::======================================================================================================================================== ::========================================================================================================================================
@ -1425,10 +1507,16 @@ exit /b
:dk_setvar :dk_setvar
set psc=powershell.exe 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)

View File

@ -2,51 +2,63 @@
<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, 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.
2. **Copy and paste the code below, then press enter.**
``` ```
irm https://get.activated.win | iex irm https://get.activated.win | iex
``` ```
3. You will see the activation options. Choose (1) HWID for Windows activation. Choose (2) Ohook for Office activation. Alternatively, you can use the following (this will be deprecated in the future):
4. That's all.
<details>
<summary>More options</summary>
- Alternatively, you can use the following (It will be deprecated in the future.)
``` ```
irm https://massgrave.dev/get | iex irm https://massgrave.dev/get | iex
``` ```
- The URL `get.activated.win` might be blocked by some DNS services because it is a new domain.
3. You will see the activation options.
Press 1 HWID for Windows activation.
Press 2 Ohook for Office activation.
4. That's all
---
### Method 2 - Traditional (Windows Vista and later)
<details>
<summary>Click here to view</summary>
1. Download the file using one of the links below:
`https://github.com/massgravel/Microsoft-Activation-Scripts/archive/refs/heads/master.zip`
or
`https://git.activated.win/massgrave/Microsoft-Activation-Scripts/archive/master.zip`
2. Right-click on the downloaded zip file and extract it.
3. In the extracted folder, find the folder named `All-In-One-Version`.
4. Run the file named `MAS_AIO.cmd`.
5. You will see the activation options. Follow the on-screen instructions.
6. That's all.
</details> </details>
--- ---
### Method 2 - Traditional (Windows 7 and later) - **[Office for macOS](https://massgrave.dev/office_for_mac)**
- To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches).
<details> ---
<summary>Click here for info</summary>
1. Download the file using the links provided below. ### Not working ❓
`https://github.com/massgravel/Microsoft-Activation-Scripts/archive/refs/heads/master.zip`
or
`https://git.activated.win/massgrave/Microsoft-Activation-Scripts/archive/master.zip`
2. Right-click on the downloaded zip file and extract
3. In the extracted folder, find the folder named `All-In-One-Version`
4. Run the file named `MAS_AIO.cmd`
5. You will see the activation options, follow the on-screen instructions.
6. That's all.
</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).
--- ---
@ -58,11 +70,9 @@ or
--- ---
To run the scripts in unattended mode, check [here](https://massgrave.dev/command_line_switches).
``` ```
Latest Version: 2.9 Latest Version: 3.1
Release date: 20-Dec-2024 Release date: 29-Apr-2025
``` ```
### [Troubleshooting / Help](https://massgrave.dev/troubleshoot) ### [Troubleshooting / Help](https://massgrave.dev/troubleshoot)