473,387 Members | 1,724 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,387 software developers and data experts.

Call a third party console application and return the result

GD
I am trying to execute a third party console application and return the
result dispalayed in the console screen.

Can this be achieved?

Thanks.

GD
Dec 20 '07 #1
2 6477
GD,

Yes, using the Process class, you can start the new application easily.

When creating the ProcessStartInfo instance to pass to the Start method,
make sure that UseShellExecute is set to false, and that
RedirectStandardError, RedirectStandardInput, and/or RedirectStandardOutput
properties to allow you to look at the appropriate input/output.

Once you set those properties, you can then access the StandardError,
StandardInput and StandardOutput properties on the Process instance that you
start and process the input/output as you wish.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"GD" <jb*****@yahoo.comwrote in message
news:eu**************@TK2MSFTNGP03.phx.gbl...
>I am trying to execute a third party console application and return the
result dispalayed in the console screen.

Can this be achieved?

Thanks.

GD

Dec 20 '07 #2
GD
Nicholas,

Thank you very much for your solution. It works like a charm.

For those who are interested in same solution, I post my test code here:
System.Diagnostics.ProcessStartInfo psi = new
System.Diagnostics.ProcessStartInfo();

psi.FileName = "ConsoleTest.exe";

psi.UseShellExecute = false;

psi.RedirectStandardOutput = true;

System.Diagnostics.Process p = new System.Diagnostics.Process();

p.StartInfo = psi;

p.Start();

txtConsoleOutput.Text = p.StandardOutput.ReadToEnd();

p.WaitForExit();

GD
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:OU**************@TK2MSFTNGP06.phx.gbl...
GD,

Yes, using the Process class, you can start the new application easily.

When creating the ProcessStartInfo instance to pass to the Start
method, make sure that UseShellExecute is set to false, and that
RedirectStandardError, RedirectStandardInput, and/or
RedirectStandardOutput properties to allow you to look at the appropriate
input/output.

Once you set those properties, you can then access the StandardError,
StandardInput and StandardOutput properties on the Process instance that
you start and process the input/output as you wish.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"GD" <jb*****@yahoo.comwrote in message
news:eu**************@TK2MSFTNGP03.phx.gbl...
>>I am trying to execute a third party console application and return the
result dispalayed in the console screen.

Can this be achieved?

Thanks.

GD


Dec 21 '07 #3

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

Similar topics

0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
2
by: Jon Davis | last post by:
I have a full-blown application that consists of several (fifteen or so) assembly DLLs, each being a separate VS.NET project that outputs to the main DLL's bin directory. They are all strongly...
15
by: jon | last post by:
How can I call a base interface method? class ThirdPartyClass :IDisposable { //I can not modify this class void IDisposable.Dispose() { Console.WriteLine( "ThirdPartyClass Dispose" ); } } ...
3
by: Beryl Small | last post by:
Hi, I have a third party software that needs to send information to an .aspx page for processing to communicate with an SQL database. The software sends the information something like this: ...
0
by: Richard B | last post by:
I have to call a third-party program from mine. The third-party program expects a string parameter(that will be converted to an integer) that is a handle to a callback function in my program. The...
3
by: cecille | last post by:
Hi don't know where to post this, please help me. I have a third party application that I need to launch inside my C# application. how can I do this? thanks.
6
by: Ben Finney | last post by:
Howdy all, I'm improving an existing application that's partly written using Python and the standard library. Many of the improvements I want to make can be done by using third-party free...
5
by: Daz | last post by:
Hi everyone, Sorry about the long thread name, I think that my problem is that I don't know how to word it, which is why I have been unsuccessful finding the information I require. I am...
46
by: Steven T. Hatton | last post by:
I just read §2.11.3 of D&E, and I have to say, I'm quite puzzled by what it says. http://java.sun.com/docs/books/tutorial/essential/concurrency/syncrgb.html <shrug> -- NOUN:1. Money or...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.