Return error code from x.ps1
This commit is contained in:
parent
82cd953c7c
commit
9ea7142a01
7
x.ps1
7
x.ps1
@ -16,7 +16,14 @@ function Get-Application($app) {
|
|||||||
|
|
||||||
function Invoke-Application($application, $arguments) {
|
function Invoke-Application($application, $arguments) {
|
||||||
$process = Start-Process -NoNewWindow -PassThru $application $arguments
|
$process = Start-Process -NoNewWindow -PassThru $application $arguments
|
||||||
|
# WORKAROUND: Caching the handle is necessary to make ExitCode work.
|
||||||
|
# See https://stackoverflow.com/a/23797762
|
||||||
|
$handle = $process.Handle
|
||||||
$process.WaitForExit()
|
$process.WaitForExit()
|
||||||
|
if ($null -eq $process.ExitCode) {
|
||||||
|
Write-Error "Unable to read the exit code"
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
Exit $process.ExitCode
|
Exit $process.ExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user