Marty List brings us Random.zip to return %ERRORLEVEL% as a random number between a lowerbound and upperbound parameter.
When you type random /?, you receive:
Returns an exit code (Errorlevel) of a random number based on lowerbound and upperbound numbers which must be passed as arguments. Syntax: random LowerBound UpperBound Example: random 1 10 Non-numeric arguments will be evaluated as 0. An argument of /? or -? displays this syntax and always returns 0.
Example:To set an environment variable to a random number between 1 and 997:
for /f "Tokens=1" %%r in ('random 1 997') do if /i "%%r" NEQ "The" set /a rnum=%%r