Batch a random number within a range

Author Johnny Josefsson on August 17, 2012 | Print | Bookmark
%RANDOM% generates a random number between 0 - 62k (32 bit maximum int value)
% 0 tells it to stray within the 0 - 200 range
+10 tells it to start at 10

REM generate a random number within in the range of 10-200
SET /A RAND=%RANDOM% % 0 +10


You could also just tell it how man digits to show with this:


That tells it to RANDOM a number with maximum of two digits, 0-99	

Was this article helpful?

Yes No

Category: Scripting, Batch / bat / cmd

Last updated on September 8, 2012 with 1388 views