0

I got a task to create a powershell or a batch file on Windows which should, in sequence, start a "node file.js", then call a "npm start" command in another directory and then launch a browser to localhost:3000. The problem is that I can not get the exact time when to launch the browser at the very end. I tried to concatenate commands with & and && (How to run two commands in one line in Windows CMD?) but the browser got launched before the scripts reach the end in the first case, never in the second case. I guess cmd simply can't understand when node or npm commands are finished to be executed.

Does anybody have experience with this particular task?

Community
  • 1
  • 1
Fabio Ricci
  • 395
  • 1
  • 4
  • 16
  • 3
    Please show your code. – Squashman Dec 27 '16 at 15:48
  • Note that `&` is the unconditional command concatenation operator, whereas `&&` lets the second command execute only in case the first one succeeded, that is, its exit code was zero... – aschipfl Dec 27 '16 at 15:53
  • 1
    Please note that https://stackoverflow.com is not a free script/code writing service. If you tell us what you have tried so far (include the scripts/code you are already using) and where you are stuck then we can try to help with specific problems. You should also read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). – DavidPostill Dec 27 '16 at 17:49
  • DavidPostill, please note that one has his own life in addition to coding, so if I don't reply within 4 hours, I am not considering SO as a free script/code writing service. – Fabio Ricci Dec 27 '16 at 21:08
  • This stated, I would be even happy to make this work as a cmd command: "node helloWorld.js && start http://localhost:8000". The first command opens a terminal window and the server is started. Then nothing happens. If I try to exit the terminal, then the browser opens but, obviously, can't reach the url I provided. – Fabio Ricci Dec 27 '16 at 21:10

0 Answers0