mirror of
https://github.com/massgravel/Microsoft-Activation-Scripts.git
synced 2024-12-02 18:05:09 +00:00
Compare commits
No commits in common. "73eabbff59964ef0386c014e5256d33981211f1a" and "deb74ab9b8d2652a4913683ed7e0cd63a8cc8d6f" have entirely different histories.
73eabbff59
...
deb74ab9b8
|
@ -458,10 +458,8 @@ goto :at_back
|
|||
:retokens
|
||||
|
||||
cls
|
||||
if not defined terminal (
|
||||
mode 125, 32
|
||||
if not defined terminal mode 125, 32
|
||||
%psc% "&{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;}"
|
||||
)
|
||||
title Fix Licensing ^(ClipSVC ^+ Office vNext ^+ SPP ^+ OSPP^)
|
||||
|
||||
echo:
|
||||
|
@ -502,13 +500,13 @@ echo:
|
|||
if %winbuild% LSS 10240 (
|
||||
echo ClipSVC Licence rebuilding is supported only on Win 10/11 and Server equivalent.
|
||||
echo Skipping...
|
||||
goto :rebuildspptok
|
||||
goto :cleanvnext
|
||||
)
|
||||
|
||||
%psc% "(([WMISEARCHER]'SELECT Name FROM SoftwareLicensingProduct WHERE LicenseStatus=1 AND GracePeriodRemaining=0 AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).Name" %nul2% | findstr /i "Windows" %nul1% && (
|
||||
%psc% "(([WMISEARCHER]'SELECT Name FROM SoftwareLicensingProduct WHERE LicenseStatus=1 AND GracePeriodRemaining=0 AND PartialProductKey IS NOT NULL').Get()).Name" %nul2% | findstr /i "Windows" %nul1% && (
|
||||
echo Windows is permanently activated.
|
||||
echo Skipping...
|
||||
goto :rebuildspptok
|
||||
echo Skipping rebuilding ClipSVC licences...
|
||||
goto :cleanvnext
|
||||
)
|
||||
|
||||
echo Stopping ClipSVC service...
|
||||
|
@ -591,14 +589,77 @@ echo [Successful]
|
|||
|
||||
echo:
|
||||
echo Restarting [wlidsvc LicenseManager] services...
|
||||
for %%# in (wlidsvc LicenseManager) do (%psc% "Start-Job { Restart-Service %%# } | Wait-Job -Timeout 10 | Out-Null")
|
||||
for %%# in (wlidsvc LicenseManager) do (%psc% Restart-Service %%# %nul%)
|
||||
|
||||
::========================================================================================================================================
|
||||
|
||||
:: Find remnants of Office vNext license block and remove it because it stops non vNext licenses from appearing
|
||||
:: https://learn.microsoft.com/en-us/office/troubleshoot/activation/reset-office-365-proplus-activation-state
|
||||
|
||||
:cleanvnext
|
||||
|
||||
echo:
|
||||
echo %line%
|
||||
echo:
|
||||
call :dk_color %Blue% "Clearing Office vNext License"
|
||||
echo:
|
||||
|
||||
setlocal DisableDelayedExpansion
|
||||
set "_Local=%LocalAppData%"
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
attrib -R "!ProgramData!\Microsoft\Office\Licenses" %nul%
|
||||
attrib -R "!_Local!\Microsoft\Office\Licenses" %nul%
|
||||
|
||||
if exist "!ProgramData!\Microsoft\Office\Licenses\" (
|
||||
rd /s /q "!ProgramData!\Microsoft\Office\Licenses\" %nul%
|
||||
if exist "!ProgramData!\Microsoft\Office\Licenses\" (
|
||||
echo Failed To Delete - !ProgramData!\Microsoft\Office\Licenses\
|
||||
) else (
|
||||
echo Deleted Folder - !ProgramData!\Microsoft\Office\Licenses\
|
||||
)
|
||||
) else (
|
||||
echo Not Found - !ProgramData!\Microsoft\Office\Licenses\
|
||||
)
|
||||
|
||||
if exist "!_Local!\Microsoft\Office\Licenses\" (
|
||||
rd /s /q "!_Local!\Microsoft\Office\Licenses\" %nul%
|
||||
if exist "!_Local!\Microsoft\Office\Licenses\" (
|
||||
echo Failed To Delete - !_Local!\Microsoft\Office\Licenses\
|
||||
) else (
|
||||
echo Deleted Folder - !_Local!\Microsoft\Office\Licenses\
|
||||
)
|
||||
) else (
|
||||
echo Not Found - !_Local!\Microsoft\Office\Licenses\
|
||||
)
|
||||
|
||||
|
||||
echo:
|
||||
for /f "tokens=* delims=" %%a in ('%psc% "Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' | ForEach-Object { Split-Path -Path $_.PSPath -Leaf }" %nul6%') do (if defined _sid (set "_sid=!_sid! HKU\%%a") else (set "_sid=HKU\%%a"))
|
||||
|
||||
set regfound=
|
||||
for %%# in (HKCU !_sid!) do (
|
||||
for %%A in (
|
||||
%%#\Software\Microsoft\Office\16.0\Common\Licensing
|
||||
%%#\Software\Microsoft\Office\16.0\Common\Identity
|
||||
%%#\Software\Microsoft\Office\16.0\Registration
|
||||
) do (
|
||||
reg query %%A %nul% && (
|
||||
set regfound=1
|
||||
reg delete %%A /f %nul% && (
|
||||
echo Deleted Registry - %%A
|
||||
) || (
|
||||
echo Failed to Delete - %%A
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
if not defined regfound echo Not Found - Office vNext Registry Keys
|
||||
|
||||
::========================================================================================================================================
|
||||
|
||||
:: Rebuild SPP Tokens
|
||||
|
||||
:rebuildspptok
|
||||
|
||||
echo:
|
||||
echo %line%
|
||||
echo:
|
||||
|
@ -613,6 +674,15 @@ call :dk_color %Red% "tokens.dat file not found."
|
|||
echo tokens.dat file: [%token%]
|
||||
)
|
||||
|
||||
echo:
|
||||
set wpainfo=
|
||||
for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1]);" %nul6%') do (set wpainfo=%%a)
|
||||
echo "%wpainfo%" | find /i "Error Found" %nul% && (
|
||||
call :dk_color %Red% "WPA Registry Error: %wpainfo%"
|
||||
) || (
|
||||
echo WPA Registry Count: %wpainfo%
|
||||
)
|
||||
|
||||
set tokenstore=
|
||||
for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore %nul6%') do call set "tokenstore=%%b"
|
||||
|
||||
|
@ -1100,6 +1170,44 @@ exit /b
|
|||
|
||||
::========================================================================================================================================
|
||||
|
||||
:: This code checks for invalid registry keys in HKLM\SYSTEM\WPA. This issue may appear even on healthy systems
|
||||
|
||||
:wpatest:
|
||||
$wpaKey = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64').OpenSubKey("SYSTEM\\WPA")
|
||||
$count = $wpaKey.SubKeyCount
|
||||
|
||||
$osVersion = [System.Environment]::OSVersion.Version
|
||||
$minBuildNumber = 14393
|
||||
|
||||
if ($osVersion.Build -ge $minBuildNumber) {
|
||||
$subkeyHashTable = @{}
|
||||
foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
|
||||
$keyNumber = $subkeyName -replace '.*-', ''
|
||||
$subkeyHashTable[$keyNumber] = $true
|
||||
}
|
||||
for ($i=1; $i -le $count; $i++) {
|
||||
if (-not $subkeyHashTable.ContainsKey("$i")) {
|
||||
Write-Host "Total Keys $count. Error Found- $i key does not exist"
|
||||
$wpaKey.Close()
|
||||
exit
|
||||
}
|
||||
}
|
||||
}
|
||||
$wpaKey.GetSubKeyNames() | ForEach-Object {
|
||||
$subkey = $wpaKey.OpenSubKey($_)
|
||||
$p = $subkey.GetValueNames()
|
||||
if (($p | Where-Object { $subkey.GetValueKind($_) -eq [Microsoft.Win32.RegistryValueKind]::Binary }).Count -eq 0) {
|
||||
Write-Host "Total Keys $count. Error Found- Binary Data is corrupt"
|
||||
$wpaKey.Close()
|
||||
exit
|
||||
}
|
||||
}
|
||||
$count
|
||||
$wpaKey.Close()
|
||||
:wpatest:
|
||||
|
||||
::========================================================================================================================================
|
||||
|
||||
:checkperms
|
||||
|
||||
set permerror=
|
||||
|
|
Loading…
Reference in a new issue