Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 13th, 2012  |  syntax: None  |  size: 0.46 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. @ECHO OFF
  2. :: get values passed in for the min and max desired values
  3. SET min=%1
  4. SET max=%2
  5. SET /a range=max-min
  6. :: min number returned by %random% function
  7. SET minrand=0
  8. :: max number returned by %random% function
  9. SET maxrand=32767
  10. SET /a rangerand=maxrand-minrand
  11. SET /a number=(%random%-minrand)*range/rangerand+min
  12. ECHO %number%
  13. :: usage in a batch file, this sets %number% to a random # from 1 to 10:
  14. :: FOR /F "tokens=*" %%i in ('rand.bat 1 10') do SET number=%%i