Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to make a quick little installer and uninstaller app, because I seem to use these little resources a LOT, and it's set up to have y mean uninstall, and n mean end the script, standard stuff, the problem is if I type a non y or n key, it automatically uninstalls.

How can I make it fail on non y/n keys?

Also, can I make it display the entered key on a new line, so it's more visible?

Here's my script.

SET /P ANSWER=Do you want to uninstall? (Y/N)?
echo You chose: %ANSWER%
if /i {%ANSWER%}=={y} (goto :uninstall)
if /i {%ANSWER%}=={n} (goto :end)
goto :end

~EDIT~ Changed the script to look like this, same behavior.

if /i %ANSWER% == y goto :uninstall else goto :end
share|improve this question
    
Please move the 'I figured it out' part from the question to an answer, then mark it as the correct answer – Jan Doggen May 3 '13 at 9:01
    
Any reason you can't use something like choice with ErrorLevel instead? It's made specifically for this sort of usage. – Karan May 4 '13 at 1:41
up vote 0 down vote accepted
SET /P DELETE=Do you want to uninstall (Y/N)?
echo You chose: %DELETE%
if !DELETE! == y (goto uninstall) else (goto cancel)
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .