How to specify a program exit code ?

L

Lee Gillie

I have a console application. It has a FUNCTION MAIN AS INTEGER. When it exits I want to return a program completion code to the OS.
I've coded the end of my MAIN as:

ProgramExitStatus = 10
Environment.ExitCode = ProgramExitStatus
Environment.Exit(ProgramExitStatus)
Return ProgramExitStatus

But in the IDE I see this:

The program '[1820] MyConsoleApp.exe' has exited with code 0 (0x0).

Is there a way that really works?
 
H

Herfried K. Wagner [MVP]

* "Lee Gillie said:
I have a console application. It has a FUNCTION MAIN AS INTEGER. When it exits I want to return a program completion code to the OS.
I've coded the end of my MAIN as:

ProgramExitStatus = 10
Environment.ExitCode = ProgramExitStatus
Environment.Exit(ProgramExitStatus)
Return ProgramExitStatus

But in the IDE I see this:

The program '[1820] MyConsoleApp.exe' has exited with code 0 (0x0).

Is there a way that really works?

I use VS.NET 2002 (.NET 1.0) and it works. In the IDE, the exit code is not
displayed correctly, but when using a batch file, it works. I think this is
an IDE bug.
 
L

Lee Gillie

Herfried -

Ok, I can live with that. I won't be using from Batch, but eventually as a sub process, and checking the completion status in
spawner. Thank you for taking the time, and sharing your experience.

Best regards - Lee Gillie


Herfried K. Wagner said:
* "Lee Gillie said:
I have a console application. It has a FUNCTION MAIN AS INTEGER. When it exits I want to return a program completion code to the OS.
I've coded the end of my MAIN as:

ProgramExitStatus = 10
Environment.ExitCode = ProgramExitStatus
Environment.Exit(ProgramExitStatus)
Return ProgramExitStatus

But in the IDE I see this:

The program '[1820] MyConsoleApp.exe' has exited with code 0 (0x0).

Is there a way that really works?

I use VS.NET 2002 (.NET 1.0) and it works. In the IDE, the exit code is not
displayed correctly, but when using a batch file, it works. I think this is
an IDE bug.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top