From 805394463a694870feb489e9c07af1edd5c2ae38 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sun, 25 Jun 2023 18:09:47 +0200 Subject: [PATCH] Unload registry hive after editing --- scripts/Windows/Scripts/Context.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index e3670060..a99a8f84 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -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() {