如何运行exe文件后返回退出code?文件、exe、code

2023-09-03 07:55:44 作者:各种坚强

我已经创建了用于验证功能,这个应用程序,我需要通过使用VBScript执行控制台应用程序。执行该exe文件后,我想返回退出code函数是否返回成功与否。我怎样才能返回一个状态或退出code。在.NET?

I have created a Console application for validating a function and this application i need to execute by using vbscript. After executing this exe i want to return an exit code whether the function return success or not. How can i return a status or exit code in .net?

推荐答案

我会假设你正在写C#或VB.NET。在这两种情况下,人们通常有一个主要功能不返回任何内容,但是您可以更改为返回一个整数重新present出口code。

I'm going to assume you're writing either C# or VB.NET. In either case usually people have a Main function that returns nothing, but you can change this to return an integer to represent the exit code.

有关C#看看这个MSDN页

您可以做的:

static int Main()
{
    //...
    return 0;
}

有关VB.NET看到这个MSDN网页。

For VB.NET see this MSDN page.

您可以做的:

Module mainModule
    Function Main() As Integer
        '....
        '....
        Return returnValue
    End Function
End Module