Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I tried to run password generator from youtube. Here's the code:

@echo off
chcp 1257
setlocal EnableDelayedExpansion
set alpha= 
a?bc?de??fghi?jklmnopqrs?tu?ūvwxyz?A?BC?DE??FGHI?JKLMNOPQRS?TU?ūVWXYZ?

For /L %%j in (1,1,13) DO CALL:GEN
echo Your Random Password is [ %PASSWORD% ]

EndLocal
pause

:GEN

For /L %%j in (1,1,10) DO (
if %random% gtr 10000 ( set PASSWORD=%PASSWORD%%random:~0,1% ) else (
set /a i=%random:~1,1%+%random:~1,1%
if !i! gtr 25 set i=25
set PASSWORD=%PASSWORD%!alpha:~%i%,1! )
)

This returns 1 random password. And I need 10 passwords, so I tried to create for loop before this line: For /L %%j in (1,1,13) DO CALL:GEN . Then it returns 10 rows of text but without passwords:

Active code page: 1257
Your Random Password is [  ]
Your Random Password is [  ]
Your Random Password is [  ]
Your Random Password is [  ]
Your Random Password is [  ]
Your Random Password is [  ]
Your Random Password is [  ]
Your Random Password is [  ]
Your Random Password is [  ]
Your Random Password is [  ]
Press any key to continue . . .

How can I solve this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
317 views
Welcome To Ask or Share your Answers For Others

1 Answer

@echo off & setlocal EnableDelayedExpansion
chcp 1257

set "alpha=aabccdeeefghiijklmnopqrs?tuuuvwxyz?AABCCDEEEFGHIIJKLMNOPQRS?TUUUVWXYZ?"
set alphaCnt=70

For /L %%j in (1,1,10) DO CALL :GEN %%j

pause
Goto :Eof
:GEN
Set "Password="
For /L %%j in (1,1,10) DO (
    Set /a i=!random! %% alphaCnt
    Call Set PASSWORD=!PASSWORD!%%alpha:~!i!,1%%
)
echo Your Random Password %1 is [%PASSWORD%]

Sample output:

Your Random Password 1 is [EüllxleUOc]
Your Random Password 2 is [RBGEo?ulEF]
Your Random Password 3 is [AfuuAEFwMe]
Your Random Password 4 is [kuaEjuLicr]
Your Random Password 5 is [ModgGsAN?E]
Your Random Password 6 is [MzEqSWJWCB]
Your Random Password 7 is [oücrFUqGpj]
Your Random Password 8 is [kRHDCqiciü]
Your Random Password 9 is [gUYjjSiicQ]
Your Random Password 10 is [cuuAOüixVY]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...