diff --git a/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 b/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 index 0d014c4dbc..90be131724 100644 --- a/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 @@ -166,6 +166,9 @@ param( Unregister-Event -SourceIdentifier "LogOutput_ChocolateyZipProc" Unregister-Event -SourceIdentifier "LogErrors_ChocolateyZipProc" + # sometimes the process hasn't fully exited yet. + Start-Sleep 2 + $exitCode = $process.ExitCode Set-PowerShellExitCode $exitCode $process.Dispose() diff --git a/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 b/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 index 6cc416035d..768d6a86cf 100644 --- a/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 +++ b/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 @@ -156,7 +156,7 @@ Elevating Permissions and running [`"$exeToRun`" $wrappedStatements]. This may t $process = New-Object System.Diagnostics.Process $process.EnableRaisingEvents = $true - Register-ObjectEvent -InputObject $process -SourceIdentifier "LogOutput_ChocolateyProc" -EventName OutputDataReceived -Action $writeOutput | Out-Null + Register-ObjectEvent -InputObject $process -SourceIdentifier "LogOutput_ChocolateyProc" -EventName OutputDataReceived -Action $writeOutput | Out-Null Register-ObjectEvent -InputObject $process -SourceIdentifier "LogErrors_ChocolateyProc" -EventName ErrorDataReceived -Action $writeError | Out-Null #$process.StartInfo = New-Object System.Diagnostics.ProcessStartInfo($exeToRun, $wrappedStatements) @@ -191,6 +191,9 @@ Elevating Permissions and running [`"$exeToRun`" $wrappedStatements]. This may t # them to do so. Without this it never finishes. Unregister-Event -SourceIdentifier "LogOutput_ChocolateyProc" Unregister-Event -SourceIdentifier "LogErrors_ChocolateyProc" + + # sometimes the process hasn't fully exited yet. + Start-Sleep 2 $exitCode = $process.ExitCode $process.Dispose()