Option Explicit Dim objCrypt, strArg, strPW Const CAPICOM_ENCODE_ANY = -1 Const CAPICOM_ENCODE_BASE64 = 0 Const CAPICOM_ENCODE_BINARY = 1 With WScript.Arguments If .Named.Count <> 0 Then Syntax If .Unnamed.Count <> 1 Then Syntax strArg = .Unnamed(0) If Not IsNumeric( .Unnamed(0) ) Then Syntax If CInt( strArg ) <> CDbl( strArg ) Then Syntax End With Set objCrypt = CreateObject( "CAPICOM.Utilities.1" ) strPW = Left( objCrypt.GetRandom( strArg, CAPICOM_ENCODE_ANY ), strArg ) Set objCrypt = Nothing WScript.Echo strPW Sub Syntax Dim strMsg strMsg = vbCrLf _ & WScript.ScriptName & ", Version 1.00" _ & vbCrLf _ & "Generate random complex passwords with a specified length" _ & vbCrLf & vbCrLf _ & "Usage: " & UCase( WScript.ScriptName ) & " length" _ & vbCrLf & vbCrLf _ & "Where: ""length"" is an integer specifying the requested password length" _ & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" _ & vbCrLf _ & "http://www.robvanderwoude.com" WScript.Echo strMsg WScript.Quit 1 End Sub