Batch file that asks for username / password + registration

I need a batch file that can register the user in itself. sort of:

@echo off
echo Choose an option:
echo     1:Register
echo     2:Login
Set option=
set /p option=Your option: 
if %option%==1 goto reg
if %option%==2 goto login
...
:reg
--The registration script--
goto login
...
:login
Set usr=
set /p usr=Username: 
if %usr%== goto pass
echo False username!
@pause
goto login
...
:pass
Set passw=
set /p passw=Password: 
if %passw%== goto success
echo False password!
@pause
goto login

So ... something like that. 'if% passw% == ", and if% usr% ==" "' === this should automatically do this at registration.

Well, if more than 1 person registered.

+3
source share
11 answers

Hmmm. This is what I learned with:

@echo off
title REGISTERANDLOGIN
if exist programbase.dll goto login
if not exist programbase.dll goto register

:register
title Register
echo Register
echo.
echo Please fill in the blanks.
echo.
Set usrname=
set /p usrname=Username: 
Set passw=
set /p passw=Password: 
echo %usrname%>> programdata.dll
echo %passw%>> programbase.dll
goto login

:login
:begin
set usr=
set /p usr=Enter your username: 
if {%usr%}=={} goto :begin
set authenticated=
for /f "tokens=*" %%a in (programdata.dll) do (
    if {%%a}=={%usr%} set authenticated=true
)

if not defined authenticated (echo Invalid Username & goto :begin)

:passwo
set pass=
set /p pass=Enter your password: 
if {%pass%}=={} goto :begin
set authenticated=
for /f "tokens=*" %%a in (programbase.dll) do (
    if {%%a}=={%pass%} set authenticated=true
)
if not defined authenticated (echo Invalid password & goto :begin)

:loggedin
cls
echo Welcome.
@pause
exit /b 0
+1
source

To check for an empty string, place quotation marks on both sides:

if "%usr%"==""

To add to a text file, use →

echo %usr%:%pass% >> passwd.txt

To iterate over the contents of a file, use for / f:

for /f "delims=: tokens=1,2" %%x in (passwd.txt) do (
  if "%%x"=="%usr%" then (
    set usrfound=true
  )
)
if "%usrfound%"=="" then (
  rem Register user
) else (
  rem Check password and succeed/fail
)

, . for , :

setlocal enabledelayedexpansion

, , , ! var! % var%.

+1

, :

 @ echo off 
 goto username
 :username
 echo Hello, please log in with your user ID or type "reg" to register.
 echo Username: 
 set /p user
 if %user%== username(s)here goto password
 if %user%==reg goto register
 if not defined user (
 cls
 echo Bad username!
 pause
 exit
 )

. , , !

+1

., . , . , "Color Changer" "TicTacToe". TicTacToe , www.screwthelotofyou.webs.com/files/. Color Changer . ", , , ". - ScrewTheLotofYou

, ., : http://www.mediafire.com/?kwzzvk24nuze8fq , .: D ~ meilviruz99

+1

-, :

ECHO Enter some input, and press Enter when ready . . .
ECHO ←[13;0;64;13p
COPY CON USRINPUT.TMP
ECHO ←[13;13p
CLS
ECHO You typed:
TYPE USRINPUT.TMP

ANSI Enter CTRL-Z.

0

, , -, , - this .

, .

0
@echo off

if exist "%userprofile%\documents\Login\Accounts" goto start0

if not exist "%userprofile%\documents\Login\Accounts" md "%userprofile%\documents\Login\Accounts"

 :start0

title Login

color 02

cls

echo ---------------------------------

echo              Login.

echo ---------------------------------

echo.

echo.

echo.

echo 1.Create New Username.

echo 2.Log in.

echo.

echo.

echo.

set /p A=Choice:

IF '%A%' == '1' GOTO NewUser0

IF '%A%' == '2' GOTO Login0

IF NOT '%A%' == '1' GOTO start0

:NewUser0

cls

color 02

cd "%userprofile%\documents\Login\Accounts"

set /p newuser=New Username:

IF EXIST %newuser%.bat GOTO inval0

set /p newpass=New Password:

echo set realusername=%newuser% >> %newuser%.bat

echo set password=%newpass% >> %newuser%.bat

IF EXIST %newuser%.bat GOTO NewUser1

IF NOT EXIST %newuser%.bat GOTO NewUser2

:NewUser1

echo Your Account Has Been Created Successfully. Press An Key To Continue.

pause >nul

GOTO start0

:NewUser2

cls

color 0c

del /f /q %newuser%.bat

echo ERROR!Account Could Not Be Created For Unknown Reasons.Press Any Key To Continue

pause >nul

GOTO start0

:Login0

cls

color 02

cd "%userprofile%\documents\Login\Accounts"

echo Login.

echo.

echo.

echo.

echo.

set /p loguser=Username:

IF NOT EXIST %loguser%.bat GOTO inval1

:Login1

set /p logpass=Password:

call %loguser%.bat

if %logpass% == %password% goto success0

goto invalid2

:inval0

cls

color 0c 

echo Desired Username Already Exists. Press Any Key To Continue.

pause >nul

GOTO start0

:inval1

cls

color 0c 

echo Desired Username Does NOT Exist. Press Any Key To Continue.

pause >nul

GOTO start0

:invalid2

cls

color 0c 

echo Invalid Password. Press Any Key To Continue.

pause >nul

cls

color 02

echo Login.

echo.

echo.

echo.

echo.

echo Username:%loguser%

GOTO Login1

:Success0

cls

color 02

title End Of My Script

echo You Successfully Logged In.

echo Here Is Where You Continue The Script.

ping localhost -n 3 >nul

echo.

echo.

echo.

echo Press Any Key To Exit.

pause >nul 

exit
0

:

@echo off
cls
echo @prompt set date=$d$_set time=$t$h$h$h > {a}.bat
%comspec% /e:2048 /c {a}.bat > {b}.bat
for %%v in ({b}.bat del) do call %%v {?}.bat
:LoGINSCR
ECHO Euronet MessageBoard
ECHO v1.0 [BETA]
goto LOGIN
:LOGIN
ECHO.
set/p user=Login As:
if %user%==Eugene goto PASSWORD
if %user%==Toxic goto PASSWORD
if %user%==Plague goto PASSWORD
if %user%==Jason goto PASSWORD
goto LOGIN
:PASSWORD
set/p pass=Password:
if %pass%==$euronet$ goto SYSTEM
goto LOGIN
:SYSTEM
ECHO Welcome to Euronet MessageBoard, %user%.
goto INPUTMAIN
:INPUTMAIN
ECHO.
set/p main=%user%/chat:
if %main%==help goto HELP
if %main%==join goto JOIN
if %main%==quit goto EXIT
if %main%==ic goto IC
goto ERROR
:IC
ping google.com
PAUSE
ping wikipedia.org
PAUSE
ping facebook.com
PAUSE
ipconfig
PAUSE
goto INPUTMAIN
:ERROR
ECHO [ERROR] No command found ("%main%")
goto INPUTMAIN
:HELP
ECHO Type help to show the help page.
ECHO Type join to join board
ECHO Type quit to exit MessageBoard
ECHO Type ic for internet check
ECHO After you joined the board, you can update
ECHO your screen by pressing "Shift & 6".
goto INPUTMAIN

:JOIN
ECHO.
set/p mesgc=Enter your message:
ECHO %user% [%time%] - %mesgc% >> messg1
goto TRAFFIC
:TRAFFIC
cls
TYPE messg1
goto JOIN
:CLS
cls
goto TRAFFIC
:EXIT
exit

, bat . TYPE /p . , , Shift 6 Enter.

0

? , . - launguage. .

0

:) : login.bat, login2.bat, . login.bat:

@echo off
choice /c:RL /m "Choose an option: Register (R) or Login (L).:
if errorlevel 2 goto login
if errorlevel 1 goto register
:register
start /wait C:\[path]\login2.bat
cls
goto login
:in
cls
echo Welcome %u%
echo.
echo Bla Bla Bla or start "a program"
pause
exit
:login
set /p u=Username
set /p p=Password

login2.bat:

@echo off
:a
set /p a="Choose a Username"
set /p b="Choose a Password"
echo.
choice /m "Are you sure you would like your Username to be %a% and your Password to be %b%?"
if errorlevel 2 goto a
set q="if %%u%% equ %a% if %%p%% equ %b% goto in"
for /f "tokens=*" %%I in (%q%) do set m=%%I
echo %m% >>C:\[path]\login.bat
exit

, : in, , , , , login.bat, : login, , , . , . 100% . , !

0

, , , , .

A really easy way to do what you ask for is to simply register and the login page that detects the files. For example, create a pair of directories, such as userSaves or passSaves. Then the system simply determines if the files exist at login:

:page
set /p usr=Username:
if exist mydir\LoginProgram\saves\userSaves\%usr% (
echo Valid Username.
pause
goto passentry
cls
 ) else (
echo Invalid Username.
pause
goto page
cls
)
:passentry
cls
set /p pass=Password:
 if exist mydir\LoginProgram\saves\passSaves\%pass% (
echo Valid Password. Welcome!
pause
goto whateverpage
cls
 ) else (
echo Invalid Password. Login failed.
pause
goto page
cls
)

Super simple code. Just do the same for registration.

0
source

Source: https://habr.com/ru/post/1708981/


All Articles