我正在尝试编写一个Powershell工具控制脚本,该脚本使用&运算符调用其他“ .EXE”程序。示例:
$cmd = ".\buffalo_wing.exe"
& $cmd "--really_hot" "--extra_spicy"
# ok now my command has failed by returning non-zero value...
# but powershell keeps on going like the energizer bunny..
我尝试设置:
$ErrorActionPreference="Stop"
但无济于事。
答案 0 :(得分:0)
$cmd = ".\buffalo_wing.exe"
& $cmd "--really_hot" "-o wing.log"
if ($? -eq $false) {
write-host -background DarkBlue -foreground Red "<Error Exit>"
exit 1
}