Subscribe to MORPH        RSS Feed
-----

Batch user system - Make a user account

Icon Leave Comment
This code fragment will automate user account creation, thus requiring a login to access the program

:USERSYSTEM                                  

IF NOT EXIST pass_file.bat GOTO CREATE_USER
GOTO LOGIN                            

REM CREATING A USER
:CREATE_USER
TITLE Welcome                        
CLS
echo.
echo You do not have a user account.
echo.
echo Please create an account to use the program
echo.
SET /P USER=Create a username here: 
SET /P NAME=Type your real name here:
echo.
SET /P PASS=Create a password:
SET /P PASS2=Retype your password here:
REM MAKING SURE THE TWO PASSWORDS ARE THE SAME
IF %PASS% NEQ %PASS2% GOTO DIFF       
GOTO CONFIRM     

REM SCENARIO WHEN YOU ENTER TWO DIFFERENT PASSWORDS
:DIFF
CLS
echo The passwords you have entered don't match!
echo.
echo Press any key to go back to the password creation screen
PAUSE >NUL                           
GOTO CREATE_USER

REM CONFIRMING YOUR DATA
:CONFIRM
CLS
echo Please confirm your user settings
echo.
echo USERNAME=%USER%                
echo REAL NAME=%NAME%
echo PASSWORD=%PASS%
echo.
echo.
echo Confirm user settings? (Y/N)
CHOICE /C YN /N                     
IF %ERRORLEVEL% EQU 1 GOTO CREATE_FILES 
GOTO CREATE_USER

REM CREATING USER ACCOUNT
:CREATE_FILES                             
echo :: > "pass_file.bat"
echo SET PASSWORD=%PASS% >> "pass_file.bat" 
echo SET NAME=%NAME% >> "pass_file.bat"
echo SET USER=%USER% >> "pass_file.bat"
attrib +h +s pass_file.bat                 
GOTO LOGIN

REM LOGIN
:LOGIN

CALL pass_file.bat                         
CLS
echo Enter your username:
echo.
SET /P USERNAME=
IF %USERNAME% NEQ %USER% GOTO DIF
CLS
echo Enter your password:
echo.
SET /P PASS=
IF %PASS% NEQ %PASSWORD% GOTO DIF
GOTO PROGRAM

REM THE SCENARIO WHEN YOUR USERNAME/PASSWORD IS INCORRECT
:DIF
CLS
echo Your password/username is incorrect
echo.
echo Press any key to try again
PAUSE >NUL
GOTO LOGIN

:PROGRAM
REM Put your program here!


0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

October 2017

S M T W T F S
1234567
891011121314
15161718 19 2021
22232425262728
293031    

Recent Entries

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)

Categories