From 73bede1aeb4d4ac181ff4635e7d9053e86f772a0 Mon Sep 17 00:00:00 2001 From: Olai Date: Sun, 26 May 2024 17:31:34 +0200 Subject: [PATCH] Warning about enableNumberedVersion Added a warning that the script will not run properly if a config is enabled --- Chrome Downloader.ps1 | 10 ++++++++-- README.md | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Chrome Downloader.ps1 b/Chrome Downloader.ps1 index 185247f..ea0f92f 100644 --- a/Chrome Downloader.ps1 +++ b/Chrome Downloader.ps1 @@ -128,6 +128,12 @@ if ($config.options.enableForcedVersion) { } } -if ($config.options.enableNumberedVersion) { - & $PSScriptRoot\Rename.ps1 +# 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 diff --git a/README.md b/README.md index 07d9c21..44d7210 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The script reads its configuration from a JSON file named `config.json` located - `enableRegularVersion`: Boolean flag to enable the downloading of the regular version of Chrome. - `enableForcedVersion`: Boolean flag to enable the downloading of the forced update version of Chrome. -- `enableNumberedVersion`: Boolean flag to enable the automatic renaming of the folder to the newest version of Chrome. +- `enableNumberedVersion`: Boolean flag to enable the automatic renaming of the folder to the newest version of Chrome **⚠️This config requires administrative privileges when executing the script!⚠️** - `logDateFormat`: A string defining the format of timestamps in log messages. #### Date Configuration