Retrieving returnvalue after calling a .Net executable

  • Thread starter Thread starter Ries Spruit
  • Start date Start date
R

Ries Spruit

Hiya,

I have a simple program which should be executed from the commandline
by various other programs. The program returns an integer as the
result.

What is the easiest way to pick up this returnvalue? If I use 'return
-1' etc. the value is might be returned but it is not visible when
executing the program directly from the commandline. Console.WriteLine
would work but I am curious wether it is possible to retrieve the
returned value from say a .vbs script or a .cmd or .bat file when just
using 'return -1'.

I can seem to find any info on it.. "return-value", ".Net" and
"commandline" give too many results!

Kind regards,
Ries
 
If you are running the command directly from a prompt, return value is not
displayed unless the program chooses to display it.

In a batch file, the return value is returned in the errorlevel batch file
if test.

Enter errorlevel in the OS search for help

In this example, the return value is 1:

:begin
@echo off
format a: /s
if not errorlevel 1 goto end
echo An error occurred during formatting.
:end
echo End of batch program.
 
Back
Top