If you need to produce a random number on a Microsoft Windows system, you can do so at a command line interface (CLI) or in a batch file using the
%RANDOM%environment variable - see Windows Environment Variables for a list of the environment variables available on Microsoft Windows systems.
To generate random numbers at the command line, you can
open a command prompt window
c:\Users\Public\Documents>echo %random% 31090 c:\Users\Public\Documents>echo %random% 16802 c:\Users\Public\Documents>echo %random% 20253 c:\Users\Public\Documents>
When you use
%random%, you will get numbers between 0 and
32,767, which is 2 to the 15th power. But you can
make the range of numbers smaller by using a command like the following
where 0 is the lower bound for the numbers and n-1 is the upper bound
of the range.
SET /a _rand=(%RANDOM%*n/32768)
[ More Info ]