diff --git a/setupReg.ps1 b/setupReg.ps1 index 1c7ff67..426a012 100644 --- a/setupReg.ps1 +++ b/setupReg.ps1 @@ -10,8 +10,8 @@ function UserReg { $UserSID = $UserProfile.SID if( -not (Test-Path -Path "Registry::HKEY_USERS\$UserSID" -PathType Container) ) { Write-Host "REG LOAD HKEY_USERS\$UserSID C:\Users\$Username\NTUSER.DAT" - $res = REG LOAD HKEY_USERS\$UserSID "C:\Users\$Username\NTUSER.DAT" - if ($res -ne 0) { + $res = REG LOAD HKEY_USERS\$UserSID C:\Users\$Username\NTUSER.DAT + if ($res -e 1) { Write-Host "Failed to load $Username's HKU registry hive." return $null, $null } @@ -88,7 +88,10 @@ function SetupEleveReg { Write-Host "Added registry entries" Write-Host "Unloading registry HIVE" Write-Host "REG UNLOAD HKEY_USERS\$UserSID" - Start-Process powershell.exe -ArgumentList "REG UNLOAD HKEY_USERS\$UserSID" -WindowStyle Hidden + $res = REG UNLOAD HKEY_USERS\$UserSID + if ($res -e 1) { + Write-Host "Failed to unload $username's HKU registry hive." + } } else { Write-Host "Unable to get the user's HKU registry." }