New
#21
Hello @FreeBooter,
Nice Script.
If you want to avoid incorrect user input [ Zero, Letters, Characters, etc ], where you have . . .
Code:set /p len="Password Length: "
. . . change it to [ it will catch the VAST majority ] . . .
Code:set "len=" set /p "len=Password Length: " for /f "delims=0123456789" %%a in ("!len!") do (goto :Start) if "!len!"=="" goto :Start if "!len!"=="0" goto :Start
Also, and just my preference, I would use the line as follows as it is easier to troubleshoot . . .
Code:set "alp=a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T A U V X Y Z 0 1 2 3 4 5 6 7 8 9"
I hope this helps.
Last edited by Paul Black; 23 Dec 2021 at 18:20.
I have also coded batch script that can be use for setting Windows User Account with random password.
Code::: Setting Windows User Account with Random Password @Echo Off & Cls REM --> Check for permissions Reg query "HKU\S-1-5-19\Environment" REM --> If error flag set, we do not have admin. if %errorlevel% NEQ 0 ( ECHO ************************************** ECHO Running Admin shell... Please wait... ECHO ************************************** goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" set params = "%*:"="" echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" exit /B :gotAdmin CLS CHOICE /C YR /M "Press Y for Random Password, R to Remove Password." If %errorlevel% == 1 Goto :RandPW If %errorlevel% == 2 Goto :RemPW :RandPW Cls Echo. Echo. net user %UserName% /random Pause > Nul Exit :RemPW Cls Echo. Echo. net user %username% "" Pause > Nul Exit
Last pc I built I tried to use the password mypen15.
Got error message - too short...