From 94f5657ea7698bce64bde297406e3f4d8688decb Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 27 Aug 2024 03:11:35 +0200 Subject: [PATCH] Allow rebooting without registering setup --- scripts/Windows/OS/Install.ps1 | 2 +- scripts/Windows/Scripts/PowerManagement.ps1 | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index 6d3c5a2f..545c41a6 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -593,7 +593,7 @@ $null = New-Module { if ($msAccount) { if (-not (Test-Admin)) { Invoke-OneShot DisableUAC; - Restart-Computer; + Restart-Intermediate -NoRegister; return; } diff --git a/scripts/Windows/Scripts/PowerManagement.ps1 b/scripts/Windows/Scripts/PowerManagement.ps1 index 20faed40..83e6579a 100644 --- a/scripts/Windows/Scripts/PowerManagement.ps1 +++ b/scripts/Windows/Scripts/PowerManagement.ps1 @@ -166,18 +166,22 @@ $null = New-Module { #> function Restart-Intermediate { param( - [Parameter(ParameterSetName="Default")] + [Parameter(ParameterSetName="None")] + [switch] $NoRegister, + [Parameter(ParameterSetName="Default", Mandatory)] [switch] $DefaultUser, [Parameter(ParameterSetName="Current", Mandatory)] [switch] $CurrentUser ) - if ($DefaultUser.IsPresent) { - Register-Setup -DefaultUser; - } elseif ($CurrentUser.IsPresent) { - Register-Setup -User; - } else { - Register-Setup; + if (-not $NoRegister.IsPresent) { + if ($DefaultUser.IsPresent) { + Register-Setup -DefaultUser; + } elseif ($CurrentUser.IsPresent) { + Register-Setup -User; + } else { + Register-Setup; + } } Restart-Computer -Force;