Update
This commit is contained in:
26
setupReg.ps1
26
setupReg.ps1
@@ -87,14 +87,26 @@ function SetupEleveReg {
|
||||
}
|
||||
Write-Host "Added registry entries"
|
||||
Write-Host "Unloading registry HIVE"
|
||||
Start-Sleep -s 5
|
||||
Write-Host "REG UNLOAD HKEY_USERS\$UserSID"
|
||||
$res = REG UNLOAD HKEY_USERS\$UserSID
|
||||
if ($res -ne 0) {
|
||||
Write-Host "Failed to unload $username's HKU registry hive."
|
||||
$retryCount = 0
|
||||
$retryLimit = 5
|
||||
$success = $false
|
||||
|
||||
while (-not $success -and $retryCount -lt $retryLimit) {
|
||||
Start-Sleep -s 5
|
||||
Write-Host "REG UNLOAD HKEY_USERS\$UserSID (attempt $($retryCount + 1))"
|
||||
$res = REG UNLOAD HKEY_USERS\$UserSID
|
||||
if ($res -ne 0) {
|
||||
Write-Host "Failed to unload $username's HKU registry hive. Retrying in 5 seconds..."
|
||||
$retryCount++
|
||||
}
|
||||
else {
|
||||
Write-Host "Unloaded $username's HKU registry hive."
|
||||
$success = $true
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "Unloaded $username's HKU registry hive."
|
||||
|
||||
if (-not $success) {
|
||||
Write-Host "Failed to unload $username's HKU registry hive after $retryLimit attempts."
|
||||
}
|
||||
} else {
|
||||
Write-Host "Unable to get the user's HKU registry."
|
||||
|
||||
Reference in New Issue
Block a user