title: Running Multiple Commands in CMD.EXE from C# program?
body: <p>I am attempting to 1. run a cd command and 2. execute a node.js executable that takes in two filenames through the command window.</p>
  
  <p>The following code is embedded in a for loop so the variable names for the filename extension variables change: </p>
  
  <pre><code>command_line = "/C cd C:/Users/esimons/Documents/Software/Serial_GUIC#/ComputerToArduino/images/TraxSecur-Node/TraxSecur-Node/ &amp; node main.js " + image_extension + " " + UID_extension;
  
  System.Diagnostics.Process.Start("CMD.exe", command_line);
  
  </code></pre>
  
  <p>I have tried splitting up the commands using a &amp; which I saw on another thread but it is not working. </p>
  
  <p>Using alternative approach: </p>
  
  <pre><code>System.Diagnostics.Process p = new System.Diagnostics.Process();
  p.StartInfo.FileName = "cmd.exe";
  p.StartInfo.WorkingDirectory = @"C:/Users/esimons/Documents/Software/Serial_GUIC#/ComputerToArduino/images/TraxSecur-Node/TraxSecur-Node/";
  p.StartInfo.UseShellExecute = false;
  p.StartInfo.RedirectStandardOutput = true;
  p.StartInfo.RedirectStandardInput = true;
  p.Start();
  p.StandardInput.WriteLine("node main.js " + image_extension + " " + UID_extension);
  p.Close();
  </code></pre>
  
  <p>Solution:
  The above code works! Restart you system if you have recently installed node.js</p>