Computing.Net > Forums > Programming > Batch File Password

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.

Batch File Password

Reply to Message Icon

Name: Impulse
Date: January 4, 2009 at 13:27:21 Pacific
OS: Windows XP Pro SP2
CPU/Ram: AMD Semptron - 1.5gb RAM
Product: E-machines / T3120
Subcategory: Batch
Comment:

Hi, i'm making a batch file where the user
enters a password. Instead of the password
intergrated inside the batch file, I need it
to be saved on a seperate file, like pwd.txt.
How would you make the batch file read it and
see if it has the same text as the user has
inputted?



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: January 4, 2009 at 14:31:03 Pacific
Reply:

First create pwd.txt and give it the Hidden and ReadOnly attributes for safety reasons.

echo.MyPassword>pwd.txt
attrib pwd.txt +R +H

Then to read the stealth password and compare with the one typed

set /P PWD=<pwd.txt
set /P USER=Enter Password^>
if "%USER%"=="%PWD%" (goto :OK) else (goto :ERROR)

That however allows the password to be stolen while the user is typing it on the screen.


0

Response Number 2
Name: FishMonger
Date: January 4, 2009 at 19:51:21 Pacific
Reply:

Security through obscurity is no security all.

Passwords used in batch files, even if they are stored in a hidden text file, is IMO completely worthless. My 10 year old nephew knows how to access a "hidden" text file to get the password that is stored in it.

If you really need to use password authentication, then use a language that doesn't store the password in a plain text file and you should store them encrypted.


0

Response Number 3
Name: reno
Date: January 5, 2009 at 10:31:34 Pacific
Reply:

i'm facing the same problem here.
what's the better way to store plain password? i'm thinking of storing it in registry, but dont have a clue to do it. at least it stop the average computer user to look at my data.


0

Response Number 4
Name: FishMonger
Date: January 5, 2009 at 11:36:37 Pacific
Reply:

Putting the passwords in the registry is 1 step above a plain text file, but still not very secure.

Here's an example on using regedit in a batch file, but I'm sure IVO can come up with a better example.
http://www.robvanderwoude.com/reged...

A better option would be to store encrypted passwords in a database, such as mysql, and use a scripting language like Perl or Python, or one of the VB variants.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File Password

Batch file to enter password protec www.computing.net/answers/programming/batch-file-to-enter-password-protec/16637.html

Password in a batch file www.computing.net/answers/programming/password-in-a-batch-file/18315.html

FTP and Batch Files www.computing.net/answers/programming/ftp-and-batch-files/13160.html