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 ...
 
Notifications
Clear all

[Solved] Random function in batch.  


SheWolf99
Posts: 5
(@sheerowwanjiku)
Active Member
Joined: 3 weeks ago

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

Topic Tags
1 Reply
Kvc
Posts: 22
 Kvc
Admin
(@thekvc)
Admin
Joined: 1 year 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
Cls
:Loop
Set _Rand_Number= %RANDOM%
Echo %_Rand_Number%
Pause
Goto :Loop

The above code will help you out 🙂

Reply
Share:

© 2020 TheBATeam

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

Theme by Anders Norén