未返回Environment.exit代码 [英] Environment.exit code not returned

查看:94
本文介绍了未返回Environment.exit代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在.bat文件中查询c#控制台应用程序的返回代码? 我在c#程序中使用以下内容:

Is there any way to interrogate a return code from a c# console application in a .bat file?  I am using the following in the c# program:

Environment.Exit(200)

Environment.Exit (200)

.bat文件中的%ERRORLEVEL%始终为9009从退出返回的值。

%ERRORLEVEL% in the .bat file is ALWAYS 9009 regardless of the value returned from the exit.

提前致谢。

推荐答案

确保在显示控制台程序之前确实已找到并执行该控制台程序值为
'echo%ERRORLEVEL%'。检查路径。如果它包含空格,则使用引号。 (如果找不到该文件,则报告错误9009。)

Make sure that the console program was actually found and executed before displaying the value with ‘echo %ERRORLEVEL%’. Check the path. If it contains spaces, then use quotation marks. (If the file is not found, then the error 9009 is reported).

为了检查值,请使用
IF的形式 ERRORLEVEL %ERRORLEVEL%
 
https://docs.microsoft.com/en- us / windows-server / administration / windows-commands / if


这篇关于未返回Environment.exit代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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