From fa31b353a2925d1c617898bf252faab616221800 Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Fri, 6 Jan 2023 10:08:59 -0600 Subject: [PATCH] (#2345) Do not add trailing space to arguments This prevents the addition of a trailing space after silent arguments in Install-ChocolateyInstallPackage when there are no additional arguments. --- .../Install-ChocolateyInstallPackage.ps1 | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 index 5945aa924f..5714e6de09 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 @@ -339,7 +339,10 @@ Pro / Business supports a single, ubiquitous install directory option. "$msiArgs $additionalInstallArgs" } else { - "$msiArgs $silentArgs $additionalInstallArgs" + "$msiArgs $silentArgs" + if ($additionalInstallArgs) { + " " + $additionalInstallArgs + } } $env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$msiArgs" "$($env:SystemRoot)\System32\msiexec.exe" -validExitCodes $validExitCodes -workingDirectory $workingDirectory @@ -352,7 +355,10 @@ Pro / Business supports a single, ubiquitous install directory option. $msiArgs = "$msiArgs $additionalInstallArgs"; } else { - $msiArgs = "$msiArgs $silentArgs $additionalInstallArgs"; + $msiArgs = "$msiArgs $silentArgs"; + if ($additionalInstallArgs) { + $msiArgs += " " + $additionalInstallArgs + } } $env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$msiArgs" "$($env:SystemRoot)\System32\msiexec.exe" -validExitCodes $validExitCodes -workingDirectory $workingDirectory @@ -364,7 +370,11 @@ Pro / Business supports a single, ubiquitous install directory option. $env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$additionalInstallArgs" $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory } else { - $env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$silentArgs $additionalInstallArgs" $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory + $exeArgs = $silentArgs + if ($additionalInstallArgs) { + $exeArgs += " " + $additionalInstallArgs + } + $env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin -Statements "$exeArgs" -ExeToRun $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory } } @@ -374,7 +384,10 @@ Pro / Business supports a single, ubiquitous install directory option. $msuArgs = "`"$fileFullPath`" $additionalInstallArgs" } else { - $msuArgs = "`"$fileFullPath`" $silentArgs $additionalInstallArgs" + $msuArgs = "`"$fileFullPath`" $silentArgs" + if ($additionalInstallArgs) { + $msuArgs += " " + $additionalInstallArgs + } } $env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$msuArgs" "$($env:SystemRoot)\System32\wusa.exe" -validExitCodes $validExitCodes -workingDirectory $workingDirectory }