What command line tool can generate passwords on Windows?

6

2

I am looking for something that has an usage like

passgen <length> <charset>

John

Posted 2011-05-08T18:47:06.430

Reputation: 1 101

Answers

2

Cross-Platform: Using PERL

There's a PERL password generator that works for Windows, *nix, OS X, etc.

Usage: genpass [-OPTIONS] LENGTH
-s, --symbols       Exclude symbol characters.
-n, --numbers       Exclude number characters.
-u, --uppercase     Exclude uppercase characters.
-l, --lowercase     Exclude lowercase characters.

On Windows, it can be converted into an executable.

Windows-only

Warning: This will change the password for the administrator account.

Not specifically what you want, but could also come in useful. In the command line, type:

net user administrator /random    

enter image description here

Unix/Linux

See answers of this question: Random password generator: many, in columns, on command line, in Linux

slhck

Posted 2011-05-08T18:47:06.430

Reputation: 182 472

net user administrator /random needs to run under elevated mode on Vista and up – phuclv – 2018-06-24T08:08:19.303

Warning net user administrator /random resets password for administrator. – display_name – 2018-07-17T10:36:03.730

Please add the warning to the answer. – Alex Wiese – 2019-10-02T04:30:33.563

http://search.cpan.org/~rschupp/PAR-Packer-1.009/lib/pp.pm, converts a perl script to an executable. So problem solved. – John – 2011-05-09T11:28:18.450

@johnthexiii Oh, nice. I added it to the answer for later reference. – slhck – 2011-05-09T11:42:28.277

3

Depends on how strong you want your password is. Of course if security is not a problem then echo %random% in cmd or get-random in PowerShell will just work

With PowerShell you can simply call GeneratePassword(int length, int numberOfNonAlphanumericCharacters). For example to generated a 12-character long password with at least 3 special symbols you can call it like this

[Reflection.Assembly]::LoadWithPartialName("System.Web")
[System.Web.Security.Membership]::GeneratePassword(12, 3)

There are several blog posts on MS TechNet on this:

In case you don't want to work with PowerShell then here's a pure batch solution

phuclv

Posted 2011-05-08T18:47:06.430

Reputation: 14 930

I found another batch solution, that is even close to be readable by sane humans: https://stackoverflow.com/questions/30629694/make-a-random-string-in-batch/30630254#30630254

– Gras Double – 2018-06-24T13:13:27.717

@GrasDouble with the other batch file you can tune what type of characters you want to go into the password. Your linked question is about alphanumeric characters only. Of course it can be made to produce non-alphanumeric letters but it's not as flexible as the other question – phuclv – 2018-06-24T14:06:12.900

1

Take a look at SecurePassword Kit command line password generator (archived link). It has the follwing syntax:

gspk.exe /g [-l:password_length] [-a:charset_options] 


Just to clarify: gspk.exe is the executable of a GUI program, but it can also be used in command line by calling it with arguments.

Tapkin

Posted 2011-05-08T18:47:06.430

Reputation: 11

I tried this program in CLI, after execution it has to be terminated using Ctrl+C to get the prompt back, and more importantly, there seems to be no way to grab the output (e.g. to a file, and I did try >output.txt 2>&1), making the program quite useless in practice… – Gras Double – 2018-06-24T04:06:50.793

Read this post, you must.

– James Mertz – 2013-04-17T17:20:36.677