Unload registry hive after editing
This commit is contained in:
parent
b61c6d1d60
commit
805394463a
1 changed files with 3 additions and 1 deletions
|
@ -66,9 +66,11 @@ class Context {
|
||||||
|
|
||||||
[void] ProcessDefaultUserKey([System.Action[Microsoft.Win32.RegistryKey]] $action) {
|
[void] ProcessDefaultUserKey([System.Action[Microsoft.Win32.RegistryKey]] $action) {
|
||||||
$root = "HKLM:\DefaultUser";
|
$root = "HKLM:\DefaultUser";
|
||||||
|
$regRoot = $root.Replace(":", "");
|
||||||
$hivePath = "$env:SystemDrive\Users\Default\NTUSER.dat"
|
$hivePath = "$env:SystemDrive\Users\Default\NTUSER.dat"
|
||||||
$null = & reg load $root.Replace(":", "") $hivePath;
|
$null = & reg load $regRoot $hivePath;
|
||||||
$action.Invoke((Get-Item $root));
|
$action.Invoke((Get-Item $root));
|
||||||
|
reg unload $regRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Microsoft.Win32.RegistryKey] GetRunOnceKey() {
|
[Microsoft.Win32.RegistryKey] GetRunOnceKey() {
|
||||||
|
|
Loading…
Reference in a new issue