It is easy to generate random numbers via a batch file under Windows Server and all MS Windows 11, 10, ... Desktop OS and MS Server!There are free tools that can generate random numbers like the ►► Windows tool NonCompressibleFiles , but to see how random numbers can be generated in order to understand the random numbers is enough under Windows 11, 10, 8.1, ... or current Microsoft Web Servers 2022, 2019 , 2016, a simple random number Tast.bat, or the command prompt! Contents: 1.) ... generate random numbers in the command line, four simple examples!
|
(Image-1) Generate random numbers and display them in the command prompt! |
![]() |

If you enter% random%, you will get numbers between 0 and 32,767. However, you can decrease the range of numbers using a command like the following, where 0 is the lower limit of the numbers and n-1 is the upper limit of the range.
2. Simple example a random number from 1 to 100
c:\User>set /a _rand=(%random%*100/32768) + 1
18
c:\User>set /a _rand=(%random%*100/32768) + 1
27
c:\Users>set /a _rand=(%random%*100/32768) + 1
43
A simple multiplication generates even larger random numbers
3. Simple example of generating a larger random number
C:\>set /a _rand=(%random%*%random%) + 1
251646066
C:\>set /a _rand=(%random%*%random%) + 1
290567809
C:\>
4. Simple example of a random number from 1 to 1 million
(Image-2) Generate random numbers up to 1 million via the command prompt! |
![]() |

PS:
If you need to generate a random number on a Microsoft Windows system, you can do so through a command line interface, or in a batch file using% RANDOM%, which is one of many Windows environment variables. For a list of the environment variables available from Microsoft, see Windows Environment Variables on Every Windows System.
2.) ... A random number Tast.bat as a batch file (Euro-Jackpot 5 + 2)!
Copy the text via Copy Paste and into a Euro-Jackpot.bat created on the desktop , then simply start it by double-clicking and generate lottery numbers for the next draws via a command prompt or batch file!It also works without external tools such as LTK: ►► ... Lotto Numbers Generatr LTK!
The batch file for Lotto Euro-Jackpot 5+2:
@echo off
REM
SET maxvalue=50
SET minvalue=1
SETLOCAL
SET /A tmpRandom=((%RANDOM%)%%(%maxvalue%))+(%minvalue%)
echo "Lotto-1: %tmpRandom%"
SET /A tmpRandom=((%RANDOM%)%%(%maxvalue%))+(%minvalue%)
echo "Lotto-2: %tmpRandom%"
SET /A tmpRandom=((%RANDOM%)%%(%maxvalue%))+(%minvalue%)
echo "Lotto-3: %tmpRandom%"
SET /A tmpRandom=((%RANDOM%)%%(%maxvalue%))+(%minvalue%)
echo "Lotto-4: %tmpRandom%"
SET /A tmpRandom=((%RANDOM%)%%(%maxvalue%))+(%minvalue%)
echo "Lotto-5: %tmpRandom%"
SET maxvalue=10
SET minvalue=1
SET /A tmpRandom=((%RANDOM%)%%(%maxvalue%))+(%minvalue%)
echo "Euro-1: %tmpRandom%"
SET /A tmpRandom=((%RANDOM%)%%(%maxvalue%))+(%minvalue%)
echo "Euro-1: %tmpRandom%"
pause
ENDLOCAL
BREAK
(Image-3) Random numbers batch file 6 from 49 lottery |
![]() |

3.) ... How good are these random numbers, and what should be considered!
There are always points of contention when it comes to random numbers, but it is indeed the case that there are no random numbers in reality, whoever deals with them professionally will eventually understand why it is so.
If you are interested in random numbers then you should deal with many approaches to generating random numbers, not just look at them to understand them and use them sensibly.
The %RANDOM% is of course not the best choice, but you can use it as an example!
FAQ 88: Updated on: 26 August 2023 10:47