From e1b6038f4c8ed066e3930ef78d02b5db7999ded7 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 a405a6cb..c1dcf1e8 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -596,7 +596,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;