Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm trying to create a batch script that can read a single lined file containing a password (making a login script), than set the read string as a variable. So far, all my attempts have failed. I'm pretty new to batch files, so the simplest script possible would be the best. This is what I've tried so far:
@set tpass=(TYPE "c:\login\%name%s_pass.bat")
This is what I've tried so far, but instead of reading the file and setting it as tpass, it sets tpass as "(TYPE "c:\login\%name%s_pass.bat")".
%name% is the name their trying to login as
tpass is the pass they entered to compare with the stored pass
%name%s_pass.bat is the file I'm trying to read (but It doesn't have to be a bat)

set /p tpass=< c:\login\%name%s_pass.bat
=====================================
If at first you don't succeed, you're about average.M2

Having more problems now. I'll copy the main part of my script down:
@:LOGIN
@set /p name=UserName?
@echo Checking...
@ping -n 3 127.0.0.1 >NUL
@if exist c:\login\%name%s_name.bat goto NAMEPASS
@GOTO NAMEFAIL@:NAMEPASS
@set /p pass=PassWord?
@set /p tpass=< c:\login\%name%s_pass.bat
@if %tpass%==%pass% GOTO LOGINTRUE
@if not %tpass%==%pass% GOTO LOGINFALSE
@pause(This isn't the entire script, just the part I'm having problems with)
I hope this helps explain what I'm trying to do.
Again, %tpass% is the stored password that is used to compare to the password that they enter at login (%pass%).

What is the problem?
=====================================
If at first you don't succeed, you're about average.M2

this is certainly not the best way to password authenticate a person. If its for fun, then its ok. If not, set up a proper authentication mechanism, not using batch!

I agree with ghostdog. Just to illustrate a point, consider the following user's answer to the first prompt:
UserName? nul type C:\input\* & rem
Then the batch file will execute this statement:if exist c:\login\nul type C:\input\* & rem s_name.bat goto NAMEPASS
And so this user will get to see everyone's name and password.

![]() |
![]() |
![]() |

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