Random Password Generator Script

By maartenr, Updated on 14 Aug 2014
push_pin
star

This script can be used to generate a random password which can be used for the CRM7 user the first time you install SuperOffice. After stating the script it will show the password in a messagebox. You can copy the password to the clipboard using "Ctrl-C" and paste it in your documentation.

Script:

function RandomString()

Randomize()

dim CharacterSetArray
CharacterSetArray = Array(_
Array(5, "abcdefghijklmnopqrstuvwxyz"), _
Array(1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), _
Array(1, "0123456789"), _
Array(1, "!@#$+-*&?:") _
)

dim i
dim j
dim Count
dim Chars
dim Index
dim Temp

for i = 0 to UBound(CharacterSetArray)

Count = CharacterSetArray(i)(0)
Chars = CharacterSetArray(i)(1)

for j = 1 to Count

Index = Int(Rnd() * Len(Chars)) + 1
Temp = Temp & Mid(Chars, Index, 1)

next

next

dim TempCopy

do until Len(Temp) = 0

Index = Int(Rnd() * Len(Temp)) + 1
TempCopy = TempCopy & Mid(Temp, Index, 1)
Temp = Mid(Temp, 1, Index - 1) & Mid(Temp, Index + 1)

loop

RandomString = TempCopy

end function

dim strMessage

strMessage = "Password: " & RandomString
Call MsgBox(strMessage, vbOKOnly + vbInformation, "SuperOffice Random Password")