windows 在windows os中在cmd中打印退出代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3819513/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:38:21  来源:igfitidea点击:

print exit code in cmd in windows os

windowscommand-linecmd

提问by Osama Ahmad

print exit code in cmd in windows os ....some command return exit code ...where this code store...and i want to print this exit code and assign it to variable

在windows os中的cmd中打印退出代码......一些命令返回退出代码......这个代码存储的地方......我想打印这个退出代码并将其分配给变量

回答by Adrian Faciu

You can use %ERRORLEVEL% environment variable, it will hold the last code that was returned. You can echo it or assign it to a variable, depending on your needs.

您可以使用 %ERRORLEVEL% 环境变量,它将保存最后返回的代码。您可以根据需要回显它或将其分配给变量。