检查批处理文件中的命令是否成功 [英] check if command was successful in a batch file

查看:155
本文介绍了检查批处理文件中的命令是否成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在批处理文件中检查命令

How within a batch file to check if command

start "" javaw -jar %~p0/example.jar

成功或产生错误?

我想使用if / else语句来回显这个信息。

I want to use if/else statements to echo this info out.

推荐答案

你可以使用

if errorlevel 1 echo Unsuccessful

在某些情况下。这取决于最后一个返回正确退出代码的命令。如果您的程序正常返回,即使出现异常情况,您也无法判断是否有任何错误。

in some cases. This depends on the last command returning a proper exit code. You won't be able to tell that there is anything wrong if your program returns normally even if there was an abnormal condition.

这篇关于检查批处理文件中的命令是否成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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