473,320 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Retrieving returnvalue after calling a .Net executable

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
Jul 21 '05 #1
2 1845
Take a look at the property ExitCode of the System.Diagnostics.Process class
(http://msdn.microsoft.com/library/de...codetopic.asp).

HTH, Jakob.
"Ries Spruit" wrote:
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

Jul 21 '05 #2
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.
"Ries Spruit" <li***@spruit-it.nl> wrote in message
news:31**************************@posting.google.c om...
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

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Bill Grigg | last post by:
I have been successfully calling DLL's using VC++ 6.0 and also using VC++7.1 (.NET). I only mention this because I have never felt comfortable with the process, but nonetheless it did work....
6
by: Marlene Arauz Martin | last post by:
Hello, How's everybody??? I have an aspx. page that is calling an executable,....like this... System.Diagnostics.ProcessStartInfo psi= new System.Diagnostics.ProcessStartInfo();...
2
by: Ries Spruit | last post by:
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...
5
by: guxu | last post by:
Can anyone tell me the prons and cons having C# program calling an executable or DLL? I always do not like the idea of having one executable calling another executable since I can have more...
15
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
4
by: Mark Olbert | last post by:
I am struggling with trying to retrieve the value of an autoincrement identity field after a DetailsView Insert operation. The DetailsView is bound to an SqlDataSource control. So far as I can...
5
by: Sanjay Pais | last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time using the with - over clauses In query analyser, the data is retrieved in under a second. When retrieving using the...
2
by: teo | last post by:
I have to measure the length of a string in a Label, to set the adequate Label width (because not all browsers support the auto-size Label property). I decide to use the 'MeasureString'...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.