2

I have a C# console application AAA.exe which can return an integer to indicate the result

static int Main(string[] args)
  {
    . . .
    if(case1)
       return -1;

    if(case2)
       Environment.Exit(1);

    return 0;
}

I will call AAA.exe in a batch file and need the return value

AAA.exe /p="param1"

My question is:

  1. how to get the return value of AAA.exe?
  2. is there any difference between return 0; and Environment.Exit(0); statements?
Carlos Liu
  • 2,268
  • 3
  • 35
  • 51

2 Answers2

7

You can use "errorlevel" in your batch file to get the returned value. More info here.

Foole
  • 4,654
  • 1
  • 24
  • 22
3

Is there any difference between return 0; and Environment.Exit(0); statements?

See this post

Community
  • 1
  • 1
dugas
  • 11,576
  • 2
  • 42
  • 51