Support Forums
Pass Generator Batch script - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Computer Support Topics (https://www.supportforums.net/forumdisplay.php?fid=4)
+---- Forum: Microsoft Support (https://www.supportforums.net/forumdisplay.php?fid=5)
+---- Thread: Pass Generator Batch script (/showthread.php?tid=27171)



Pass Generator Batch script - AceInfinity - 09-30-2012

Code:
@echo off
setlocal enableextensions enabledelayedexpansion
set len=15
set str=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz.@#$*()?/\{}[]

call :GetLength %str%

set /a n=0
:A
set /a rnd=%random% %% %i%+1
set out=!out!!str:~%rnd%,1!
set /a n+=1
if not %n%==%len% goto :A

echo !out!
pause && goto :EOF

:GetLength
set i=0
set arg=%1
:N
set T=!arg:~%i%,1!

if defined T (
    set /a i+=1
    goto :N
)

Here's a password/passkey generator I wrote just a few minutes ago. It works nicely, the only problem is providing support for special characters like , % ! etc...

Change len and str variables to determine what characters to be using, and the output length of the generated pass. The :GetLength function actually calculates the length of the str variable, because we need this to return a specific character at a specific index within that variable.