Software-OK
≡... News | ... Home | ... FAQ | Impressum | Contact | Listed at | Thank you |

  
HOME ► Faq ► FAQ - Windows cmd.exe Command-Prompt ► ««« »»»

Generate random numbers in the command prompt or batch file!


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!
2.) ... A random number Tast.bat as a batch file (Euro-Jackpot 5 + 2)!
3.) ... How good are these random numbers, and what should be considered? 



1.) Generate random numbers in the command line, four simple examples!

To generate random numbers on the command line, you can open a command prompt window and type:
echo %random%

1. Simple example of a random number  


c: \> echo %random%
444


(Image-1) Generate random numbers and display them in the command prompt!
Generate random numbers and display them in the command prompt!

-
▲ Back to the top ▲



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!
Zufallszahlen bis 1 Million Erzeugen über die Eingabeaufforderung!

-
▲ Back to the top ▲

 

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
Zufallszahlen Batch Datei 6 aus 49 Lotto

-
▲ Back to the top ▲



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: 5 June 2022 15:57 Windows
Windows-Console

All WiFi / WLAN access points via command from the command prompt!


It is easy to list all WiFi / WLAN access points using a command prompt under Windows 11, 10, 8.1 and MS Server 2019, 2016, The best way to do this
Windows-Console

Information about a specific user account via cmd.exe or PowerShell!


Under MS Windows 11, 10, Desktops and MS Server, information on a specific user account can be obtained quickly via the command line Important user
Windows-Console

Is my Windows User a Microsoft Account or a Local command line query!


It is practical and easy to determine from the command line in PowerShell: whether there is a Microsoft Account or is a Local Account on Windows 11, 10,
Windows-Console

Change the workgroup / PC name using the command prompt or PowerShell!


Changing workgroup or PC name using Command Prompt or PowerShell is om MS Windows 11, 10, and MS Server OS Is not impossible either, this is often used
Windows-Console

Query the Mac address via the command line (CMD)!


You can find out the mac address physical address of a computer with the getmac command on MS Windows 11, 10, etc. This can also be used to get the
Windows-Console

Find out the computer name via the command prompt or Powershell!


Its easy to find out the computer name using the command prompt or Powershell commands on Windows 11, 10, etc. You can determine your computer name
Windows-Console

Understand the shutdown command under MS Windows!


The Shutdown command under MS Windows 11, 10, . + MS Server is one of the most popular PC shutdown or restart command lines To use the command line,

»»

  My question is not there in the FAQ
Asked questions on this answer:
  1. As %RANDOM% variable is anything else than random, you'd better give a hint on that page! Especially as you give an example on how to generate random numbers for Euro-Jackpot or other lotteries, where "randomness" does potentially have an influence on making somebody rich - or not ...!
Keywords: windows, 11, 10, console, generate, random, numbers, command, prompt, batch, file, desktop, lotto, eurojackpot, Questions, Answers, Software




    

  + Freeware
  + Order on the PC
  + File management
  + Automation
  + Office Tools
  + PC testing tools
  + Decoration and fun
  + Desktop-Clocks

  + SoftwareOK Pages
  + Micro Staff
  + Freeware-1
  + Freeware-2
  + Freeware-3
  + FAQ
  + Downloads

  + Top
  + Desktop-OK
  + The Quad Explorer
  + Don't Sleep
  + Win-Scan-2-PDF
  + Quick-Text-Past
  + Print Folder Tree
  + Find Same Images
  + Experience-Index-OK
  + Font-View-OK


  + Freeware
  + PreventTurnOff
  + QuickMemoryTestOK
  + IsMyHdOK
  + AutoPowerOptionsOK
  + OneLoupe
  + TraceRouteOK
  + GetWindowText
  + AutoHideMouseCursor
  + Desktop.Calendar.Tray.OK
  + PAD-s


Home | Thanks | Contact | Link me | FAQ | Windows 2021 | Windows 10 | English-AV | Impressum | Translate | PayPal | PAD-s

 © 2023 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu
0.062


► The Stop Watch and Countdown Timer for Windows 11, 10, ... all MS OS! ◄ ► What is calibration? ◄ ► Windows 10 Home local users and groups are missing, why this? ◄ ► How to do a double-click? ◄ ► What is an executable file? ◄ ► Safely removing drives is in the wrong language, is it also possible in English? ◄ ► Change the screen buffer size of the Windows 11, 10, ... command prompt! ◄ ► Downgrade Windows 10 to Windows 7 or 8.1, can I uninstall it? ◄
This website uses cookies to ensure you get the best experience on our website more Infos & Privacy Policy
....