Set command line variable from node js file

Viewed 114

I am not sure if this is possible, but would be very useful to me if it is. I am using a .bat file which calls a js file with some node.js code in it.

e.g. call node prepare.js

In the js file I want to do some work and the output of this I would like to return to the cmd line or have a variable set on the cmd line for use later in the bat file.

Anyone done such a thing?

1 Answers

May be you need the for command?

for /f "tokens=* delims=" %%a in ('node prepare.js') do (
    set "output=%%a"
)
echo %output%
Related