Allow registering startup script for the default user

This commit is contained in:
Manuel Thalmann 2024-08-21 18:20:11 +02:00
parent 18abc9e499
commit 682571eeba

View file

@ -70,6 +70,8 @@ $null = New-Module {
param( param(
[Parameter(ParameterSetName="System")] [Parameter(ParameterSetName="System")]
[switch] $System, [switch] $System,
[Parameter(ParameterSetName="DefaultUser", Mandatory)]
[switch] $DefaultUser,
[Parameter(ParameterSetName="User", Mandatory)] [Parameter(ParameterSetName="User", Mandatory)]
[switch] $User, [switch] $User,
[Parameter(ParameterSetName="User")] [Parameter(ParameterSetName="User")]
@ -77,6 +79,18 @@ $null = New-Module {
[RegistryKey] $UserKey [RegistryKey] $UserKey
) )
if ($DefaultUser.IsPresent) {
Edit-DefaultUserKey {
param(
[RegistryKey] $Key
)
Register-Setup -UserKey $Key;
}
return;
}
if ($User.IsPresent -or $UserKey) { if ($User.IsPresent -or $UserKey) {
if (-not $UserKey) { if (-not $UserKey) {
$UserKey = Get-Item "HKCU:\"; $UserKey = Get-Item "HKCU:\";
@ -159,15 +173,9 @@ $null = New-Module {
[switch] $CurrentUser [switch] $CurrentUser
) )
if ($DefaultUser.ToBool()) { if ($DefaultUser.IsPresent) {
Edit-DefaultUserKey { Register-Setup -DefaultUser;
param( } elseif ($CurrentUser.IsPresent) {
[RegistryKey] $Key
)
Register-Setup -UserKey $Key;
}
} elseif ($CurrentUser.ToBool()) {
Register-Setup -User; Register-Setup -User;
} else { } else {
Register-Setup; Register-Setup;