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
  • 5,093
  • 11
  • 59
  • 82

2 Answers2

8

Assuming you're on Windows (C# tag)

echo %errorlevel%
Brian Rasmussen
  • 114,645
  • 34
  • 221
  • 317
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,318
  • 1
  • 31
  • 61