An official Batch Programming blog! To Solve the daily problems with windows and fixing them with little notepad scripts. Unlock the Hidden Secrets of Windows, Learn to crack Software via CMD & Make your own Programming tools. Understand to Manipulate your PC via CMD.

TheBATeam Forum

Random function in ...
Clear all

[Solved] Random function in batch.  

Posts: 5
Active Member
Joined: 2 months ago

Hi guys,  want to be able to call a random Function using Call command.

Topic Tags
1 Reply
Posts: 27
Joined: 2 years ago

If you want to generate a random string of numbers in CMD, There is no specific function for that - but, you can simply generate a random number by using an inbuilt variable.

Set _Rand_Number= %RANDOM%

A Random number will be saved in the variable named "_Rand_Number". So, every time you execute this command - a new value will be saved within this %Random% variable.

Try out the following:

@Echo off
Set _Rand_Number= %RANDOM%
Echo %_Rand_Number%
Goto :Loop

The above code will help you out 🙂


© 2020 TheBATeam

Our Core Values   /   Terms & Conditions   /   Privacy Policy   /   Why Register?

Theme by Anders Norén