How to use random in BATCH script?
%RANDOM% gives you a random number between 0 and 32767.
You can control the number's range with:
set /a num=%random% %%100
- will produce number between 0~99.
This one:
set /a num=%random% %%100 +1
- will produce number between 1~100.
%RANDOM%
gives you a random number between 0 and 32767.
Using an expression like SET /A test=%RANDOM% * 100 / 32768 + 1
, you can change the range to anything you like (here the range is [1…100] instead of [0…32767]).