Batch File Login Script

September 25, 2012 at 07:37:13
Specs: Windows XP
So I am trying to make a log in system for my batch files. I have it to where it creates the text document and puts the info in it, I just don't know how do make it so if you type in an unregistered name (name in the text file) or password wrong, it will tell you. Here is my script if think you can help me.

@echo off
title login
color 0b
:menu
cls
echo 1.Sign in
echo 2.Register
echo 4.Exit
echo.
set /p input=What would you like to do:
if %input%==1 goto log
if %input%==2 goto reg
if %input%==3 goto exit
goto error

:reg
cls
color 0e
set /p user=Enter your desired username:
set /p pass=Enter your desired password:
echo %user% >> username.txt
echo %pass% >> password.txt

:log
if exist username.txt goto menu2
if not exist password.txt goto reg
goto error

:menu2
cls
color 0b
echo WELCOME!
echo.
echo 1.Sign in
echo 2.Options
echo 3.Exit
echo.
set /p input=What would you like to do?
if %input%==1 goto log2
if %input%==2 goto op
if %input%==3 goto exit
goto error

:exit
exit

:log2
cls
color 0b
set /p input=Username:
if exist goto pass2
goto error


See More: Batch File Login Script

Report •


#1
September 25, 2012 at 08:11:10
I put it under what I have in log2, but all it does is send me back to the menu instead of letting me go to the password part.

Report •

#2
September 25, 2012 at 08:27:32
title login
color 0b

:menu
cls
echo 1.Sign in
echo 2.Register
echo 4.Exit
echo.
set /p input=What would you like to do:
if %input%==1 goto log
if %input%==2 goto reg
if %input%==4 goto exit
::changed this to 4, the menu suggested 4 without a goto.
goto menu

:reg
cls
color 0e
set /p user="Enter your desired username: "
set /p pass="Enter your desired password: "
echo %pass% >> %user%.txt
::changed this to set a text file with a password within.
goto menu

:log
set /p user="Enter your current username: "
set /p pass="Enter your current password: "
@echo on
set /p password=<%user%.txt
pause
@echo off
if %pass% equ %password% goto menu2
goto menu

:menu2
cls
color 0b
echo WELCOME!
echo.
echo 1.Sign in
echo 2.Options
echo 3.Exit
echo.
set /p input=What would you like to do?
if %input%==1 goto log2
if %input%==2 goto op
if %input%==3 goto exit
goto menu
:log2
echo there is no second log 2
goto menu
:op
echo there are no current options
goto menu
:exit
goto :eof

:: mike

I figured this might give you the option to have specific users and passwords. kept your original idea intact aside from that.


Report •

#3
September 26, 2012 at 07:22:05
When I add all that you did and such, it tells me about my documents and my password=0. What is all that about? Also, what do I need to do so when you actually log in it works and tells you if the account is in use or not, and if the user/pass is right or wrong. Also is it possible to make a folder that puts all the user/pass txt documents in it? like Character folder, then when you open it, it has the name of all the users and passwords.

Report •

Related Solutions

#4
September 27, 2012 at 14:16:50
sorry, probably forgot the @echo off at the beginning

as for the rest, all you would have to do is add a folder (md foldername) and then add that to where it is storing the username

:: mike


Report •

#5
October 3, 2012 at 07:13:51
How exactly would I make it to the put the text file into the folder?

Report •

#6
October 3, 2012 at 09:15:37

:reg
cls
color 0e
set /p user="Enter your current username: "

::add this below
if not exist c:\rpg\%user% md c:\rpg\%user%

:: mike


Report •

#7
October 6, 2012 at 04:49:35
really easy to do:
This is an example, add bits of it to urs.

@echo off
set INV=type ur password below
:home
cls
echo %INV%
set /p "input=plz enter here>"
if %input%==ENTERURPASSWORDHERE goto hi
If NOT %input%==ENTERURPASSWORDHERE set INV=INCORRECT && goto home
:hi
color a
cls
echo u are now logged in
Pause>nul


Report •


Ask Question