Better unloading

This commit is contained in:
2023-11-06 13:17:13 +01:00
parent d5b9b22345
commit 066a397573

View File

@@ -86,7 +86,13 @@ function SetupEleveReg {
} }
Write-Host "Added registry entries" Write-Host "Added registry entries"
Write-Host "Unloading registry HIVE" Write-Host "Unloading registry HIVE"
Start-Process cmd -ArgumentList "/c REG UNLOAD HKEY_USERS\$UserSID" -Verb RunAs $res = REG UNLOAD HKEY_USERS\$UserSID
if ($res -ne 0) {
Write-Host "Failed to unload $username's HKU registry hive."
}
else {
Write-Host "Unloaded $username's HKU registry hive."
}
} else { } else {
Write-Host "Unable to get the user's HKU registry." Write-Host "Unable to get the user's HKU registry."
} }