title: How to run commands via NodeJS child process?
body: <p>I am trying to run commands on Windows via NodeJS child processes:</p>
  
  <pre><code>var terminal = require('child_process').spawn('cmd');
  
  terminal.stdout.on('data', function (data) {
      console.log('stdout: ' + data);
  });
  
  terminal.stderr.on('data', function (data) {
      console.log('stderr: ' + data);
  });
  
  terminal.on('exit', function (code) {
      console.log('child process exited with code ' + code);
  });
  
  setTimeout(function() {
      terminal.stdin.write('echo %PATH%');
  }, 2000);
  </code></pre>
  
  <p>When it calls <code>ti.stdin.write</code>, it writes it to the <code>stdin</code> descriptor, but how do I trigger <code>cmd</code> to react at this point? How do I send the "enter" key signal that you do when you are actually typing in command prompt? Currently I get no response from <code>cmd</code>.</p>