0

I've searched around and didn't find anything useful! :(

What i want is to have my C# app doing a command to a running process. This running process is a console application and i just need to enter the command "restart".. my try was:

Process[]  processes=  Process.GetProcessesByName("OpenSim.32BitLaunch");

        foreach  (Process  p in  processes)
        {
             p.StandardInput.WriteLine("restart");
                 p.StartInfo.RedirectStandardInput = true;
               p.StartInfo.UseShellExecute = false;

                p.Start();

               StreamWriter myStreamWriter = p.StandardInput;
               myStreamWriter.WriteLine("tdfsffds");
               p.StandardInput.WriteLine("restart");
               p.StandardInput.Write("restart");
}

And i get and exectipon: StandardIn not redirected.I've tried also to set RedirectStandardInput but nothing ..
I've also tried with no success to do:

Process[]  processes=  Process.GetProcessesByName("OpenSim.32BitLaunch");

        foreach  (Process  pin  processes)
        {
                       p.StartInfo.RedirectStandardInput = true;
               p.StartInfo.UseShellExecute = false;

                p.Start();

               StreamWriter myStreamWriter = p.StandardInput;
               myStreamWriter.WriteLine("tdfsffds");
               p.StandardInput.WriteLine("restart");
               p.StandardInput.Write("restart");
    }

And i get and exectipon: StandardIn not redirected.I've tried also to set RedirectStandardInput but nothing .. :(

Can anyone help me ?

Regards!

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Momerath
1

You can't take over the standard input of an already running process. You can send keystrokes to a window using something like the method here

Votes + Comments
Solved with the keystrokes :)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.