«

»

Aug 31

Print this Post

Password Generator (PWGen.vbs)

PWGen is a script to generate a random 8 character password that contains upper and lower case letters, a number, and a special character/symbol.

To use it either download and extract the zip file below or copy and paste the code into notepad and save it with a .vbs extension.

PWGen
PWGen
PWGen.zip
702.0 B
168 Downloads
Details
randomize
dim arrPassA(8)
strResult = ""
arrSymbols = Array("!","#","$","%","&","(",")","*","+",",","-",".",":",";","<","=",">","?","[","]","^","_","{","}","~")

do while strResult = ""
	strPass = ""
	do while len(strPass) < 6
		intAsc = int(rnd * 57) + 65
		if intAsc < 91 or intAsc > 96 then
			strPass = strPass & chr(intAsc)
		end if
	loop

	strPass = strPass & cstr(int(rnd*10)) & arrSymbols(int(rnd*ubound(arrSymbols)))

	for i = 0 to 7
		arrPassA(i) = mid(strPass,i+1,1)
	next

	strPass = ""

	booMore = TRUE

	do
		intIdx = int(rnd*8)
		if arrPassA(intIdx) <> "" then
			strPass = strPass & arrPassA(intIdx)
			arrPassA(intIdx) = ""
		else
			booMore = FALSE
			for x = 0 to 7
				if arrPassA(x) <> "" then
					booMore = TRUE
					exit for
				end if
			next
		end if
		if not booMore then
			exit do
		end if
	loop

	if lcase(strPass) <> strPass and ucase(strPass) <> strPass then
		strResult = inputbox("Copy and Paste the following string as the password." & vbcrlf &_
							 "Click Cancel to get another password.", _
							 "Password Display", _
							 strPass)
	end if
loop

function pcase(input)
	pcase = ucase(left(input,1)) & right(input,len(input)-1)
end function

Permanent link to this article: https://www1.wperry.net/code/pwgen/

Leave a Reply

Your email address will not be published. Required fields are marked *