Since it sounds like there is still some confusion, I will try to explain with a little more detail.
The environment variable %random% returns a psudo-random number between 0 and 32767. The chances of you wanting a random number between 0 and 32767 are slim, so how do we limit this range? Dias gave the correct answer of:
set /a number=(%random% %% N) + 1
will give a randum number between 1 and N inclusive
Or for a positive random number between X and Y, (where Y is a maximum of 32767) we can use
set /a number=(%random% %% Y) + X
We know that %random% gives a number between 0 and 32767, so to limit that we use the '%' which is the modulus operator. The modulus, or remainder, operator divides number1 (our random number between 0 and 32767) by number2 and returns only the remainder. The value of the result is between 0 and the absolute value of number2. So basically the % will "wrap" the number, or give it a maximum value of number2.
I think I got it right, but if not I'm pretty sure somebody will let me know.