title: How to pass parameter from node child process to execute commands in batch file?
body: <p>I need to put all the commands in a batch file (test.cmd) with some logic, for example:</p>
  
  <pre><code>IF condition1 (c:\Windows\System32\schtasks.exe /Create ...)
  Else (c:\Windows\System32\schtasks.exe /delete ...)
  </code></pre>
  
  <p>If remove the if-else statement, and only leave one command in test.cmd, by using code like this can execute the command:</p>
  
  <pre><code>exec('some-path/test.cmd', (error, stdout, stderr) =&gt; {
          if (error) {
              console.log(error);
              return;
          }
          console.log(stdout);
      });
  </code></pre>
  
  <p>If add if-else statement back, does anyone know how can I pass parameter from node.js exec() function? In the terminal, it is easy to pass parameters like "test.cmd para1".</p>