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
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

