This commit is contained in:
2023-11-06 13:54:56 +01:00
parent 9d0cbff3a1
commit d95490ac73

View File

@@ -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."
}