title: Execute multiple command lines with the same process using .NET
body: <p>I'm trying to execute multiple commands without create a new process each time. Basically, I want to start the DOS command shell, switch to the MySQL command shell, and execute a command. Here's how I am calling the procedure (also below). Also, how do I handle the "\"'s in the command?</p>
  
  <pre><code>ExecuteCommand("mysql --user=root --password=sa casemanager", 100, false);
  
  ExecuteCommand(@"\. " + Environment.CurrentDirectory + @"\MySQL\CaseManager.sql", 100, true);
  
  private void ExecuteCommand(string Command, int Timeout, Boolean closeProcess)
  {
      ProcessStartInfo ProcessInfo;
      Process Process;
  
      ProcessInfo = new ProcessStartInfo("cmd.exe", "/C " + Command);
      ProcessInfo.CreateNoWindow = false;
      ProcessInfo.UseShellExecute = false;
      Process = Process.Start(ProcessInfo);
      Process.WaitForExit(Timeout);
  
      if (closeProcess == true) { Process.Close(); }
  }
  </code></pre>