Reputation: 2438
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:
return 0;
and Environment.Exit(0);
statements?Upvotes: 3
Views: 6139
Reputation: 1058
The environmental variable %ERRORLEVEL% contains the return code of the last executed program or script.
By default, the way to check for the ERRORLEVEL is via the following code.
Syntax
IF %ERRORLEVEL% NEQ 0 (
DO_Something
)
Source: https://www.tutorialspoint.com/batch_script/batch_script_return_code.htm
Upvotes: 0
Reputation: 4850
You can use "errorlevel" in your batch file to get the returned value. More info here.
Upvotes: 8
Reputation: 12433
Is there any difference between return 0; and Environment.Exit(0); statements?
Upvotes: 4