Computing.Net > Forums > Windows XP > Password generator batchfile

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Password generator batchfile

Reply to Message Icon

Name: blink
Date: May 14, 2006 at 23:47:21 Pacific
OS: XP
CPU/Ram: P4/1GB
Product: Me!
Comment:

I have a batchfile that creates users on a proxy server. You enter a username and a password, which pretty much is just randomly slamming keys up to 8 characters.

Is there a way to make dos generate this? %random% could work, except that its just numbers and I want numbers and lowercase letters, to form a completely randomized string of 8 characters.



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: May 15, 2006 at 03:06:06 Pacific
Reply:

The folowing is not a true random password, but you can build on it replacing the conditional statement

@Echo Off
SetLocal EnableDelayedExpansion
Set Alpha=abcdefghijklmnopqrstuvwxyz

For /L %%j in (1,1,8) Do Call :PSW

Echo Password is [%PSWRD%]
EndLocal
GoTo :EOF

:PSW
If %random% gtr 10000 (
Set PSWRD=%PSWRD%%random:~0,1%
) else (
Set /A i=%random:~-1,1%+%random:~1,1%
If !i! gtr 25 Set i=25
Set PSWRD=%PSWRD%!Alpha:~%i%,1!
)
GoTo :EOF


0

Response Number 2
Name: blink
Date: May 15, 2006 at 07:11:46 Pacific
Reply:

Looks good! Thanks!

How do I limit the usage of numbers to, lets say, 2?


0

Response Number 3
Name: IVO
Date: May 15, 2006 at 12:14:35 Pacific
Reply:

The number of digits/characters in the string is driven by

For /L %%j in (1,1,8) Do Call :PSW

so to get a key of 2 digits code

For /L %%j in (1,1,2) Do Call :PSW

Beware the sample posted is a raw one; it may return a numeric key as an alphameric one. To meet high safety standard more work is required.


0

Response Number 4
Name: IVO
Date: May 15, 2006 at 12:34:22 Pacific
Reply:

Sorry I I did not understand what actually you want, i.e. to generate a key with two digits only, isn't it?

To achieve that replace the :PSW routine with

:PSW
If "%Digit%"=="2" Goto :CHR
If %random% gtr 10000 (
Set PSWRD=%PSWRD%%random:~0,1%
Set /A Digit+=1
GoTo :EOF)
:CHR
Set /A i=%random:~-1,1%+%random:~0,1%
Set /A i=%i%+%random:~-1,1%
If !i! gtr 25 Set i=25
Set PSWRD=%PSWRD%!Alpha:~%i%,1!
GoTo :EOF

That has minor fixes too.


0

Response Number 5
Name: blink
Date: May 15, 2006 at 23:54:36 Pacific
Reply:

What I actually want is a random string of 8 characters formed by lowercase letters and a maximum of 2 numbers. So something like

wehy10wnw
2y8wejabf

The position of the numbers should be random too. So exactly that! Thanks!

How does it do what it does?


0

Related Posts

See More



Response Number 6
Name: IVO
Date: May 16, 2006 at 03:39:28 Pacific
Reply:

From your last post I assumed my code works and fits your needs (I did not test the improved script I posted as I was short in time).

The batch relies on the "delayed expansion of variables" that allows to manipulate substrings and array variables, as Alpha, using the "variable inside variable" notation (! and % to mark variables).

The whole script is actually a strechted implementation of advanced NT batch coding.



0

Response Number 7
Name: blink
Date: May 17, 2006 at 01:04:48 Pacific
Reply:

I see.

How do I implement this in my code?

In the current situation it asks for a user and a pass which it then exports to a text file. What I want it to do is that when the string entered for the pass is "x" it generates a password and exports that with the user name.


0

Response Number 8
Name: IVO
Date: May 17, 2006 at 03:33:25 Pacific
Reply:


Mail me at the address you find clicking IVO and report *exactly* what your batch needs to do.

My code can easily be integrated into your script, but I prefer the private mail channel because this thread is fading down as time goes by.

And you have to be patient before getting an answer as I have my own business to run too.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Password generator batchfile

IE upload/download port www.computing.net/answers/windows-xp/ie-uploaddownload-port/143190.html

What The Hell www.computing.net/answers/windows-xp/what-the-hell/100972.html

CMD: passgen with variables www.computing.net/answers/windows-xp/cmd-passgen-with-variables/165734.html