![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-12 01:40 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » [Repost] Random Password Generation |
| Printable Version 1,267 / 4 |
| Floor1 sea2moon | Posted 2010-09-08 11:59 |
| 初级用户 Posts 23 Credits 47 | |
|
I've been learning batch files lately, and came across a pretty good little thing for randomly generating passwords.
Reposting it here to share~ It uses quite a lot of commands. For someone at my level, I feel every bit of it is gold, and it really needs to be understood line by line. @echo off call :randomPassword 8 pass1 echo %pass1% pause exit :randomPassword ::---------generate random password ::---------%1 is the password length, %2 and after are the names of the return variables ::---------goto loop, nested variables, nested commands @echo off if "%1"=="" goto :eof if %1 lss 1 goto :eof set password_len=%1 set return= set wordset=abcdefghijklmnopqrstuvwxyz023456789_ ::---------------------------loop :randomPassword1 set /a numof=%random%%%36 call set return=%return%%%wordset:~%numof%,1%% set /a password_len-=1 if %password_len% gtr 0 goto randomPassword1 ::---------------------------loop if not "%2"=="" set %2=%return% shift /2 if not "%2"=="" goto randomPassword |
|
| Floor2 radem | Posted 2010-09-08 12:26 |
| 高级用户 Posts 383 Credits 691 | |
|
I suggest using the CODE tag.
|
|
| Floor3 HAT | Posted 2010-09-08 15:37 |
| 版主 Posts 5,017 Credits 9,023 | |
For someone at my level, I feel every bit of it is gold, and it really needs to be understood line by line. Mm, if you have time, just read more tutorials. |
|
| Floor4 DXSX | Posted 2010-09-10 13:01 |
| 中级用户 Posts 147 Credits 247 | |
|
Hehe, interesting.
Randomly picks %1 characters from a-z 0-9 _, then combines them as the password. If you add A-Z, wouldn't that be even more perfect? Can't you use for instead of a goto loop? [ Last edited by DXSX on 2010-9-10 at 13:44 ] |
|
| Floor5 676939481 | Posted 2010-09-18 11:47 |
| 新手上路 Posts 8 Credits 8 From 上海 | |
|
Ahem... moderator... where is the tutorial on setting %1~9 parameters?...
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |