Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

Capturing returned value from external application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pradeep_TP - 26 Jun 2007 09:25 GMT
Hi All,

I have simple windows service (C# code), from which I am calling an external
console application created in C#. This console application will return
different integer values that are some error codes.

How do I call this console application from windows service so that I can
read the values returned from the console application.

I have seen a lot of code to call external application, but none of them
mentions how to capture the returned code.

Thanks
pradeep_Tp
Peter Duniho - 26 Jun 2007 09:45 GMT
> I have simple windows service (C# code), from which I am calling an  
> external
[quoted text clipped - 3 lines]
> How do I call this console application from windows service so that I can
> read the values returned from the console application. [...]

A process has an exit code, which is the value returned by the main  
function.  You can retrieve it from the Process.ExitCode property once the  
process has exited.

If by "return" you don't really mean "return", but rather than the console  
application writes the exit codes as text to the standard output, then  
instead you can read the standard output by redirecting it.  Again, use  
the Process class to do this (see ProcessStartInfo.RedirectStandardOutput  
and Process.StandardOutput properties).

Pete
pradeep_TP - 26 Jun 2007 10:57 GMT
Thank you Peter. This is what I was looking for :).

> > I have simple windows service (C# code), from which I am calling an  
> > external
[quoted text clipped - 15 lines]
>
> Pete

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.