How to use random in BATCH script?

%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]).

Leave a Comment