From 94c74c8468198cc12e8fa344ca41f28e7774ae1a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sun, 25 Jun 2023 15:36:58 +0200 Subject: [PATCH] Allow parameterless handling of reboot registration --- scripts/Windows/Scripts/Context.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index ebedbf2d..1433dd15 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -71,6 +71,10 @@ class Context { $action.Invoke((Get-Item $root)); } + [Microsoft.Win32.RegistryKey] GetRunOnceKey() { + return $this.GetRunOnceKey($null); + } + [Microsoft.Win32.RegistryKey] GetRunOnceKey([Microsoft.Win32.RegistryKey] $userKey) { if (-not $userKey) { $userKey = Get-Item "HKCU:\"; @@ -79,7 +83,11 @@ class Context { return Get-Item $userKey "$userKey\Software\Microsoft\Windows\CurrentVersion\RunOnce"; } - [void] RegisterReboot([Microsoft.Win32.RegistryKey] $userKey = $null) { + [void] RegisterReboot() { + $this.RegisterReboot($null); + } + + [void] RegisterReboot([Microsoft.Win32.RegistryKey] $userKey) { $null = New-ItemProperty -Path $this.GetRunOnceKey($userKey) -Name $this.RunOnceName -Value "pwsh `"$($this.EntryPoint)`"" -PropertyType ExpandString; }