We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 473f916 + 9ea7142 commit f557a4fCopy full SHA for f557a4f
x.ps1
@@ -16,7 +16,14 @@ function Get-Application($app) {
16
17
function Invoke-Application($application, $arguments) {
18
$process = Start-Process -NoNewWindow -PassThru $application $arguments
19
+ # WORKAROUND: Caching the handle is necessary to make ExitCode work.
20
+ # See https://stackoverflow.com/a/23797762
21
+ $handle = $process.Handle
22
$process.WaitForExit()
23
+ if ($null -eq $process.ExitCode) {
24
+ Write-Error "Unable to read the exit code"
25
+ Exit 1
26
+ }
27
Exit $process.ExitCode
28
}
29
0 commit comments