Allow parameterless handling of reboot registration

This commit is contained in:
Manuel Thalmann 2023-06-25 15:36:58 +02:00
parent b4ed674a0a
commit 05478a43ef

View file

@ -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;
}