'Run node.js script multiple times with multiple command line arguements on windows

I have a script named index.js which I need to run with multiple command line arguements, one at a time. Something like this:

node index.js ABC
node index.js DEF
.
.
node index.js XYZ

So I have written all these arguements in a params.txt file, one on each line. In this question, the solution for my problem is given, but it would not work on windows. Can anyone tell me what script I need to run on windows to achieve what is being done in the linked question?

Thank You.



Solution 1:[1]

Try this

In a .bat file:

FOR /F %%i in ( params.txt ) do (
    call node index.js %%i
)

Or just from the command line this'll probably work:

FOR /F %i in ( params.txt ) do call node index.js %i

Note that if you stick it in a batch file (e.g. runthemall.bat) you need to double up the % signs.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GregHNZ