CMD-Batch File Simple Random
batch-file, range
Solution
The `%RANDOM%` returns a number between 0 and 32767. To narrow these range use modulo operator, and addition or substraction to offset the result. Example:
@set /a bottomlimit = 50
@set /a upperlimit = 100
@set /a result = %bottomlimit% + %RANDOM% %% (%upperlimit% - %bottomlimit% + 1)
@echo %result%
Problem
Using a .bat file, I know how to echo out a random number with %Random%. How do I set a certain random range of the %Random% e.g. 50-100? Oh, and I've got a point system which states at the start: SET /A MAINSCORE=0 How do I set that Random Range number to add / subtract from the MainScore? Thanks.