问题设置ERRORLEVEL [英] Problem setting ERRORLEVEL

查看:135
本文介绍了问题设置ERRORLEVEL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在BAT文件中时,从我的Visual Basic .NET应用程序(使用Environment.Exit()设置返回代码)中设置ERRORLEVEL。 但是当我从命令行(cmd.exe)执行相同的应用程序时,ERRORLEVEL不会被设置。

我会很感激可能导致此行为的任何线索。
<谢谢 -

由托德担任PS:由于这是一个经典的DOS问题,不知道确切的论坛使用,所以在这里发帖。

When inside a BAT file, ERRORLEVEL gets set from my Visual Basic .NET application (which uses Environment.Exit() to set the return code).  But when I execute the same application from the command line (cmd.exe), ERRORLEVEL does not get set.

I would appreciate any clues as to what might be causing this behaviour.

Thanks -

Todd

PS: Since this is a classic DOS question, didn't know the exact forum to use, so posting here.

推荐答案

Hello Todd,

我写了一个简单的C ++程序,它只是从main()函数返回一个数字:

int main()
{
  return 20;
}

使用上面的代码,最终将调用ExitProcess()API。

ERRORLEVEL设置正确。以下是我在命令提示符中所做的:

C:\> Test01

C:\> ECHO%ERRORLEVEL%
20

但是我不确定为什么你的VB.NET应用程序在没有从批处理文件运行时没有设置ERRORLEVEL。运行VB.NET应用程序后,您是否已回复ERRORLEVEL?

生物。
Hello Todd,

I wrote a v simple C++ program that simply returns a number from the main() function :

int main()
{
 return 20;
}

With the above code, the ExitProcess() API will eventually get called.

The ERRORLEVEL gets set correctly. The following is what I did inside a command prompt :

C:\>Test01

C:\>ECHO %ERRORLEVEL%
20

But I'm not sure why your VB.NET application does not set the ERRORLEVEL when not run from a batch file. Have you ECHO'ed the ERRORLEVEL after running the VB.NET app ?

- Bio.


这篇关于问题设置ERRORLEVEL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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