Skip to content

Commit e5372ce

Browse files
TheCakeIsNaOHcorbob
authored andcommitted
(#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.
1 parent b09a214 commit e5372ce

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,10 @@ Pro / Business supports a single, ubiquitous install directory option.
339339
"$msiArgs $additionalInstallArgs"
340340
}
341341
else {
342-
"$msiArgs $silentArgs $additionalInstallArgs"
342+
"$msiArgs $silentArgs"
343+
if ($additionalInstallArgs) {
344+
" " + $additionalInstallArgs
345+
}
343346
}
344347

345348
$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.
352355
$msiArgs = "$msiArgs $additionalInstallArgs";
353356
}
354357
else {
355-
$msiArgs = "$msiArgs $silentArgs $additionalInstallArgs";
358+
$msiArgs = "$msiArgs $silentArgs";
359+
if ($additionalInstallArgs) {
360+
$msiArgs += " " + $additionalInstallArgs
361+
}
356362
}
357363

358364
$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.
364370
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$additionalInstallArgs" $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory
365371
}
366372
else {
367-
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$silentArgs $additionalInstallArgs" $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory
373+
$exeArgs = $silentArgs
374+
if ($additionalInstallArgs) {
375+
$exeArgs += " " + $additionalInstallArgs
376+
}
377+
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin -Statements "$exeArgs" -ExeToRun $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory
368378
}
369379
}
370380

@@ -374,7 +384,10 @@ Pro / Business supports a single, ubiquitous install directory option.
374384
$msuArgs = "`"$fileFullPath`" $additionalInstallArgs"
375385
}
376386
else {
377-
$msuArgs = "`"$fileFullPath`" $silentArgs $additionalInstallArgs"
387+
$msuArgs = "`"$fileFullPath`" $silentArgs"
388+
if ($additionalInstallArgs) {
389+
$msuArgs += " " + $additionalInstallArgs
390+
}
378391
}
379392
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$msuArgs" "$($env:SystemRoot)\System32\wusa.exe" -validExitCodes $validExitCodes -workingDirectory $workingDirectory
380393
}

0 commit comments

Comments
 (0)