Responding to questions in a .bat file
Solved
train3000
Posted messages
75
Status
Member
-
train3000 Posted messages 75 Status Member -
train3000 Posted messages 75 Status Member -
Bonjour,
I am looking for a code in MS-DOS ( .bat file) for me to respond with yes or no to a question.
I had already found a .bat file before, but I lost it.
Something like this:
I understand this:
@echo off
echo Hello! How are you?
But I don't understand this:
if %goto% echo Good!
if %goto% echo ok!
I also think there is the "set" command and "answer" but I'm not sure.
Thank you.
I am looking for a code in MS-DOS ( .bat file) for me to respond with yes or no to a question.
I had already found a .bat file before, but I lost it.
Something like this:
I understand this:
@echo off
echo Hello! How are you?
But I don't understand this:
if %goto% echo Good!
if %goto% echo ok!
I also think there is the "set" command and "answer" but I'm not sure.
Thank you.
2 answers
-
@echo off
:menu
set choix=
cls
echo.
set /p choix= Hello! How are you doing? [Yes/No]
if /i "%choix%"=="YES" (echo You are doing well!&pause>nul&goto menu)
if /i "%choix%"=="NO" (echo You are not doing well!&pause>nul&goto menu)
goto menu -
Something like this?
@echo off
echo "Enter your name: "
set /p Name=
echo "Enter your first name: "
set /p firstname=
echo %name% %firstname%
It's the set /p that does everything. The "response" will be found in the environment variable which is between the "/p " and the "="