忽略 Windows PowerShell (ISE) 中的错误级别 != 0 [英] Ignoring an errorlevel != 0 in Windows PowerShell (ISE)

查看:35
本文介绍了忽略 Windows PowerShell (ISE) 中的错误级别 != 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行外部 EXE 文件的脚本.当该 EXE 文件失败(将错误级别设置为 1)时,PowerShell 脚本将失败.

I have a script that runs an external EXE file. When that EXE file fails (sets errorlevel to 1), the PowerShell script fails.

我正在运行 curl.exe 并得到这个:

I'm running curl.exe and am getting this:

  • CategoryInfo : NotSpecified: (% Total % ... Time Current:String) [], RemoteException +fullyQualifiedErrorId : NativeCommandError

如何忽略/捕获外部 EXE 文件的故障并继续执行我的脚本?

How can I ignore/catch the failure of the external EXE file and continue with my script?

推荐答案

这与 EXE 返回的退出代码没有任何关系.当 EXE 写入 stderr 时会生成错误,但仅在 ISE 内或远程或使用后台作业时生成.

This doesn't have anything to do with the exit code returned by the EXE. An error is generated when an EXE writes to stderr, but only within the ISE or when remoting or using background jobs.

写入 stderr 的 EXE 不会从常规 PowerShell 命令提示符生成错误.我不知道为什么会这样.

An EXE that writes to stderr does not generate errors from the regular PowerShell command prompt. I'm not sure why this is the case.

这篇关于忽略 Windows PowerShell (ISE) 中的错误级别 != 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆