@ -1,4 +1,4 @@
@ set masver = 2.9
@ set masver = 3.4
@ echo off
@ echo off
@ -100,6 +100,8 @@ set "nul="
set " blank= "
set " blank= "
set " mas=ht %blank% tps %blank% ://mass %blank% grave.dev/ "
set " mas=ht %blank% tps %blank% ://mass %blank% grave.dev/ "
set " github=ht %blank% tps %blank% ://github.com/massgra %blank% vel/Micro %blank% soft-Acti %blank% vation-Scripts "
set " selfgit=ht %blank% tps %blank% ://git.acti %blank% vated.win/massg %blank% rave/Micr %blank% osoft-Act %blank% ivation-Scripts "
: : Check if Null service is working, it's important for the batch script
: : Check if Null service is working, it's important for the batch script
@ -109,7 +111,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 H elp - %mas% fix_service
echo Check this webpage for h elp - %mas% fix_service
echo :
echo :
echo :
echo :
ping 127.0.0.1 -n 20
ping 127.0.0.1 -n 20
@ -124,7 +126,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 H elp - %mas% troubleshoot
echo Check this webpage for h elp - %mas% troubleshoot
echo :
echo :
echo :
echo :
ping 127.0.0.1 -n 20 > nul
ping 127.0.0.1 -n 20 > nul
@ -161,19 +163,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,40 +221,73 @@ goto dk_done
: :========================================================================================================================================
: :========================================================================================================================================
: : Elevate script as admin and pass arguments and preventing loop
%nul1% fltmc || (
if not defined _elev %psc% " start cmd.exe -arg '/c \ " !_PSarg! \" ' -verb runas " && exit /b
%eline%
echo This script needs admin rights.
echo Right click on this script and select 'Run as administrator'.
goto dk_done
)
: :========================================================================================================================================
: : Check PowerShell
: : Check PowerShell
REM :PStest: $ExecutionContext.SessionState.LanguageMode :PStest:
: :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)
cmd /c " %psc% " $f=[io.file]::ReadAllText('!_batp!') -split ':PStest:\s*';iex ($f[1])" " | find /i " FullLanguage " %nul1% || (
if /i not " %tstresult% " == " FullLanguage " (
%eline%
%eline%
cmd /c " %psc% " $ExecutionContext.SessionState.LanguageMode" "
for /f " delims= " %% a in ( ' %psc% "$ExecutionContext.SessionState.LanguageMode" %nul6% ' ) do ( set tstresult2 = %% a)
echo :
echo Test 1 - %tstresult%
cmd /c " %psc% " $ExecutionContext.SessionState.LanguageMode" " | find /i " FullLanguage " %nul1% && (
echo Test 2 - !tstresult2!
echo Failed to run Powershell command but Powershell is working.
echo :
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 :
REM check LanguageMode
set fixes = %fixes% %mas% troubleshoot
call : dk_color2 %Blue% " Help - " %_Yellow% " %mas% troubleshoot "
echo : !tstresult2! | findstr /i " ConstrainedLanguage RestrictedLanguage NoLanguage " %nul1% && (
) || (
echo FullLanguage mode not found in PowerShell. Aborting...
echo PowerShell is not working. Aborting...
echo If you have applied restrictions on Powershell then undo those changes.
echo If you have applied restrictions on Powershell then undo those changes.
echo :
echo :
set fixes = %fixes% %mas% fix_powershell
set fixes = %fixes% %mas% fix_powershell
call : dk_color2 %Blue% " Help - " %_Yellow% " %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
goto dk_done
)
)
: :========================================================================================================================================
REM check antivirus and other errors
: : Elevate script as admin and pass arguments and preventing loop
echo PowerShell is not working properly. Aborting...
%nul1% fltmc || (
if /i " !tstresult2! " == " FullLanguage " (
if not defined _elev %psc% " start cmd.exe -arg '/c \ " !_PSarg! \" ' -verb runas " && exit /b
echo :
%eline%
echo Your antivirus software might be blocking the script, or PowerShell on your system might be corrupted.
echo This script needs admin rights.
cmd /c " %psc% " " $av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { $n += $i.displayName }; if ($n) { Write-Host ('Installed Antivirus - ' + ($n -join ', '))} " " "
echo Right click on this script and select 'Run as administrator'.
)
echo :
set fixes = %fixes% %mas% troubleshoot
call : dk_color2 %Blue% " Check this webpage for help - " %_Yellow% " %mas% troubleshoot "
goto dk_done
goto dk_done
)
)
@ -258,34 +303,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 )
if defined terminal (
: : Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app
set " launchcmd=start conhost.exe %psc% "
: : This code disables QuickEdit for the current cmd.exe session without making permanent registry changes
) else (
: : It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error
set " launchcmd= %psc% "
)
: : Disable QuickEdit in current session
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%
set " d1=$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0); "
if defined terminal (
set " d2=$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128); "
start conhost.exe " !_batf! " %_args% -qedit
set " d3=$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128); "
start reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE% /f %nul1%
set " d4=$k=$t.CreateType(); $b=$k::SetConsoleMode($k::GetStdHandle(-10), 0x0080); "
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
)
%launchcmd% " %d1% %d2% %d3% %d4% & cmd.exe '/c' '!_PSarg! -qedit' " && ( exit /b) || ( set terminal = 1)
: skipQE
: skipQE
: :========================================================================================================================================
: :========================================================================================================================================
@ -294,9 +338,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 +366,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 %selfgit% & start %github% & start %mas% & exit /b)
)
)
)
)
@ -337,8 +391,13 @@ if not exist %SysPath%\%%# (
%eline%
%eline%
echo [%SysPath% \%% #] file is missing, aborting...
echo [%SysPath% \%% #] file is missing, aborting...
echo :
echo :
if not defined results (
call : dk_color %Blue% " Go back to Main Menu, select Troubleshoot and run DISM Restore and SFC Scan options. "
call : dk_color %Blue% " After that, restart system and try activation again. "
echo :
set fixes = %fixes% %mas% troubleshoot
set fixes = %fixes% %mas% troubleshoot
call : dk_color2 %Blue% " Help - " %_Yellow% " %mas% troubleshoot "
call : dk_color2 %Blue% " Check this webpage for help - " %_Yellow% " %mas% troubleshoot "
)
goto dk_done
goto dk_done
)
)
)
)
@ -363,7 +422,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 +440,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% " H elp - " %_Yellow% " %mas% evaluation_editions "
call : dk_color2 %Blue% " Check this webpage for h elp - " %_Yellow% " %mas% evaluation_editions "
goto dk_done
goto dk_done
)
)
)
)
@ -465,13 +524,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% " H elp - " %_Yellow% " %mas% troubleshoot "
call : dk_color2 %Blue% " Check this webpage for h elp - " %_Yellow% " %mas% troubleshoot "
)
)
echo :
echo :
goto dk_done
goto dk_done
@ -494,6 +553,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 +665,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 +684,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
@ -684,31 +742,37 @@ reg query HKLM\SYSTEM\CurrentControlSet\Services\wuauserv\%%G %nul% || (set wuco
)
)
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% " H elp - " %_Yellow% " %mas% remove_mal %w% ware "
call : dk_color2 %Blue% " Check this webpage for h elp - " %_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
: : Check Internet related error codes
if not defined wucorrupt if not defined wublock if not defined wuerror if not defined storeblock (
if %keyerror% EQU 0 if not defined _perm if defined _int (
if not defined wucorrupt if not defined wublock if not defined wuerror if not defined storeblock if not defined resfail (
echo " %error_code% " | findstr /i " 0x80072e 0x80072f 0x800704cf 0x87e10bcf 0x800705b4 " %nul% && (
echo " %error_code% " | findstr /i " 0x80072e 0x80072f 0x800704cf 0x87e10bcf 0x800705b4 " %nul% && (
call : dk_color %Red% " Checking Internet Issues [Found] %error_code% "
call : dk_color %Red% " Checking Internet Issues [Found] %error_code% "
set fixes = %fixes% %mas% licensing-servers-issue
set fixes = %fixes% %mas% licensing-servers-issue
call : dk_color2 %Blue% " H elp - " %_Yellow% " %mas% licensing-servers-issue "
call : dk_color2 %Blue% " Check this webpage for h elp - " %_Yellow% " %mas% licensing-servers-issue "
)
)
)
)
)
)
@ -722,11 +786,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% " H elp - " %_Yellow% " %mas% troubleshoot "
call : dk_color2 %Blue% " Check this webpage for h elp - " %_Yellow% " %mas% troubleshoot "
)
)
)
)
@ -760,10 +824,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 +973,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 +987,7 @@ set showfix=1
set error = 1
set error = 1
)
)
set generickey =
exit /b
exit /b
: : Activation command
: : Activation command
@ -954,6 +1026,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 +1073,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 $ P a t h ) { I n s t a l l L i c e n s e D i r " $ P a t h " }
If (Test-Path $ O e m ) { I n s t a l l L i c e n s e D i r " $ O e m " }
}
}
}
: xrm :
: xrm :
@ -1013,6 +1087,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 +1098,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. H elp - %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 h elp - %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 +1115,7 @@ exit /b
: dk_product
: dk_product
set d1 = %ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
set d1 = %ref% $meth = $TypeBuilder.DefinePInvokeMethod('BrandingFormatString', 'winbrand.dll', 'Public, Static', 1, [String], @([String]), 1, 3);
set d1 = %d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%% WINDOWS_LONG%% ')
set d1 = %d1% $meth.SetImplementationFlags(128); $TypeBuilder.CreateType()::BrandingFormatString('%% WINDOWS_LONG%% ') -replace [string][char]0xa9, '' -replace [string][char]0xae, '' -replace [string][char]0x2122, ''
set winos =
set winos =
for /f " delims= " %% s in ( '" %psc% %d1% "' ) do if not errorlevel 1 ( set winos = %% s)
for /f " delims= " %% s in ( '" %psc% %d1% "' ) do if not errorlevel 1 ( set winos = %% s)
@ -1096,19 +1171,19 @@ for %%# in (avira.com kaspersky.com virustotal.com mcafee.com) do (
find /i " %% # " %SysPath% \drivers\etc\hosts %nul% && set /a hcount += 1 )
find /i " %% # " %SysPath% \drivers\etc\hosts %nul% && set /a hcount += 1 )
if %hcount% == 4 set " results=[Antivirus URLs are blocked in hosts] "
if %hcount% == 4 set " results=[Antivirus URLs are blocked in hosts] "
sc start sppsvc %nul%
sc start %_slser% %nul%
echo " %errorlevel% " | findstr " 577 225 " %nul% && (
echo " %errorlevel% " | findstr " 577 225 " %nul% && (
set " results= %results% [Likely File Infector] "
set " results= %results% [Likely File Infector] "
) || (
) || (
if not exist %SysPath% \sppsvc.exe if not exist %SysPath% \alg.exe ( set " results= %results% [Likely File Infector] " )
if not exist %SysPath% \%_slexe% if not exist %SysPath% \alg.exe ( set " results= %results% [Likely File Infector] " )
)
)
if not " %results% %pupfound% " == " " (
if not " %results% %pupfound% " == " " (
if defined pupfound call : dk_color %Gray% " Checking PUP Activators [Found %pupfound% ] "
if defined pupfound call : dk_color %Gray% " Checking PUP Activators [Found %pupfound% ] "
if defined results call : dk_color %Red% " Checking Probable Mal %w% ware Infection... "
if defined results call : dk_color %Red% " Checking Probable Mal %w% ware Infection... "
if defined results call : dk_color %Red% " %results% "
if defined results ( call : dk_color %Red% " %results% " & set showfix = 1)
set fixes = %fixes% %mas% remove_mal%w% ware
set fixes = %fixes% %mas% remove_mal%w% ware
call : dk_color2 %Blue% " H elp - " %_Yellow% " %mas% remove_mal %w% ware "
call : dk_color2 %Blue% " Check this webpage for h elp - " %_Yellow% " %mas% remove_mal %w% ware "
echo :
echo :
)
)
@ -1180,6 +1255,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 +1304,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% " H elp - " %_Yellow% " %mas% fix_service "
call : dk_color2 %Blue% " Check this webpage for h elp - " %_Yellow% " %mas% fix_service "
set showfix = 1
set showfix = 1
)
)
)
)
@ -1244,15 +1320,15 @@ call :dk_color2 %Red% "Checking Boot Mode [%safeboot_option
)
)
: : https://learn.microsoft.com/windows-hardware/manufacture/desktop/windows-setup-states
: : https://learn.microsoft.com/en-us/ windows-hardware/manufacture/desktop/windows-setup-states
for /f " skip=2 tokens=2* " %% A in ( 'reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState' ) do ( set imagestate = %% B)
for /f " skip=2 tokens=2* " %% A in ( 'reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State" /v ImageState' ) do ( set imagestate = %% B)
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 +1357,11 @@ echo Checking WPA Registry Count [%wpainfo%]
)
)
if not defined office act if exist " %SystemRoot% \Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum " (
if not defined notwin act 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% " H elp - " %_Yellow% " %mas% evaluation_editions "
call : dk_color2 %Blue% " Check this webpage for h elp - " %_Yellow% " %mas% evaluation_editions "
)
)
)
)
@ -1305,26 +1380,27 @@ if "%osSKU%"=="164" set osedition=ProfessionalEducation
if " %osSKU% " == " 165 " set osedition = ProfessionalEducationN
if " %osSKU% " == " 165 " set osedition = ProfessionalEducationN
)
)
if not defined office act (
if not defined notwin act (
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
if not exist " %SystemRoot% \Servicing\Packages\Microsoft-Windows- %osedition% Edition*.mum " (
call : dk_color %Red% " Checking Package Files [Not Found] [ %osedition% ] "
call : dk_color %Red% " Checking Package Files [Not Found] [ %osedition% ] "
)
)
)
)
)
)
)
%psc% " try { $null=([WMISEARCHER]'SELECT * FROM %sps% ').Get().Version; exit 0 } catch { exit $_.Exception.InnerException.HResult } " %nul%
if %_wmic% EQU 1 wmic path %sps% get Version %nul%
if %_wmic% EQU 0 %psc% " try { $null=([WMISEARCHER]'SELECT * FROM %sps% ').Get().Version; exit 0 } catch { exit $_.Exception.InnerException.HResult } " %nul%
set error_code = %errorlevel%
set error_code = %errorlevel%
cmd /c exit /b %error_code%
cmd /c exit /b %error_code%
if %error_code% NEQ 0 set " error_code=0x %=ExitCode% "
if %error_code% NEQ 0 set " error_code=0x %=ExitCode% "
@ -1348,7 +1424,7 @@ set showfix=1
)
)
if not defined office act (
if not defined notwin act (
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 +1457,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 +1470,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 +1484,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. H elp - " %_Yellow% " %mas% issues_due_to_gaming_spoofers "
call : dk_color2 %Blue% " Most likely caused by gaming spoofers. Check this webpage for h elp - " %_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 +1534,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. "
)
)
)
)
)
@ -1514,7 +1591,7 @@ set "permerror=Error Found In SPP Registries"
)
)
)
)
REM https://learn.microsoft.com/office/troubleshoot/activation/license-issue-when-start-office-application
REM https://learn.microsoft.com/en-us/ office/troubleshoot/activation/license-issue-when-start-office-application
if not defined permerror (
if not defined permerror (
reg query " HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion " %nul% && (
reg query " HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion " %nul% && (
@ -1558,7 +1635,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 - m a t c h ' . * - . * - . * - . * - . * - ' ) {
if ($subkeyName - m a t c h ' 8 D E C 0 A F 1 - 0 3 4 1 - 4 b 9 3 - 8 5 C D - 7 2 6 0 6 C 2 D F 9 4 C . * ' ) {
$count++
$count++
}
}
}
}
@ -1567,7 +1644,7 @@ $minBuildNumber = 14393
if ($osVersion.Build - g e $ m i n B u i l d N u m b e r ) {
if ($osVersion.Build - g e $ m i n B u i l d N u m b e r ) {
$subkeyHashTable = @{}
$subkeyHashTable = @{}
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
if ($subkeyName - m a t c h ' . * - . * - . * - . * - . * - ' ) {
if ($subkeyName - m a t c h ' 8 D E C 0 A F 1 - 0 3 4 1 - 4 b 9 3 - 8 5 C D - 7 2 6 0 6 C 2 D F 9 4 C . * ' ) {
$keyNumber = $subkeyName -replace '.*-', ''
$keyNumber = $subkeyName -replace '.*-', ''
$subkeyHashTable[$keyNumber] = $true
$subkeyHashTable[$keyNumber] = $true
}
}
@ -1581,7 +1658,7 @@ if ($osVersion.Build -ge $minBuildNumber) {
}
}
}
}
$wpaKey.GetSubKeyNames() | ForEach-Object {
$wpaKey.GetSubKeyNames() | ForEach-Object {
if ($_ - m a t c h ' . * - . * - . * - . * - . * - ' ) {
if ($_ - m a t c h ' 8 D E C 0 A F 1 - 0 3 4 1 - 4 b 9 3 - 8 5 C D - 7 2 6 0 6 C 2 D F 9 4 C . * ' ) {
if ($PSVersionTable.PSVersion.Major - l t 3 ) {
if ($PSVersionTable.PSVersion.Major - l t 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 - n e 0 ) {
if ($LASTEXITCODE - n e 0 ) {
@ -1610,8 +1687,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 +1698,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
@ -1635,7 +1716,8 @@ if defined fixes (
call : dk_color %White% " Follow ALL the ABOVE blue lines. "
call : dk_color %White% " Follow ALL the ABOVE blue lines. "
call : dk_color2 %Blue% " Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore "
call : dk_color2 %Blue% " Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore "
choice /C:10 /N
choice /C:10 /N
if !errorlevel! == 1 ( for %% # in ( %fixes% ) do ( start %% #) )
if !errorlevel! == 2 exit /b
if !errorlevel! == 1 ( start %selfgit% & start %github% & for %% # in ( %fixes% ) do ( start %% #) )
)
)
if defined terminal (
if defined terminal (