From 066a3975736fd3819b6f6665f2fb49ea887c92ba Mon Sep 17 00:00:00 2001 From: Lightemerald Date: Mon, 6 Nov 2023 13:17:13 +0100 Subject: [PATCH] Better unloading --- setupReg.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/setupReg.ps1 b/setupReg.ps1 index 4b7bf1a..745e2ed 100644 --- a/setupReg.ps1 +++ b/setupReg.ps1 @@ -86,7 +86,13 @@ function SetupEleveReg { } Write-Host "Added registry entries" 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 { Write-Host "Unable to get the user's HKU registry." }