Yes / No

I'm busy building a script for myself that empties different folders, but I want to make a Yes / No choice for the user, where N returns to the menu and Y runs the script.

Here is what I got:

:temp

CHOICE /C YN /M "Enter your choice:" 
IF ERRORLEVEL Y GOTO deltemp
IF ERRORLEVEL N goto reset

:reset
goto menu

:deltemp

Now it goes directly to the menu, I think the result is: reset which is higher: deltemp.

+4
source share
1 answer

errorlevel can only have numeric values. CHOICE command commands increase the error level for each subsequent letter:

:temp

CHOICE /C YN /M "Enter your choice:" 
IF ERRORLEVEL 2 goto reset
IF ERRORLEVEL 1 GOTO deltemp


:reset
goto menu

:deltemp
+3
source

All Articles