From 0b2e2744b0280a455562a942fdabb94107d24779 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sun, 25 Jun 2023 16:48:21 +0200 Subject: [PATCH] Refactor registry value handling --- scripts/Windows/Scripts/Context.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index bb3205ffe..f1087c48a 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -91,7 +91,7 @@ class Context { } [void] RegisterReboot([Microsoft.Win32.RegistryKey] $userKey) { - $null = New-ItemProperty -Path $this.GetRunOnceKey($userKey) -Name $this.RunOnceName -Value "pwsh `"$($this.EntryPoint)`"" -PropertyType ExpandString; + $null = $this.GetRunOnceKey($userKey).SetValue($this.RunOnceName, "pwsh `"$($this.EntryPoint)`"", "ExpandString"); } [void] RegisterNewUserReboot() { @@ -99,7 +99,7 @@ class Context { } [void] DeregisterNewUserReboot() { - $this.ProcessDefaultUserKey({ param ($root) Remove-ItemProperty $this.GetRunOnceKey($root) -Name $this.RunOnceName }); + $this.ProcessDefaultUserKey({ param ($root) $this.GetRunOnceKey($root).DeleteValue($this.RunOnceName) }); } [void] Reboot() {