Question:
How to write this program in Batch?
?
2013-03-03 11:33:08 UTC
I want to learn how to write a program in Batch that would do these things:
1) Be able to "log in"

2) Store MULTIPLE usernames and passwords that would work in a file such as .txt, .uf, etc.,
meaning that you could log in with more than just one username/password

Note: Yes I know that this is completely pointless and would be of no use but I want to learn a bit
of Batch and I thought this would be a good program to try

Thanks
Three answers:
eric
2013-03-03 14:13:42 UTC
I made a login for a database a while back. See if this helps.



@echo off

color e0

:newadmin

echo.

echo.

echo ////////////////////////////Login Setup Screen//////////////////////////////////

echo.

if exist c:\portersystem\systemdata\*.txt goto userlogin

echo.

echo.

echo This will set up your user name and password.

echo.

echo Only (A-Z) (a-z) (0-9) characters are supported.

echo.

echo.

set /p newadminuser=Enter new username:

echo. >> c:\portersystems\systemdata\%newadminuser%

attrib c:\portersystems\systemdata\%newadminuser% +h

echo.

set /p newadminpass=Enter new password:

echo. >> c:\portersystems\systemdata\%newadminpass%

attrib c:\portersystems\systemdata\%newadminpass% +h

echo.

echo.

set /p hint=Enter password hint:

echo. %hint% >> c:\portersystems\systemdata\hint.txt

echo.

echo.

echo Login entries saved.

echo.

pause

goto userlogin





:userlogin

cls

color e0

echo.

echo.

echo /////////////////////////////////Login Screen///////////////////////////////////

echo.

echo.



echo.

set /p loginname=username:

if "%loginname%" equ "3z65cv2ga7yhvb9" goto newadmin

if exist c:\portersystems\systemdata\%loginname% goto userpass

echo.

echo %loginname% is not a valid username.

pause

cls

goto userlogin



:userpass

cls

color e0

echo.

echo.

echo /////////////////////////////////Login Screen///////////////////////////////////

echo.

echo.

echo.

set /p loginpass=password:

if exist c:\portersystems\systemdata\%loginpass% goto porterdbs

if not exist c:\portersystems\systemdata\%loginpass% goto showhint



:showhint

echo.

echo Password entered is incorrect.

pause

type c:\portersystems\systemdata\hint.txt

pause

goto userpass
ʄaçade
2013-03-03 11:47:04 UTC
Most operating systems support some kind of Batch processing. You did not mention which OS you are using, so I will assume Linux.



For security reasons, you have to login to an authorised account BEFORE you can run any batch programmes. In the case of cron or cron-like automated processing, the daemon logins you into the account because it runs with elevated privileges (for just that purpose).



Added: Right. You want an application-specific user login. Yes, that is entirely different. My suggestions:



(a) Instead of user/pw, think of this as a more basic text file processing task. Not an authentication task.



(b) Instead of a username file and another password file, consider a "Users" directory (owned by your programme) in which you store a file whose name is the user's name. In that file, just store the username (same as filename) and the password:



file: façade.uf

façade=meep123



file: wolverine16.uf

wolverine16=wolvesarecool



Now you have a directory ('folder') with one file for each person and the file contains the password for that user.



So much easier to handle.

Delete a user? --- Delete the file.

See known user list? --- ls the directory.

Add a user? --- Create a new file.

Username already exists? --- File already exists.



Simple.
inzano
2016-12-12 18:12:55 UTC
i understand this does not straight away answer your question, in spite of the incontrovertible fact that it could help you besides. have you ever looked at ... initiate >> All classes >> upload-ons >> equipment procedures >> Disk Cleanup if no longer the rest, would supply you recommendations for various directories for cleansing you hadn't concept-approximately.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...