0

I make a C# console program and I want to execute some batch treatments in an other cosole.

So, I have the main program which write in the console and at a certain moment I want to execute batch treatment in an other one.

I know how execute batch treatment in the main console but I want to do that in an other one, that is my question.

How can I make that ?

EDIT : I use a StreaWriter to write in the console like that :

Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;

process.StartInfo = startInfo;
process.Start();

using (StreamWriter writer = process.StandardInput)
{
    if (writer.BaseStream.CanWrite)
    {
        // commands...
    }
}
flow
  • 4,828
  • 6
  • 26
  • 41

1 Answers1

3

Use Process.Start:

Process.Start("cmd.exe", "yourcommandhere");
It'sNotALie.
  • 22,289
  • 12
  • 68
  • 103
nmat
  • 7,430
  • 6
  • 30
  • 43