Return Value from a Console Application

WellsCarrie

Well-known member
Joined
Jul 12, 2005
Messages
95
Location
Arkansas
Programming Experience
5-10
I have a console application that seeks data from multiply sources, does some calculations and then loads a data table used by several web sites and reports. When it is run manually, the app works consistently with out unresolved errors.

However, I need the operations team to run the application via ROBOT (the scheduler we have to use). They refuse to run the application because it does not send a return code of zero when it finishes. With out the return code of Zero Robot reports that the application failed, even when it doesn't.

So, do any of you know how to get a console app to return a value of zero?

Thanks,
Carrie
 
The system exit code is set to the return value of the function, main, or zero if main returns void. Translated to VB a 'void' method is a Sub method, that is no return value. A default VB.Net console application with a Sub Main will return zero when it finishes, or something else if it fails.
Here is some code from documentation you can use to check exitcode:
(change 'filename' to the real path of your or any application.)
VB.NET:
Dim newProc As Diagnostics.Process = Diagnostics.Process.Start(filename)
Dim procID As Integer = newProc.Id
newProc.WaitForExit()
Dim procEC As Integer = -1
If newProc.HasExited Then procEC = newProc.ExitCode
MsgBox("Process with ID " & CStr(procID) & " terminated with exit code " & CStr(procEC))
 
Thanks!

:D This worked Great!
I am running only main(void). So I am exiting with a zero.
I think there is something wrong on thier end.
Carrie
 
Back
Top