From 97af9654c943ba00247c64f61623963bbff1e26d Mon Sep 17 00:00:00 2001 From: Olai Date: Mon, 27 May 2024 09:00:26 +0200 Subject: [PATCH] Fixed a flaw in the admin check --- Chrome Downloader.ps1 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Chrome Downloader.ps1 b/Chrome Downloader.ps1 index f834628..051152b 100644 --- a/Chrome Downloader.ps1 +++ b/Chrome Downloader.ps1 @@ -128,12 +128,14 @@ if ($config.options.enableForcedVersion) { } } -# Check if the script is running with administrative privileges -if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { - Log-Message "Error: the config 'enableNumberedVersion' requires administrative privileges to run." -} -else { - if ($config.options.enableNumberedVersion) { - & $PSScriptRoot\Rename.ps1 - } +if ($config.options.enableNumberedVersion) { + # Check if the script is running with administrative privileges + if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { + Log-Message "Error: the config 'enableNumberedVersion' requires administrative privileges to run." + } + else { + if ($config.options.enableNumberedVersion) { + & $PSScriptRoot\Rename.ps1 + } + } } \ No newline at end of file