0

I have a .exe program (console app) written in .net.

  1. I need to execute it
  2. Provide inputs
  3. Get the outputs as a string or preferably as stream.

Currently I'm using System.Diagnostics namespace and Process Class. But using Diagnostic namespace for this purpose dosent seem to be ok.

Is there any method by which I can do the same thing more efficiently?. Like using reflection to find Main() method and then invoking it.

2 Answers 2

3

The Process class is exactly the right tool for doing what you want. Don't mind the name of the Diagnostic namespace - just use the Process class.

Sign up to request clarification or add additional context in comments.

3 Comments

thankx. i also need to run this process in a seperate app domain. can that be done using this namespace?
First: Forget about the namespace! Then, please read this to understand what a namespace is and why it shouldn't matter to you at all: msdn.microsoft.com/en-us/library/…
stackoverflow.com/questions/9991735/….. may b u can help me with this second question i hav just posted.. read the link.thankx for that
0

Completely fine. System.Diagnostics is just a namespace.

If more info needed, you can navigate to this project for motivation and see how to handle processes grammatically or this snippet from VM found in here

                var startInfo = new ProcessStartInfo(FilePath)
                {
                    WorkingDirectory = RootFolderPath,
                    Arguments = StartingArguments,
                    RedirectStandardOutput = true,
                    UseShellExecute = false,
                    CreateNoWindow = true
                };
                ConsoleProcess = new Process {StartInfo = startInfo};

                ConsoleProcess.Start();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.