Author Options:

I need to make a batch file that asks/ receives user commands/ passwords. Answered

I need the basics for asking for a password, and also ask for yes/no from the user, also to make menus for the file and also for the user to type in secret commands, possibly when you could put in a different one, such as it asking for a password, and you have 2 options. I need them to be very simple, and easy to put into the file design.


wizerd 745

10 years ago

to ask for a pasword you could use:
set /p pass=What is the password?

to check the password:
if %pass%=%password%

for yes no you could use:
set /p yn="question here"

and check with:
If %yn%=yes "command"

OR (this is the one I would use)
ask with:
choice /C YN /M "Press Y for Yes or N for No

and check with:
If ERRORLEVEL 1 "command"
(the errorlevel increases with each option:
y=1 n=2

I don't think you can add menus.
However, I would check into the choice command and see what you can do with it.
choice /?
into cmd


10 years ago

I have made a program exactly like this for operator99 he will be making an Instructable on it shortly