Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Commit

Permalink
(GH-516) Guard all Wait-Process if posh v3+
Browse files Browse the repository at this point in the history
 - This adds Wait-Process to anywhere Start-Process is called with a guard that
this should only be done in PowerShell v3+.
  • Loading branch information
ferventcoder committed Jul 11, 2014
1 parent 061f5c3 commit 69d2f6a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/functions/Chocolatey-Pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ param(

Write-Host "Calling `'$nugetExe $packageArgs`'."

Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile
$process = Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile -PassThru
if ($host.Version.Major -ge 3) { Wait-Process -InputObject $process }

$nugetOutput = Get-Content $logFile -Encoding Ascii
foreach ($line in $nugetOutput) {
Expand Down
3 changes: 2 additions & 1 deletion src/functions/Chocolatey-Push.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ param(

Write-Host "Calling `'$nugetExe $packageArgs`'. This may take a few minutes. Please wait for the command to finish." -ForegroundColor $Note -BackgroundColor Black

Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile
$process = Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile -PassThru
if ($host.Version.Major -ge 3) { Wait-Process -InputObject $process }

$nugetOutput = Get-Content $logFile -Encoding Ascii
foreach ($line in $nugetOutput) {
Expand Down
5 changes: 3 additions & 2 deletions src/functions/Chocolatey-Python.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ param(
#& cmd.exe $packagesArgs | Tee-Object -FilePath $chocoInstallLog

Write-Host "Opening minimized PowerShell window and calling `'cmd.exe $packageArgs`'. If progress is taking a long time, please check that window. It also may not be 100% silent..." -ForegroundColor $Warning -BackgroundColor Black
Start-Process -FilePath "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy unrestricted -Command `"cmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`'`"" -Wait -WindowStyle Minimized

$process = Start-Process -FilePath "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy unrestricted -Command `"cmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`'`"" -Wait -WindowStyle Minimized -PassThru
if ($host.Version.Major -ge 3) { Wait-Process -InputObject $process }

Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
foreach ($line in $installOutput) {
Expand Down
1 change: 1 addition & 0 deletions src/helpers/functions/Get-CheckSumValid.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ param(

Write-Debug "Calling command [`'$checksumExe`' -c$checksum `"$file`"] to retrieve checksum"
$process = Start-Process "$checksumExe" -ArgumentList " -c=`"$checksum`" -t=`"$checksumType`" -f=`"$file`"" -Wait -WindowStyle Hidden -PassThru
if ($host.Version.Major -ge 3) { Wait-Process -InputObject $process }

Write-Debug "`'$checksumExe`' exited with $($process.ExitCode)"

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/functions/Get-ChocolateyUnzip.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ param(
$unzipOps = {
param($7zip, $destination, $fileFullPath, [ref]$exitCodeRef)
$p = Start-Process $7zip -ArgumentList "x -o`"$destination`" -y `"$fileFullPath`"" -Wait -WindowStyle Hidden -PassThru
Wait-Process -InputObject $p
if ($host.Version.Major -ge 3) { Wait-Process -InputObject $p }
$exitCodeRef.Value = $p.ExitCode
}

Expand Down

0 comments on commit 69d2f6a

Please sign in to comment.