Batch File Random Number

April 29, 2009 at 11:00:26
Specs: Windows Vista
Hello,
I want a random fact part of my Batch File, but when i use the %random% command, it crashes.

I believe that this is because '%random%' picks a number between 1 and 32767.

Is there a way of randomly selecting a number between 1 and 10 (that i can change, should i wish to add more facts)


See More: Batch File Random Number

Report •


#1
April 29, 2009 at 12:47:16
set /a R=%random%%10+1


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
April 30, 2009 at 03:35:12
This doesn't work. It gives me numbers like 22335

@echo off
cls
:1
set /a R=%random%%10+1
echo %R%
pause >nul
goto 1


Report •

#3
April 30, 2009 at 03:53:07
@echo off
cls
:1
set /a R=%random%%%10+1
echo %R%
pause >nul
goto 1


=====================================
If at first you don't succeed, you're about average.

M2


Report •

Related Solutions


Ask Question