title: Executing Batch File in C#
body: <p>I'm trying to execute a batch file in C#, but I'm not getting any luck doing it.</p>
  
  <p>I've found multiple examples on the Internet doing it, but it is not working for me.</p>
  
  <pre><code>public void ExecuteCommand(string command)
  {
      int ExitCode;
      ProcessStartInfo ProcessInfo;
      Process Process;
  
      ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
      ProcessInfo.CreateNoWindow = true;
      ProcessInfo.UseShellExecute = false;
  
      Process = Process.Start(ProcessInfo);
      Process.WaitForExit();
  
      ExitCode = Process.ExitCode;
      Process.Close();
  
      MessageBox.Show("ExitCode: " + ExitCode.ToString(), "ExecuteCommand");
  }
  </code></pre>
  
  <p>The command string contains the name of the batch file (stored in <code>system32</code>) and some files it should manipulate. (Example: <code>txtmanipulator file1.txt file2.txt file3.txt</code>). When I execute the batch file manually, it works correctly.</p>
  
  <p>When executing the code, it gives me an <code>**ExitCode: 1** (Catch all for general errors)</code></p>
  
  <p>What am I doing wrong?</p>