From d025f4c6a3bcfc2272f57baff7497fd86cc6702a Mon Sep 17 00:00:00 2001 From: Olai Date: Thu, 30 May 2024 13:23:40 +0200 Subject: [PATCH] Updated JSON Names for Better Clarity Updated some JSON names for better clarity. --- Downloader.ps1 | 36 ++++++++++++++++++------------------ README.md | 22 +++++++++++----------- config.json | 8 ++++---- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Downloader.ps1 b/Downloader.ps1 index 93ca31c..f0b8fb4 100644 --- a/Downloader.ps1 +++ b/Downloader.ps1 @@ -59,7 +59,7 @@ function chrome-Log-Message { param ( [string]$message ) - if ($config.chrome.options.enableRegularVersion -or $config.chrome.options.enableForcedVersion) { + if ($config.chrome.options.downloadRegular -or $config.chrome.options.downloadForced) { $timestamp = Get-Date -Format $chromedateFormat Write-Output "[$timestamp] - $message" | Out-File -Append -FilePath "$PSScriptRoot\$chromelogFileNameFormat" -Encoding utf8 } @@ -76,7 +76,7 @@ function amazonworkspace-Log-Message { } # Check if both options are disabled and log a message -if (-not $config.chrome.options.enableRegularVersion -and -not $config.chrome.options.enableForcedVersion -and -not $config.amazonWorkspace.options.download) { +if (-not $config.chrome.options.downloadRegular -and -not $config.chrome.options.downloadForced -and -not $config.amazonWorkspace.options.download) { chrome-Log-Message "Warn: Neither Chrome or Amazon Workspaces is selected. Please enable at least one option to proceed." exit } @@ -86,10 +86,10 @@ if ($config.amazonWorkspace.logging.logName -eq $config.chrome.logging.logName) chrome-Log-Message "Debug: Script started" } else { - if ($config.chrome.options.enableRegularVersion) { + if ($config.chrome.options.downloadRegular) { chrome-Log-Message "Debug: Script started" } - elseif ($config.chrome.options.enableForcedVersion) { + elseif ($config.chrome.options.downloadForced) { chrome-Log-Message "Debug: Script started" } if ($config.amazonWorkspace.options.download) { @@ -153,7 +153,7 @@ $forceUpdateFolder = Join-Path -Path $PSScriptRoot -ChildPath "$chromeNaming VER $amazonworkspacedestinationFolder = Join-Path -Path $PSScriptRoot -ChildPath "$workspacesNaming VERSION" # Conditional execution based on config -if ($config.chrome.options.enableRegularVersion) { +if ($config.chrome.options.downloadRegular) { # Create main folder and files folder if they don't exist $folderName = "$chromeNaming VERSION" $folderPath = Join-Path -Path $PSScriptRoot -ChildPath $folderName @@ -197,7 +197,7 @@ if ($config.chrome.options.enableRegularVersion) { } } -if ($config.chrome.options.enableForcedVersion) { +if ($config.chrome.options.downloadForced) { # Create force update folder if it doesn't exist if (-not (Test-Path $forceUpdateFolder)) { try { @@ -217,7 +217,7 @@ if ($config.chrome.options.enableForcedVersion) { } # If the regular version is not enabled, download 64-bit Chrome installer directly to the force update folder - if (-not $config.chrome.options.enableRegularVersion) { + if (-not $config.chrome.options.downloadRegular) { $fileName1 = [System.IO.Path]::GetFileName($chrome64BitUrl) $filePath1 = Join-Path -Path $forceUpdateFolder -ChildPath $fileName1 try { @@ -277,19 +277,19 @@ try { } } -if ($config.chrome.options.folderNumberedVersion -or $config.amazonWorkspace.options.folderNumberedVersion) { +if ($config.chrome.options.folderNumber -or $config.amazonWorkspace.options.folderNumber) { # Check if the script is running with administrative privileges if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { if ($config.amazonWorkspace.logging.logName -eq $config.chrome.logging.logName) { - chrome-Log-Message "Error: the config 'folderNumberedVersion' requires administrative privileges to run." + chrome-Log-Message "Error: the config 'folderNumber' requires administrative privileges to run." } else { - chrome-Log-Message "Error: the config 'folderNumberedVersion' requires administrative privileges to run." - amazonworkspace-Log-Message "Error: the config 'folderNumberedVersion' requires administrative privileges to run." + chrome-Log-Message "Error: the config 'folderNumber' requires administrative privileges to run." + amazonworkspace-Log-Message "Error: the config 'folderNumber' requires administrative privileges to run." } } else { - if ($config.chrome.options.enableRegularVersion -and -not $config.chrome.options.enableForcedVersion) { + if ($config.chrome.options.downloadRegular -and -not $config.chrome.options.downloadForced) { $msiPath = "$PSScriptRoot\$chromeNaming VERSION\Files\googlechromestandaloneenterprise64.msi" Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$msiPath`" /quiet" -Wait $chromeRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" @@ -310,7 +310,7 @@ if ($config.chrome.options.folderNumberedVersion -or $config.amazonWorkspace.opt chrome-Log-Message "Warn: Chrome version could not be determined. Folder was not renamed." } } - elseif ($config.chrome.options.enableForcedVersion -and -not $config.chrome.options.enableRegularVersion) { + elseif ($config.chrome.options.downloadForced -and -not $config.chrome.options.downloadRegular) { $msiPath = "$PSScriptRoot\$chromeNaming VERSION_force_update\googlechromestandaloneenterprise64.msi" Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$msiPath`" /quiet" -Wait $chromeRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" @@ -331,7 +331,7 @@ if ($config.chrome.options.folderNumberedVersion -or $config.amazonWorkspace.opt chrome-Log-Message "Warn: Chrome version could not be determined. Folder was not renamed." } } - elseif ($config.chrome.options.enableForcedVersion -and $config.chrome.options.enableRegularVersion) { + elseif ($config.chrome.options.downloadForced -and $config.chrome.options.downloadRegular) { $msiPath = "$PSScriptRoot\$chromeNaming VERSION_force_update\googlechromestandaloneenterprise64.msi" Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$msiPath`" /quiet" -Wait @@ -389,10 +389,10 @@ if ($config.chrome.options.folderNumberedVersion -or $config.amazonWorkspace.opt Write-Output "For additional logs, please refer to $PSScriptRoot\$chromelogFileNameFormat." } else { - if ($config.chrome.options.enableRegularVersion) { + if ($config.chrome.options.downloadRegular) { Write-Output "For additional logs, please refer to $PSScriptRoot\$chromelogFileNameFormat." } - elseif ($config.chrome.options.enableForcedVersion) { + elseif ($config.chrome.options.downloadForced) { Write-Output "For additional logs, please refer to $PSScriptRoot\$chromelogFileNameFormat." } if ($config.amazonWorkspace.options.download) { @@ -406,10 +406,10 @@ else { Write-Output "For additional logs, please refer to $PSScriptRoot\$chromelogFileNameFormat." } else { - if ($config.chrome.options.enableRegularVersion) { + if ($config.chrome.options.downloadRegular) { Write-Output "For additional logs, please refer to $PSScriptRoot\$chromelogFileNameFormat." } - elseif ($config.chrome.options.enableForcedVersion) { + elseif ($config.chrome.options.downloadForced) { Write-Output "For additional logs, please refer to $PSScriptRoot\$chromelogFileNameFormat." } if ($config.amazonWorkspace.options.download) { diff --git a/README.md b/README.md index e84167f..265bd27 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ The `config.json` file should be structured as follows: { "chrome":{ "options": { - "enableRegularVersion": true, - "enableForcedVersion": false, - "folderNumberedVersion": false, + "downloadRegular": true, + "downloadForced": false, + "folderNumber": false, "checkExist": false, "folderName": "Chrome -" }, @@ -30,7 +30,7 @@ The `config.json` file should be structured as follows: "amazonWorkspace":{ "options": { "download": false, - "folderNumberedVersion": false, + "folderNumber": false, "checkExist": false, "folderName": "WorkSpaces -" }, @@ -46,8 +46,8 @@ The `config.json` file should be structured as follows: #### Options: --- ##### Chrome Specific: -- `enableRegularVersion`: A boolean flag to enable downloading and installing the regular version of Chrome. -- `enableForcedVersion`: A boolean flag to enable downloading and installing the forced update version of Chrome. +- `downloadRegular`: A boolean flag to enable downloading and installing the regular version of Chrome. +- `downloadForced`: A boolean flag to enable downloading and installing the forced update version of Chrome. ##### WorkSpaces Specific: @@ -56,13 +56,13 @@ The `config.json` file should be structured as follows: ##### Universal: -- `folderNumberedVersion`: A boolean flag to enable the automatic renaming of the folder to the newest version of Chrome. ⚠️ **This option requires administrative privileges when executing the script!** ⚠️ +- `folderNumber`: A boolean flag to enable the automatic renaming of the folder to the newest version of Chrome. ⚠️ **This option requires administrative privileges when executing the script!** ⚠️ - `checkExist`: A boolean flag to delete old Chrome folders when the script is executed. ⚠️ **This action will delete your Chrome folders, so ensure you have backups if you wish to retain them.** ⚠️ - `folderName`: A string defining the name of the folders. The default name is `Chrome -` and `WorkSpaces -`. #### Logging options: --- -- `logName`: A string defining the name of the log(s) file(s). The default name is `google_chrome` and `amazon_workspace`. +- `logName`: A string defining the name of the log(s) file(s). The default name is `google_chrome` and `amazon_workspaces`. - `logFormat`: A string defining the format of the log(s) file(s). The default format is `log`. - `logDateFormat`: A string defining the format of timestamps in logs. The default format is `dd/MM/yyyy HH:mm:ss`. - `clearLogs`: A boolean flag to enable clearing of the log(s) file(s). This will clear the content inside of the log file(s). @@ -113,7 +113,7 @@ Output: 29-06-2024 15:19:30 ### Numbered Version --- -`folderNumberedVersion`: Set this to `true` to enable automatic renaming of the folder based on the downloaded Chrome version. This action requires administrative privileges. +`folderNumber`: Set this to `true` to enable automatic renaming of the folder based on the downloaded Chrome version. This action requires administrative privileges. For example, if this option is enabled, the folders will be named as follows: @@ -127,7 +127,7 @@ Chrome - VERSION_force_update Chrome - 125.0.6422.113_force_update ``` -The `folderNumberedVersion` configuration requires administrative privileges because the only way to obtain the Chrome version number is by installing the MSI file and retrieving the version from the Windows registry. +The `folderNumber` configuration requires administrative privileges because the only way to obtain the Chrome version number is by installing the MSI file and retrieving the version from the Windows registry. ## Script Usage ### 1. Prepare the Environment: @@ -161,4 +161,4 @@ This command will clone the repository into your current directory. ### 4. Monitor the Logs: -- Check `google_chrome.log` or `amazon_workspace.log` in the script directory for detailed logs of the execution process, including any errors encountered. +- Check `google_chrome.log` or `amazon_workspaces.log` in the script directory for detailed logs of the execution process, including any errors encountered. diff --git a/config.json b/config.json index 72f3e84..de3f925 100644 --- a/config.json +++ b/config.json @@ -1,9 +1,9 @@ { "chrome":{ "options": { - "enableRegularVersion": true, - "enableForcedVersion": false, - "folderNumberedVersion": false, + "downloadRegular": true, + "downloadForced": false, + "folderNumber": false, "checkExist": false, "folderName": "Chrome -" }, @@ -17,7 +17,7 @@ "amazonWorkspace":{ "options": { "download": false, - "folderNumberedVersion": false, + "folderNumber": false, "checkExist": false, "folderName": "WorkSpaces -" },