loading

Choice command works in CMD but not in a batch file

I was trying to use the Choice command in Windows7 and when I tested it in CMD it worked fine, but when I try to use it in a batch nothing shows up it just stops the batch from doing anything on a blank line. So lets say my batch file was...

@echo off
echo Hi
echo Person
choice /c YN /m Will you be my friend?
if ERRORLEVEL==2 goto :end
if ERRORLEVEL==1 goto :a
echo If you see this it failed...
:a
echo YAY!
Pause>nul
:end
exit

Then I would see

Hi
Person

Then nothing after that. It would just be blinking like you have to type in something on a blank line. Any Ideas?


TheBatchies7 years ago

I think you did it wrong... Let me help.

choice /cyn Will you be my friend?
if %errorlevel% equ 14 goto end
if %errorlevel% equ 25 goto a

And the /N switch makes it so you cannot see the choices, so you yourself made it so you couldn't see it! Haha, happens to me all of the time. Good question, glad if I could help.

No he didn't... He used the /M switch...

I don't know why it's not working...