Frage

I am putting conditional statement for exit in batch file.

:choice
set /P c=Do you want to exit [y/n]?
if /I "%c%" EQU "Y" goto :optA
if /I "%c%" EQU "N" goto :optB
goto :choice

:optA

pause 
exit

:optB
pause >nul

pause>nul does not work as expected.

I wish to have gain control in command prompt once I say No in the exit options in above code.

War es hilfreich?

Lösung

Try this:

:optB
cmd /k

Another option is to simply do it as:

:optB
cmd.exe

This will start the cmd instance within the same window, after the execution of batch file is done, if option B is chosen.

You can also just do it as:

:optB
cmd

...without the extension.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top