How to generate a random number?

January 31, 2011 at 22:01:51
Specs: Windows 7
I want to generate a random number for a random part in my batch file.
I want to generate a random number between x and y which I can change anytime.

See More: How to generate a random number?

Report •

#1
January 31, 2011 at 23:04:26
max & min inclusive:

rem max must be geq min
rem min must be geq 0
rem max must be leq 32767
set min=1
set max=9
set /a var=(%random% %% ((max - min) + 1 )) + min
echo %var%
pause



Report •

#2
January 31, 2011 at 23:55:14
Thanks.

Report •
Related Solutions


Ask Question