title: Run Windows Node.js script in background when the user logins by setting a Run key
body: <p>I'm running on Windows Server 2012R2.</p>
  
  <p>I have a node.js script which I want to run when the user performs logins.</p>
  
  <p>To do this I'm setting the command to run in the <code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</code> registry path.</p>
  
  <p>I set this command:</p>
  
  <pre><code>/path/to/node/node /path/to/node/script args
  </code></pre>
  
  <p>This works fine, but it will spawn a terminal showing the command output, while I'd like to run this command in background and detached from any command terminal.</p>
  
  <p>I tried to replace the previous command with:
     start /b /path/to/node/node /path/to/node/script args</p>
  
  <p>but in this case there is no evidence that the script was even started.</p>
  
  <p>I also tried to wrap the following command in a .bat script:</p>
  
  <p>start \b node script args</p>
  
  <p>set the name of the script in the Run key: in this case I can see terminal flash but then the script is not running anymore (I suppose that the script is executed but then it is stopped as soon as the parent process is terminated).</p>
  
  <p>I want to avoid to convert the script in a windows service, as long as a simpler solution is possible.</p>
  
  <p>A solution not using the Run registry key is also fine, as long as it fulfils my requirement (run a script in background when the user logins).</p>