summaryrefslogtreecommitdiff
path: root/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd
diff options
context:
space:
mode:
Diffstat (limited to 'MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd')
-rw-r--r--MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd49
1 files changed, 29 insertions, 20 deletions
diff --git a/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd b/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd
index ec2e8c9..d912038 100644
--- a/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd
+++ b/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd
@@ -1106,7 +1106,15 @@ set _sortIds=!_sortIds:PreInstallR_=Retail_!
:: https://learn.microsoft.com/office/troubleshoot/activation/reset-office-365-proplus-activation-state
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 """"$Env:SystemDrive\Users\*"""" -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))
+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 (
set error=1
@@ -1126,8 +1134,6 @@ call :dk_color %Gray% "Checking Total User Accounts [%counter%]"
:: Load the unloaded useraccounts registry
set loadedsids=
-set failedtoload=
-set failedtounload=
for %%# in (%_sidlist%) do (
reg query HKU\%%#\Software %nul% || (
for /f "skip=2 tokens=2*" %%a in ('"reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%%#" /v ProfileImagePath" %nul6%') do (
@@ -1135,7 +1141,7 @@ reg load HKU\%%# "%%b\NTUSER.DAT" %nul%
reg query HKU\%%#\Software %nul% && (
call set "loadedsids=%%loadedsids%% %%#"
) || (
-set failedtoload=1
+set failedload=1
)
)
)
@@ -1197,13 +1203,19 @@ 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."
:: Resiliency registry entry can skip this check
+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"
+
if defined o16c2r if defined officeact (
-reg load HKU\DEF_TEMP %SystemDrive%\Users\Default\NTUSER.DAT %nul%
-reg query HKU\DEF_TEMP %nul% || set failedtoload=1
+if exist "%defdat%\NTUSER.DAT" (
+reg load HKU\DEF_TEMP "%defdat%\NTUSER.DAT" %nul%
+reg query HKU\DEF_TEMP %nul% || set faileddef=1
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 failedtounload=1
-
+reg query HKU\DEF_TEMP %nul% && set faileddef=1
+) else (
+set faileddef=1
+)
for %%# in (%_sidlist%) do (
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%
@@ -1217,19 +1229,15 @@ echo Adding Reg Keys to Skip License Check [Successfully added to all %counter
for %%# in (%loadedsids%) do (
reg unload HKU\%%# %nul%
-reg query HKU\%%# %nul% && set failedtounload=1
+reg query HKU\%%# %nul% && set failedload=1
)
-if defined failedtoload (
-set error=1
-call :dk_color %Red% "Loading Unloaded Accounts Registry [Failed for some user accounts]"
-call :dk_color %Blue% "Reboot your machine using the restart option and try again."
+if defined failedload (
+call :dk_color %Gray% "Loading Unloading Registries [Failed for some user accounts]"
)
-if defined failedtounload (
-set error=1
-call :dk_color %Red% "Unloading Loaded Account Registries [Failed for some user accounts]"
-call :dk_color %Blue% "Reboot your machine using the restart option and try again."
+if defined faileddef (
+call :dk_color %Gray% "Loading Unloading Registries [Failed for Default\NTUSER.DAT]"
)
exit /b
@@ -1673,9 +1681,9 @@ 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)
if /i not "%imagestate%"=="IMAGE_STATE_COMPLETE" (
-set error=1
-call :dk_color %Red% "Checking Windows Setup State [%imagestate%]"
+call :dk_color %Gray% "Checking Windows Setup State [%imagestate%]"
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."
)
@@ -1902,6 +1910,7 @@ for /f "delims=" %%a in ('%psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -
echo !taskinfo! | find /i "Ready" %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
+if "!taskinfo!"=="" set "taskinfo=Not Found"
call :dk_color %Red% "Checking SvcRestartTask Status [!taskinfo!, System might deactivate later]"
)
)
@@ -2044,7 +2053,7 @@ echo:
if %_unattended%==1 timeout /t 2 & exit /b
if defined fixes (
-call :dk_color2 %Blue% "Press [1] to Open Troubleshoot Page " %Gray% " Press [0] to Ignore"
+call :dk_color2 %Blue% "Press [1] to Open Support Webpage " %Gray% " Press [0] to Ignore"
choice /C:10 /N
if !errorlevel!==1 (for %%# in (%fixes%) do (start %%#))
)