Command Prompt for Windows




ASK Example

Consider the following batch file, which will display a yes/no message, and depending on the user response the program will either continue or end :-

ASK Are you sure (Y/N)?
IF ERRORLEVEL  1 GOTO  no
    ECHO You pressed the 'Y' key
    EXIT
:no
ECHO You pressed the 'N' key

Similarly, the following batch file will display a yes/no message and either loop or end :-

:loop
ECHO Hello, world!
ASK Again (Y/N)?
IF ERRORLEVEL 1 GOTO no
GOTO loop
:no
ECHO You pressed the 'N' key