Reputation: 23
I'm looking for a batch file code that will generate a random 10 digit number and will show up to the user using the batch file... (I'm making a generator)
Upvotes: 0
Views: 1916
Reputation: 56180
just to add another possibility:
SetLocal EnableDelayedExpansion
set "num="
For /L %%i In (1,1,10) Do (Set "num=!num!!random:~-1!")
Echo=%num%
Upvotes: 0
Reputation: 324
Set /a num1=%random% %% 10
Set /a num2=%random% %% 10
Set /a num3=%random% %% 10
Set /a num4=%random% %% 10
Set /a num5=%random% %% 10
Set /a num6=%random% %% 10
Set /a num7=%random% %% 10
Set /a num8=%random% %% 10
Set /a num9=%random% %% 10
Set /a num10=%random% %% 10
echo %num1%%num2%%num3%%num4%%num5%%num6%%num7%%num8%%num9%%num10%
Upvotes: 0
Reputation: 38614
Or in a loop:
@Echo Off
SetLocal EnableDelayedExpansion
For /L %%i In (1,1,10) Do (Set/A _=!random! %%10&Set num=!num!!_!)
Echo=%num%
Pause
Upvotes: 2
Reputation:
Set /a num1=%random% %% 10
Set /a num2=%random% %% 10
Echo %num1%%num2%
Gives you a two digit random number. So do above 10 times. See set /?
for help.
Upvotes: 1