I am trying to make a login bat file. i have seen some on youtube but the batch file doesn't remember what the login was.i need a code that will read a txt file and match it to the user input. So if i typed Collin for the user name then type my password it would search in the user account file i made Here is my code :
@echo off
title Login System
cls
echo Please register
echo.
set /p user=Username:
set /p pass=Password:
cls
echo %user% %pass% > useraccounts.txt
echo Your account %user% has been created
echo.
cls
pause
:login
echo Please Login
echo.
set /p u=Username:
set /p p=Password:
if %u%==%user% if %p%==%pass% goto securitypass1
echo Wrong User Name Or Password
local pin host>nul 6
goto login
:securitypass1
cls
echo You are now login as %user%
It isn't quite finised
You will need to create multiple text files, unless you are wanting to download third party software. Here's how I have done it in the past: (I'll explain, then give you the code.)
- Have it save the user information in folder titled with the users name.
- have a two text files within this folder ("User" and "Password")
- Save the users name and password in the text files
Code:
@ECHO OFF :Start CLS ECHO Enter 1 to login, or 2 to register: SET /p entry="" IF "%entry%"=="1" GOTO Login IF "%entry%"=="2" GOTO Register CLS ECHO Unknown Command ECHO. PAUSE GOTO Start :Login CLS ECHO What is your name? SET /p name="" CD %name% IF "%ERRORLEVEL%"=="1" GOTO Error1 SET /p password= <password.txt :Password CLS ECHO Enter your password SET /p password1="" IF "%password%"=="%password1%" GOTO Approved CLS ECHO Incorrect Password ECHO. PAUSE GOTO Password :Approved CLS ECHO You are now logged in as %name%! ECHO. PAUSE CD.. GOTO Next :Register CLS ECHO What is your name? SET /p name="" MKDIR %name% CD %name% CLS ECHO What is your password? SET /p password="" >password.txt ECHO %password% CLS ECHO Successfully registered! ECHO. PAUSE CD.. GOTO Start :Error1 CLS ECHO Unknown User ECHO. PAUSE GOTO Start :NextThat should work nicely.
Ok i tryed that and just know rilized it something. Yes your idea did work but i just edited your code a bit. Here my code with your code @echo off
:start
cls
echo Please Sign in
echo ===================
echo.
set /p datauser Enter your new username=
set /p datapass Enter your new password=
cd %userprofile%\data_aco\
edit echo. > %datauser%.txt
edit echo. > %datapass%.txt
cls
echo Sign Up
echo ===================
echo.
echo Your account was Sucessfully created
echo.
pause
goto startThen For the login part:
@echo off
:loginstart
echo Please Log in
echo ===================
echo.
set /p dataun=
echo.
set /p datapw=
cd %userprofile%\data_aco\
if exist %dataun%.txt got secpass1
echo INVAILD USER NAME
pause
goto loginstart
:secpass1
cd %userprofile%\data_aco\
if exist %datapw%.txt goto secpass2
echo INVAILD PASSWORD
pause
goto loginstart
:secpass2
echo You have signed in Sucessfully
pauseWould that work.
And how would you hide the txt file with the accounts because then they could access
P.S. I sent you a privite message -_O ITS A REAL SUPRISE
There is just so much wrong with that I don't even know where to begin... Model your code after the one I have given you, it works, yours doesn't.
To make the files hidden:
C:\>attrib /? Displays or changes file attributes. ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [+I | -I] [drive:][path][filename] [/S [/D] [/L]] + Sets an attribute. - Clears an attribute. R Read-only file attribute. A Archive file attribute. S System file attribute. H Hidden file attribute. I Not content indexed file attribute. [drive:][path][filename] Specifies a file or files for attrib to process. /S Processes matching files in the current folder and all subfolders. /D Processes folders as well. /L Work on the attributes of the Symbolic Link versus the target of the Symbolic Link
i wasen't probably thinking it was very early in the moring when i did this i'm sorry. Ok so i need to hide the files right? Using ATTRIB +h so it would be this C:useracos ATTRIB +h
Because i will put the files there
I think we need a faster way of communcation LOL
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |