mirror of
https://github.com/massgravel/Microsoft-Activation-Scripts.git
synced 2024-11-25 09:06:41 +00:00
Compare commits
No commits in common. "d384c5f2f79f12f8d4aa18797452e8839cb99cf3" and "b80a50208668e1cbb99a85f698f318d8fccc8379" have entirely different histories.
d384c5f2f7
...
b80a502086
@ -781,7 +781,7 @@ set "_xmlexist=if exist "%tdir%\GenuineTicket.xml""
|
|||||||
%_xmlexist% (
|
%_xmlexist% (
|
||||||
set error=1
|
set error=1
|
||||||
if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul%
|
if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul%
|
||||||
call :dk_color %Gray% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]"
|
call :dk_color %Red% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -2808,10 +2808,27 @@ set _sortIds=!_sortIds:PreInstallR_=Retail_!
|
|||||||
:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state
|
:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state
|
||||||
|
|
||||||
set _sidlist=
|
set _sidlist=
|
||||||
for /f "tokens=* delims=" %%a in ('%psc% "$p = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'; Get-ChildItem $p | ForEach-Object { $pi = (Get-ItemProperty """"$p\$($_.PSChildName)"""").ProfileImagePath; if ($pi -like '*\Users\*' -and (Test-Path """"$pi\NTUSER.DAT"""") -and -not ($_.PSChildName -match '\.bak$')) { Split-Path $_.PSPath -Leaf } }" %nul6%') do (if defined _sidlist (set _sidlist=!_sidlist! %%a) else (set _sidlist=%%a))
|
set failedload=
|
||||||
|
|
||||||
|
for /f "tokens=* delims=" %%a in ('%psc% "$p = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'; Get-ChildItem $p | ForEach-Object { $pi = (Get-ItemProperty """"$p\$($_.PSChildName)"""").ProfileImagePath; if ($_.PSChildName -match '^S-([^-\n]*-){5,}[^-\n]*$' -and (Test-Path """"$pi\NTUSER.DAT"""") -and -not ($_ -match '\.bak$')) { Split-Path $_.PSPath -Leaf } }" %nul6%') do (if defined _sidlist (set _sidlist=!_sidlist! %%a) else (set _sidlist=%%a))
|
||||||
|
|
||||||
|
:: Fallback method
|
||||||
|
if not defined _sidlist (
|
||||||
|
set failedload=1
|
||||||
|
for /f "delims=" %%a in ('%psc% "$explorerProc = Get-Process -Name explorer | Where-Object {$_.SessionId -eq (Get-Process -Id $pid).SessionId} | Select-Object -First 1; $sid = (gwmi -Query ('Select * From Win32_Process Where ProcessID=' + $explorerProc.Id)).GetOwnerSid().Sid; $sid" %nul6%') do (set _sidlist=%%a)
|
||||||
|
)
|
||||||
|
|
||||||
if not defined _sidlist (
|
if not defined _sidlist (
|
||||||
for /f "delims=" %%a in ('%psc% "$explorerProc = Get-Process -Name explorer | Where-Object {$_.SessionId -eq (Get-Process -Id $pid).SessionId} | Select-Object -First 1; $sid = (gwmi -Query ('Select * From Win32_Process Where ProcessID=' + $explorerProc.Id)).GetOwnerSid().Sid; $sid" %nul6%') do (set _sidlist=%%a)
|
set error=1
|
||||||
|
call :dk_color %Red% "Checking User Accounts SID [Not Found]"
|
||||||
|
exit /b
|
||||||
|
)
|
||||||
|
|
||||||
|
set /a counter=0
|
||||||
|
for %%# in (%_sidlist%) do set /a counter+=1
|
||||||
|
|
||||||
|
if %counter% GTR 10 (
|
||||||
|
call :dk_color %Gray% "Checking Total User Accounts [%counter%]"
|
||||||
)
|
)
|
||||||
|
|
||||||
::==========================
|
::==========================
|
||||||
@ -2819,18 +2836,14 @@ for /f "delims=" %%a in ('%psc% "$explorerProc = Get-Process -Name explorer | Wh
|
|||||||
:: Load the unloaded useraccounts registry
|
:: Load the unloaded useraccounts registry
|
||||||
|
|
||||||
set loadedsids=
|
set loadedsids=
|
||||||
set alrloadedsids=
|
|
||||||
|
|
||||||
for %%# in (%_sidlist%) do (
|
for %%# in (%_sidlist%) do (
|
||||||
reg query HKU\%%#\Software %nul% && (
|
reg query HKU\%%#\Software %nul% || (
|
||||||
call set "alrloadedsids=%%alrloadedsids%% %%#"
|
|
||||||
) || (
|
|
||||||
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do (
|
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do (
|
||||||
reg load HKU\%%# "%%b\NTUSER.DAT" %nul%
|
reg load HKU\%%# "%%b\NTUSER.DAT" %nul%
|
||||||
reg query HKU\%%#\Software %nul% && (
|
reg query HKU\%%#\Software %nul% && (
|
||||||
call set "loadedsids=%%loadedsids%% %%#"
|
call set "loadedsids=%%loadedsids%% %%#"
|
||||||
) || (
|
) || (
|
||||||
reg unload HKU\%%# %nul%
|
set failedload=1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -2838,23 +2851,6 @@ reg unload HKU\%%# %nul%
|
|||||||
|
|
||||||
::==========================
|
::==========================
|
||||||
|
|
||||||
set "_sidlist=%loadedsids% %alrloadedsids%"
|
|
||||||
|
|
||||||
set /a counter=0
|
|
||||||
for %%# in (%_sidlist%) do set /a counter+=1
|
|
||||||
|
|
||||||
if %counter% EQU 0 (
|
|
||||||
set error=1
|
|
||||||
call :dk_color %Red% "Checking User Accounts SID [Not Found]"
|
|
||||||
exit /b
|
|
||||||
)
|
|
||||||
|
|
||||||
if %counter% GTR 10 (
|
|
||||||
call :dk_color %Gray% "Checking Total User Accounts [%counter%]"
|
|
||||||
)
|
|
||||||
|
|
||||||
::==========================
|
|
||||||
|
|
||||||
:: Clear the vNext/shared/device license blocks which may prevent ohook activation
|
:: Clear the vNext/shared/device license blocks which may prevent ohook activation
|
||||||
|
|
||||||
rmdir /s /q "%ProgramData%\Microsoft\Office\Licenses\" %nul%
|
rmdir /s /q "%ProgramData%\Microsoft\Office\Licenses\" %nul%
|
||||||
@ -2909,23 +2905,24 @@ echo Clearing Office License Blocks [Successfully cleared from all %cou
|
|||||||
:: Some retail products attempt to validate the license and may show a banner "There was a problem checking this device's license status."
|
:: Some retail products attempt to validate the license and may show a banner "There was a problem checking this device's license status."
|
||||||
:: Resiliency registry entry can skip this check
|
:: Resiliency registry entry can skip this check
|
||||||
|
|
||||||
set defname=DEFTEMP-%random%
|
set faileddef=
|
||||||
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v Default" %nul6%') do call set "defdat=%%b"
|
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v Default" %nul6%') do call set "defdat=%%b"
|
||||||
|
|
||||||
if defined o16c2r if defined officeact (
|
if defined o16c2r if defined officeact (
|
||||||
if exist "%defdat%\NTUSER.DAT" (
|
if exist "%defdat%\NTUSER.DAT" (
|
||||||
reg load HKU\%defname% "%defdat%\NTUSER.DAT" %nul%
|
reg load HKU\DEF_TEMP "%defdat%\NTUSER.DAT" %nul%
|
||||||
reg query HKU\%defname%\Software %nul% && (
|
reg query HKU\DEF_TEMP %nul% || set faileddef=1
|
||||||
reg add HKU\%defname%\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
reg add HKU\DEF_TEMP\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
||||||
|
reg unload HKU\DEF_TEMP %nul%
|
||||||
|
reg query HKU\DEF_TEMP %nul% && set faileddef=1
|
||||||
|
) else (
|
||||||
|
set faileddef=1
|
||||||
)
|
)
|
||||||
reg unload HKU\%defname% %nul%
|
|
||||||
)
|
|
||||||
|
|
||||||
for %%# in (%_sidlist%) do (
|
for %%# in (%_sidlist%) do (
|
||||||
reg delete HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /f %nul%
|
reg delete HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /f %nul%
|
||||||
reg add HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
reg add HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
||||||
)
|
)
|
||||||
echo Adding Registry to Skip License Check [Successfully added to all %counter% ^& future new user accounts]
|
echo Adding Reg Keys to Skip License Check [Successfully added to all %counter% ^& future new user accounts]
|
||||||
)
|
)
|
||||||
|
|
||||||
::==========================
|
::==========================
|
||||||
@ -2934,6 +2931,15 @@ echo Adding Registry to Skip License Check [Successfully added to all %counter
|
|||||||
|
|
||||||
for %%# in (%loadedsids%) do (
|
for %%# in (%loadedsids%) do (
|
||||||
reg unload HKU\%%# %nul%
|
reg unload HKU\%%# %nul%
|
||||||
|
reg query HKU\%%# %nul% && set failedload=1
|
||||||
|
)
|
||||||
|
|
||||||
|
if defined failedload (
|
||||||
|
call :dk_color %Gray% "Loading Unloading Registries [Failed for some user accounts]"
|
||||||
|
)
|
||||||
|
|
||||||
|
if defined faileddef (
|
||||||
|
call :dk_color %Gray% "Loading Unloading Registries [Failed for Default\NTUSER.DAT]"
|
||||||
)
|
)
|
||||||
|
|
||||||
exit /b
|
exit /b
|
||||||
@ -3919,7 +3925,7 @@ call :dk_color %Gray% "Stopping sppsvc Service [Failed]"
|
|||||||
%_xmlexist% (
|
%_xmlexist% (
|
||||||
set error=1
|
set error=1
|
||||||
if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul%
|
if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul%
|
||||||
call :dk_color %Gray% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]"
|
call :dk_color %Red% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -544,7 +544,7 @@ set "_xmlexist=if exist "%tdir%\GenuineTicket.xml""
|
|||||||
%_xmlexist% (
|
%_xmlexist% (
|
||||||
set error=1
|
set error=1
|
||||||
if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul%
|
if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul%
|
||||||
call :dk_color %Gray% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]"
|
call :dk_color %Red% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ call :dk_color %Gray% "Stopping sppsvc Service [Failed]"
|
|||||||
%_xmlexist% (
|
%_xmlexist% (
|
||||||
set error=1
|
set error=1
|
||||||
if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul%
|
if exist "%tdir%\*.xml" del /f /q "%tdir%\*.xml" %nul%
|
||||||
call :dk_color %Gray% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]"
|
call :dk_color %Red% "Installing GenuineTicket.xml [Failed with ClipSVC service restart, wait...]"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1106,10 +1106,27 @@ set _sortIds=!_sortIds:PreInstallR_=Retail_!
|
|||||||
:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state
|
:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state
|
||||||
|
|
||||||
set _sidlist=
|
set _sidlist=
|
||||||
for /f "tokens=* delims=" %%a in ('%psc% "$p = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'; Get-ChildItem $p | ForEach-Object { $pi = (Get-ItemProperty """"$p\$($_.PSChildName)"""").ProfileImagePath; if ($pi -like '*\Users\*' -and (Test-Path """"$pi\NTUSER.DAT"""") -and -not ($_.PSChildName -match '\.bak$')) { Split-Path $_.PSPath -Leaf } }" %nul6%') do (if defined _sidlist (set _sidlist=!_sidlist! %%a) else (set _sidlist=%%a))
|
set failedload=
|
||||||
|
|
||||||
|
for /f "tokens=* delims=" %%a in ('%psc% "$p = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'; Get-ChildItem $p | ForEach-Object { $pi = (Get-ItemProperty """"$p\$($_.PSChildName)"""").ProfileImagePath; if ($_.PSChildName -match '^S-([^-\n]*-){5,}[^-\n]*$' -and (Test-Path """"$pi\NTUSER.DAT"""") -and -not ($_ -match '\.bak$')) { Split-Path $_.PSPath -Leaf } }" %nul6%') do (if defined _sidlist (set _sidlist=!_sidlist! %%a) else (set _sidlist=%%a))
|
||||||
|
|
||||||
|
:: Fallback method
|
||||||
|
if not defined _sidlist (
|
||||||
|
set failedload=1
|
||||||
|
for /f "delims=" %%a in ('%psc% "$explorerProc = Get-Process -Name explorer | Where-Object {$_.SessionId -eq (Get-Process -Id $pid).SessionId} | Select-Object -First 1; $sid = (gwmi -Query ('Select * From Win32_Process Where ProcessID=' + $explorerProc.Id)).GetOwnerSid().Sid; $sid" %nul6%') do (set _sidlist=%%a)
|
||||||
|
)
|
||||||
|
|
||||||
if not defined _sidlist (
|
if not defined _sidlist (
|
||||||
for /f "delims=" %%a in ('%psc% "$explorerProc = Get-Process -Name explorer | Where-Object {$_.SessionId -eq (Get-Process -Id $pid).SessionId} | Select-Object -First 1; $sid = (gwmi -Query ('Select * From Win32_Process Where ProcessID=' + $explorerProc.Id)).GetOwnerSid().Sid; $sid" %nul6%') do (set _sidlist=%%a)
|
set error=1
|
||||||
|
call :dk_color %Red% "Checking User Accounts SID [Not Found]"
|
||||||
|
exit /b
|
||||||
|
)
|
||||||
|
|
||||||
|
set /a counter=0
|
||||||
|
for %%# in (%_sidlist%) do set /a counter+=1
|
||||||
|
|
||||||
|
if %counter% GTR 10 (
|
||||||
|
call :dk_color %Gray% "Checking Total User Accounts [%counter%]"
|
||||||
)
|
)
|
||||||
|
|
||||||
::==========================
|
::==========================
|
||||||
@ -1117,18 +1134,14 @@ for /f "delims=" %%a in ('%psc% "$explorerProc = Get-Process -Name explorer | Wh
|
|||||||
:: Load the unloaded useraccounts registry
|
:: Load the unloaded useraccounts registry
|
||||||
|
|
||||||
set loadedsids=
|
set loadedsids=
|
||||||
set alrloadedsids=
|
|
||||||
|
|
||||||
for %%# in (%_sidlist%) do (
|
for %%# in (%_sidlist%) do (
|
||||||
reg query HKU\%%#\Software %nul% && (
|
reg query HKU\%%#\Software %nul% || (
|
||||||
call set "alrloadedsids=%%alrloadedsids%% %%#"
|
|
||||||
) || (
|
|
||||||
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do (
|
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do (
|
||||||
reg load HKU\%%# "%%b\NTUSER.DAT" %nul%
|
reg load HKU\%%# "%%b\NTUSER.DAT" %nul%
|
||||||
reg query HKU\%%#\Software %nul% && (
|
reg query HKU\%%#\Software %nul% && (
|
||||||
call set "loadedsids=%%loadedsids%% %%#"
|
call set "loadedsids=%%loadedsids%% %%#"
|
||||||
) || (
|
) || (
|
||||||
reg unload HKU\%%# %nul%
|
set failedload=1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -1136,23 +1149,6 @@ reg unload HKU\%%# %nul%
|
|||||||
|
|
||||||
::==========================
|
::==========================
|
||||||
|
|
||||||
set "_sidlist=%loadedsids% %alrloadedsids%"
|
|
||||||
|
|
||||||
set /a counter=0
|
|
||||||
for %%# in (%_sidlist%) do set /a counter+=1
|
|
||||||
|
|
||||||
if %counter% EQU 0 (
|
|
||||||
set error=1
|
|
||||||
call :dk_color %Red% "Checking User Accounts SID [Not Found]"
|
|
||||||
exit /b
|
|
||||||
)
|
|
||||||
|
|
||||||
if %counter% GTR 10 (
|
|
||||||
call :dk_color %Gray% "Checking Total User Accounts [%counter%]"
|
|
||||||
)
|
|
||||||
|
|
||||||
::==========================
|
|
||||||
|
|
||||||
:: Clear the vNext/shared/device license blocks which may prevent ohook activation
|
:: Clear the vNext/shared/device license blocks which may prevent ohook activation
|
||||||
|
|
||||||
rmdir /s /q "%ProgramData%\Microsoft\Office\Licenses\" %nul%
|
rmdir /s /q "%ProgramData%\Microsoft\Office\Licenses\" %nul%
|
||||||
@ -1207,23 +1203,24 @@ echo Clearing Office License Blocks [Successfully cleared from all %cou
|
|||||||
:: Some retail products attempt to validate the license and may show a banner "There was a problem checking this device's license status."
|
:: Some retail products attempt to validate the license and may show a banner "There was a problem checking this device's license status."
|
||||||
:: Resiliency registry entry can skip this check
|
:: Resiliency registry entry can skip this check
|
||||||
|
|
||||||
set defname=DEFTEMP-%random%
|
set faileddef=
|
||||||
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v Default" %nul6%') do call set "defdat=%%b"
|
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v Default" %nul6%') do call set "defdat=%%b"
|
||||||
|
|
||||||
if defined o16c2r if defined officeact (
|
if defined o16c2r if defined officeact (
|
||||||
if exist "%defdat%\NTUSER.DAT" (
|
if exist "%defdat%\NTUSER.DAT" (
|
||||||
reg load HKU\%defname% "%defdat%\NTUSER.DAT" %nul%
|
reg load HKU\DEF_TEMP "%defdat%\NTUSER.DAT" %nul%
|
||||||
reg query HKU\%defname%\Software %nul% && (
|
reg query HKU\DEF_TEMP %nul% || set faileddef=1
|
||||||
reg add HKU\%defname%\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
reg add HKU\DEF_TEMP\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
||||||
|
reg unload HKU\DEF_TEMP %nul%
|
||||||
|
reg query HKU\DEF_TEMP %nul% && set faileddef=1
|
||||||
|
) else (
|
||||||
|
set faileddef=1
|
||||||
)
|
)
|
||||||
reg unload HKU\%defname% %nul%
|
|
||||||
)
|
|
||||||
|
|
||||||
for %%# in (%_sidlist%) do (
|
for %%# in (%_sidlist%) do (
|
||||||
reg delete HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /f %nul%
|
reg delete HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /f %nul%
|
||||||
reg add HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
reg add HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
||||||
)
|
)
|
||||||
echo Adding Registry to Skip License Check [Successfully added to all %counter% ^& future new user accounts]
|
echo Adding Reg Keys to Skip License Check [Successfully added to all %counter% ^& future new user accounts]
|
||||||
)
|
)
|
||||||
|
|
||||||
::==========================
|
::==========================
|
||||||
@ -1232,6 +1229,15 @@ echo Adding Registry to Skip License Check [Successfully added to all %counter
|
|||||||
|
|
||||||
for %%# in (%loadedsids%) do (
|
for %%# in (%loadedsids%) do (
|
||||||
reg unload HKU\%%# %nul%
|
reg unload HKU\%%# %nul%
|
||||||
|
reg query HKU\%%# %nul% && set failedload=1
|
||||||
|
)
|
||||||
|
|
||||||
|
if defined failedload (
|
||||||
|
call :dk_color %Gray% "Loading Unloading Registries [Failed for some user accounts]"
|
||||||
|
)
|
||||||
|
|
||||||
|
if defined faileddef (
|
||||||
|
call :dk_color %Gray% "Loading Unloading Registries [Failed for Default\NTUSER.DAT]"
|
||||||
)
|
)
|
||||||
|
|
||||||
exit /b
|
exit /b
|
||||||
|
@ -1207,10 +1207,27 @@ exit /b
|
|||||||
:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state
|
:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state
|
||||||
|
|
||||||
set _sidlist=
|
set _sidlist=
|
||||||
for /f "tokens=* delims=" %%a in ('%psc% "$p = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'; Get-ChildItem $p | ForEach-Object { $pi = (Get-ItemProperty """"$p\$($_.PSChildName)"""").ProfileImagePath; if ($pi -like '*\Users\*' -and (Test-Path """"$pi\NTUSER.DAT"""") -and -not ($_.PSChildName -match '\.bak$')) { Split-Path $_.PSPath -Leaf } }" %nul6%') do (if defined _sidlist (set _sidlist=!_sidlist! %%a) else (set _sidlist=%%a))
|
set failedload=
|
||||||
|
|
||||||
|
for /f "tokens=* delims=" %%a in ('%psc% "$p = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'; Get-ChildItem $p | ForEach-Object { $pi = (Get-ItemProperty """"$p\$($_.PSChildName)"""").ProfileImagePath; if ($_.PSChildName -match '^S-([^-\n]*-){5,}[^-\n]*$' -and (Test-Path """"$pi\NTUSER.DAT"""") -and -not ($_ -match '\.bak$')) { Split-Path $_.PSPath -Leaf } }" %nul6%') do (if defined _sidlist (set _sidlist=!_sidlist! %%a) else (set _sidlist=%%a))
|
||||||
|
|
||||||
|
:: Fallback method
|
||||||
|
if not defined _sidlist (
|
||||||
|
set failedload=1
|
||||||
|
for /f "delims=" %%a in ('%psc% "$explorerProc = Get-Process -Name explorer | Where-Object {$_.SessionId -eq (Get-Process -Id $pid).SessionId} | Select-Object -First 1; $sid = (gwmi -Query ('Select * From Win32_Process Where ProcessID=' + $explorerProc.Id)).GetOwnerSid().Sid; $sid" %nul6%') do (set _sidlist=%%a)
|
||||||
|
)
|
||||||
|
|
||||||
if not defined _sidlist (
|
if not defined _sidlist (
|
||||||
for /f "delims=" %%a in ('%psc% "$explorerProc = Get-Process -Name explorer | Where-Object {$_.SessionId -eq (Get-Process -Id $pid).SessionId} | Select-Object -First 1; $sid = (gwmi -Query ('Select * From Win32_Process Where ProcessID=' + $explorerProc.Id)).GetOwnerSid().Sid; $sid" %nul6%') do (set _sidlist=%%a)
|
set error=1
|
||||||
|
call :dk_color %Red% "Checking User Accounts SID [Not Found]"
|
||||||
|
exit /b
|
||||||
|
)
|
||||||
|
|
||||||
|
set /a counter=0
|
||||||
|
for %%# in (%_sidlist%) do set /a counter+=1
|
||||||
|
|
||||||
|
if %counter% GTR 10 (
|
||||||
|
call :dk_color %Gray% "Checking Total User Accounts [%counter%]"
|
||||||
)
|
)
|
||||||
|
|
||||||
::==========================
|
::==========================
|
||||||
@ -1218,18 +1235,14 @@ for /f "delims=" %%a in ('%psc% "$explorerProc = Get-Process -Name explorer | Wh
|
|||||||
:: Load the unloaded useraccounts registry
|
:: Load the unloaded useraccounts registry
|
||||||
|
|
||||||
set loadedsids=
|
set loadedsids=
|
||||||
set alrloadedsids=
|
|
||||||
|
|
||||||
for %%# in (%_sidlist%) do (
|
for %%# in (%_sidlist%) do (
|
||||||
reg query HKU\%%#\Software %nul% && (
|
reg query HKU\%%#\Software %nul% || (
|
||||||
call set "alrloadedsids=%%alrloadedsids%% %%#"
|
|
||||||
) || (
|
|
||||||
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do (
|
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do (
|
||||||
reg load HKU\%%# "%%b\NTUSER.DAT" %nul%
|
reg load HKU\%%# "%%b\NTUSER.DAT" %nul%
|
||||||
reg query HKU\%%#\Software %nul% && (
|
reg query HKU\%%#\Software %nul% && (
|
||||||
call set "loadedsids=%%loadedsids%% %%#"
|
call set "loadedsids=%%loadedsids%% %%#"
|
||||||
) || (
|
) || (
|
||||||
reg unload HKU\%%# %nul%
|
set failedload=1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -1237,23 +1250,6 @@ reg unload HKU\%%# %nul%
|
|||||||
|
|
||||||
::==========================
|
::==========================
|
||||||
|
|
||||||
set "_sidlist=%loadedsids% %alrloadedsids%"
|
|
||||||
|
|
||||||
set /a counter=0
|
|
||||||
for %%# in (%_sidlist%) do set /a counter+=1
|
|
||||||
|
|
||||||
if %counter% EQU 0 (
|
|
||||||
set error=1
|
|
||||||
call :dk_color %Red% "Checking User Accounts SID [Not Found]"
|
|
||||||
exit /b
|
|
||||||
)
|
|
||||||
|
|
||||||
if %counter% GTR 10 (
|
|
||||||
call :dk_color %Gray% "Checking Total User Accounts [%counter%]"
|
|
||||||
)
|
|
||||||
|
|
||||||
::==========================
|
|
||||||
|
|
||||||
:: Clear the vNext/shared/device license blocks which may prevent ohook activation
|
:: Clear the vNext/shared/device license blocks which may prevent ohook activation
|
||||||
|
|
||||||
rmdir /s /q "%ProgramData%\Microsoft\Office\Licenses\" %nul%
|
rmdir /s /q "%ProgramData%\Microsoft\Office\Licenses\" %nul%
|
||||||
@ -1308,23 +1304,24 @@ echo Clearing Office License Blocks [Successfully cleared from all %cou
|
|||||||
:: Some retail products attempt to validate the license and may show a banner "There was a problem checking this device's license status."
|
:: Some retail products attempt to validate the license and may show a banner "There was a problem checking this device's license status."
|
||||||
:: Resiliency registry entry can skip this check
|
:: Resiliency registry entry can skip this check
|
||||||
|
|
||||||
set defname=DEFTEMP-%random%
|
set faileddef=
|
||||||
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v Default" %nul6%') do call set "defdat=%%b"
|
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v Default" %nul6%') do call set "defdat=%%b"
|
||||||
|
|
||||||
if defined o16c2r if defined officeact (
|
if defined o16c2r if defined officeact (
|
||||||
if exist "%defdat%\NTUSER.DAT" (
|
if exist "%defdat%\NTUSER.DAT" (
|
||||||
reg load HKU\%defname% "%defdat%\NTUSER.DAT" %nul%
|
reg load HKU\DEF_TEMP "%defdat%\NTUSER.DAT" %nul%
|
||||||
reg query HKU\%defname%\Software %nul% && (
|
reg query HKU\DEF_TEMP %nul% || set faileddef=1
|
||||||
reg add HKU\%defname%\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
reg add HKU\DEF_TEMP\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
||||||
|
reg unload HKU\DEF_TEMP %nul%
|
||||||
|
reg query HKU\DEF_TEMP %nul% && set faileddef=1
|
||||||
|
) else (
|
||||||
|
set faileddef=1
|
||||||
)
|
)
|
||||||
reg unload HKU\%defname% %nul%
|
|
||||||
)
|
|
||||||
|
|
||||||
for %%# in (%_sidlist%) do (
|
for %%# in (%_sidlist%) do (
|
||||||
reg delete HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /f %nul%
|
reg delete HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /f %nul%
|
||||||
reg add HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
reg add HKU\%%#\Software\Microsoft\Office\16.0\Common\Licensing\Resiliency /v "TimeOfLastHeartbeatFailure" /t REG_SZ /d "2040-01-01T00:00:00Z" /f %nul%
|
||||||
)
|
)
|
||||||
echo Adding Registry to Skip License Check [Successfully added to all %counter% ^& future new user accounts]
|
echo Adding Reg Keys to Skip License Check [Successfully added to all %counter% ^& future new user accounts]
|
||||||
)
|
)
|
||||||
|
|
||||||
::==========================
|
::==========================
|
||||||
@ -1333,6 +1330,15 @@ echo Adding Registry to Skip License Check [Successfully added to all %counter
|
|||||||
|
|
||||||
for %%# in (%loadedsids%) do (
|
for %%# in (%loadedsids%) do (
|
||||||
reg unload HKU\%%# %nul%
|
reg unload HKU\%%# %nul%
|
||||||
|
reg query HKU\%%# %nul% && set failedload=1
|
||||||
|
)
|
||||||
|
|
||||||
|
if defined failedload (
|
||||||
|
call :dk_color %Gray% "Loading Unloading Registries [Failed for some user accounts]"
|
||||||
|
)
|
||||||
|
|
||||||
|
if defined faileddef (
|
||||||
|
call :dk_color %Gray% "Loading Unloading Registries [Failed for Default\NTUSER.DAT]"
|
||||||
)
|
)
|
||||||
|
|
||||||
exit /b
|
exit /b
|
||||||
|
@ -37,7 +37,7 @@ irm https://massgrave.dev/get | iex
|
|||||||
|
|
||||||
### Method 2 - Traditional (Windows 7 and later)
|
### Method 2 - Traditional (Windows 7 and later)
|
||||||
|
|
||||||
1. Download the file under the code button from [GitHub](https://github.com/massgravel/Microsoft-Activation-Scripts) / [Azure DevOps](https://dev.azure.com/massgrave/_git/Microsoft-Activation-Scripts) / [Self-hosted Git](https://git.activated.win/massgrave/Microsoft-Activation-Scripts)
|
1. Download the file under the code button from [GitHub](https://github.com/massgravel/Microsoft-Activation-Scripts) / [Azure DevOps](https://dev.azure.com/massgrave/_git/Microsoft-Activation-Scripts)
|
||||||
2. Right-click on the downloaded zip file and extract
|
2. Right-click on the downloaded zip file and extract
|
||||||
3. In the extracted folder, find the folder named `All-In-One-Version`
|
3. In the extracted folder, find the folder named `All-In-One-Version`
|
||||||
4. Run the file named `MAS_AIO.cmd`
|
4. Run the file named `MAS_AIO.cmd`
|
||||||
|
Loading…
Reference in New Issue
Block a user