My site is ad supported.

Random Chars [Password Generator] (Script)

Version 1.4 - Download


Generates a string of random alpha-numeric characters of a specified length and character set. This script is ideal for generating random passwords from the Windows command line.


The following command generates a random 10 character string using all numbers, upper case, lower case letters, and (defined) special characters as its selection set:

RandomChars 10 /S

The following command generates a random 5 digit number:

RandomChars 5 /R 10

The following command generates a random 15 character string using only uppercase letters:

RandomChars 15 /R 36 /O 10

The following command generates a random string in GUID format (8-4-4-4-12) using all digits and upper case letters A-F as its selection set:

RandomChars /G

The following script generates a 12 character password to a variable and prints it to the screen:

FOR /F "usebackq tokens=*" %%A IN (`CALL RandomChars 12 /S`) DO SET NewPassword=%%A
ECHO Randomly Generated Password: %NewPassword%

My site is ad supported.

Help Information (/?)

RandomChars {Length [/R Range] [/O Offset] | /G}

 Length     Length of the string to generate.
 /G         Generate a random GUID (00000000-0000-0000-0000-000000000000).
 /R Range   Define the range of available characters used for generation.
            The range should be a number between 1 and 62.
            10 = Numbers 0-9.
            36 = Upper case letters A-Z + all previous characters.
            62 = (Default) Lower case letters a-z + all previous characters.
 /O Offset  Define the lower range offset for character generation.
            The offset must be lower than the range (/R) value.
            For example, range 62 with offset 10 will produce characters
            between 10 and 62 only.
 /S         Specifies that at least one special character should be included
            in the generated output.

Version History

Version 1.1

  • Added Offset parameter option.
  • Added psuedo-seeding to the random number used for character generation.

Version 1.2

  • Fixed a bug introduced in version 1.1 where the /G switch did not work.

Version 1.3

  • Added the /S option.

Version 1.4

  • Fixed a passive issue where the /G switch would display "missing operand" before the generated value.