I found a nice script that generates random numbers with javascript, without the drawbacks of using a command like ran =%random%
in a batch file (it gives the same number for almost simultaneous calls). That code works but it prints the random number on screen. However, I dont know much of javascript and I cannot understand how I can call that java script function with 2 input variables and return the random value into another variable. I would like to do something like this
@set @e=0 /*
@echo off
set minV=0
set maxV=5000
set @e=
cscript //nologo //e:jscript "%~f0" minV maxV
exit /b
*/
function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
but it does not work. Also, I dont understand why the original script is using a "at" sign before "e" here
set @e=
Is "e" a variable storing the result of the call?