[英]How to print the exit code of the last executed application in a Windows batch file?
I have a Unix shell script with the following code, which I want to turn into a Windows batch file:我有一个带有以下代码的 Unix shell 脚本,我想将其转换为 Windows 批处理文件:
./test.sh some arguments here
export a=$?
echo "RETURN CODE FROM UpgradeR16 = $a"
I've already rewritten test.sh
into test.bat
, but I'm not sure what the export
and echo
are doing here.我已经将test.sh
重写为test.bat
,但我不确定export
和echo
在这里做了什么。 How do I write the equivalent code in a Windows .bat file?如何在 Windows .bat 文件中编写等效代码?
If by $?
如果按$?
is ment to be the return value of the last execution then this needs to be replaced with %ERRORLEVEL%
in a windows batch file.是最后一次执行的返回值,那么这需要在 Windows 批处理文件中用%ERRORLEVEL%
替换。
So you could just use echo "RETURN CODE FROM Upgrade16 = %ERRORLEVEL%"
所以你可以使用echo "RETURN CODE FROM Upgrade16 = %ERRORLEVEL%"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.