0

What I'm trying to do is open a new command prompt through Node and run a Javascript file.

For example, I would

node file1.js

And that would open a new console instance, which would instantly run

node file2.js

I have the basic outline and can open a new instance, just not pass any commands/arguments

var child_process = require('child_process');

child_process.execSync('start cmd.exe');

I need help passing command line params, cant find out how though.

Anthemius
  • 29
  • 5
  • 1
    Simply write a shell script that calls both of them. – georoot Mar 06 '17 at 00:44
  • I want to open a new instance of the console at a certain point during the program, while its running. – Anthemius Mar 06 '17 at 00:47
  • Okay so you are having problems passing command line params ? – georoot Mar 06 '17 at 00:48
  • Have a look here http://stackoverflow.com/questions/14458508/node-js-shell-command-execution#14510775 . Is this what you are looking for ? If not edit the question to be a little more specific on the problem :) – georoot Mar 06 '17 at 00:50

1 Answers1

0
var child_process = require('child_process');
child_process.execSync('start node file2.js');

Worked for me. Please make sure node.exe is in your PATH

Gireesh Punathil
  • 1,344
  • 8
  • 18