How to create a choice like command in a batch file?

There used to be a windows command called choice, which takes yes or no for an answer. Recently I was making a batch file and tried the same command again but to my surprise found that it was not available.

So I didn’t implement that part. But later I found out another way and probably a better way to implement this behavior using the ‘set’ command.

For eg: if you wanna ask a question like, please enter your name, this is how we would do it…

set /p NameVar=”Please enter your name? “

When you press enter you will be asked for your name and on command completion your name will be stored in NameVar.

You can print out the value using…

echo %NameVar%

One thought on “How to create a choice like command in a batch file?

Appreciate your comments...