5

Possible Duplicate:
How do I get the application exit code from a Windows command line?

I have a console application. It will be executed from command prompt. It will return either 0 or 1 from main method. How can I know that what value is returned by the application?

Community
  • 1
  • 1
Maanu
  • 4,941
  • 11
  • 53
  • 78

2 Answers2

7

Assuming you're on Windows (C# tag)

echo %errorlevel%
Brian Rasmussen
  • 112,408
  • 34
  • 217
  • 309
0

If you run the command line app with the Process class in C#:

  • if you look for the exitcode: process.ExitCode
  • if you need to read what the app has written to the console: process.StandardError.ReadToEnd() or process.StandardOutput.ReadToEnd()

If you need this in C++ since you gave that TAG too, I cannot help you much.

You should choose one of those tags, or have you put unrelated tags into the question?

Marino Šimić
  • 7,256
  • 1
  • 27
  • 59