|
Answer» I am looking for a way to make a simple login screen in batch, with the usernames and passwords stored in files. I know that it isn't secure, but that's no problem.
Any help would be great. Try this: Code: [Select]@ECHO off echo. echo.Enter your username: set /p uname= echo.Enter your password: set /p pass=
Thats the login screen but how do you have the usernames and passwords stored in the files, all of them in the same one or in different files?For every user 2 files (1 for username) (1 for password) Alright add this in:
Code: [Select]cd <folder where the files are> If not Exist %uname%.TXT GOTO Fail If not Exist %pass%.txt goto Fail echo. echo.Successfully Logged In! pause exit
:Fail echo.User name or Password incorrect. pause goto Login And add this:
Code: [Select]:Login before this:
Code: [Select]echo. echo.Enter your username:
Hope this helps ,Nick(macdad-)Works great, but is it possible to store the username and password IN a file?
i would prefer using one file for all users:
Code: [Select]@echo off if not exist base.txt echo.>>base.txt
:MAIN cls set /p user=Username: set /p pass=Password:
for /f "tokens=1,2 delims=;" %%F in (base.txt) do (
if "%%F" equ "%user%" (
if "%%G" equ "%pass%" ( goto LOGIN ) ELSE ( echo.Wrong password! pause >nul goto MAIN )
) ) echo.%user%;%pass%>>base.txt goto MAIN
:LOGIN cls echo.User logged: %user% echo.Pass : %pass% pause >nul goto MAINTried it and works perfect!
Thanks!
|