Joe Wood
Joe Wood

Reputation: 43

How to run multiple nodes in batch in one file

I've been having this problem where I have a program with multiple instances running at once so it can run different configurations of the program at one time. (In this case its discord alt accounts.)

Is there an easy way to run one of the programs, pause to make sure it's ready, and then continue to run the next one? At the moment all it will do is run the first program inside of the active cmd window. Maybe there is a way to open the index.js file in a new terminal?

@echo on
node 1-JoeFish\src\index.js
@echo Main started successfully
pause
node 2-Mr-Someone\src\index.js
@echo Alt one started successfully
pause
node 3-A-bottle-of-sand\src\index.js
@echo Alt two started successfully
pause
node 4-Bart-Simpson\src\index.js
@echo Alt three started successfully
pause

Upvotes: 0

Views: 308

Answers (1)

SomethingDark
SomethingDark

Reputation: 14305

The start command with the /WAIT option will run a program and then wait for it to complete before continuing.

@echo on
start "" /wait node 1-JoeFish\src\index.js
@echo Main started successfully
pause
start "" /wait node 2-Mr-Someone\src\index.js
@echo Alt one started successfully
pause
start "" /wait node 3-A-bottle-of-sand\src\index.js
@echo Alt two started successfully
pause
start "" /wait node 4-Bart-Simpson\src\index.js
@echo Alt three started successfully
pause

Upvotes: 1

Related Questions