Unload registry hive after editing

This commit is contained in:
Manuel Thalmann 2023-06-25 18:09:47 +02:00
parent b61c6d1d60
commit 805394463a

View file

@ -66,9 +66,11 @@ class Context {
[void] ProcessDefaultUserKey([System.Action[Microsoft.Win32.RegistryKey]] $action) {
$root = "HKLM:\DefaultUser";
$regRoot = $root.Replace(":", "");
$hivePath = "$env:SystemDrive\Users\Default\NTUSER.dat"
$null = & reg load $root.Replace(":", "") $hivePath;
$null = & reg load $regRoot $hivePath;
$action.Invoke((Get-Item $root));
reg unload $regRoot;
}
[Microsoft.Win32.RegistryKey] GetRunOnceKey() {