prompts for input, and not close the cmd window. Can this be done?
I searched a little and found no answer. I tried a goto :exitNow but the code flows
from the label that has exit /b, back to where the goto was executed.
The solution must be batch code only, as the goal of my project is to
conquer time (time to deliver a file), space (framed space) and colors, all 16,777,216 of them,
and do it all with batch code.
Here is a test script that I think illustrates my goal to immediately close a batch file
without having to backtrack to the main code level. I do not want to close the cmd
window as this would not be user-friendly.
Code: Select all
@echo off rem goal: close the batch file from any prompt while keeping cmd window open setlocal :top echo in main set "rsp=" set /p "rsp=Press Enter to continue or enter X to exit from main " If /I "%rsp%" equ "X" exit /b call :fun1 goto :top endlocal & exit /b :fun1 setlocal :fLoop echo in fun1 .. enter X to immediately exit set "rsp=" set /p "rsp=" If /I "%rsp%" equ "X" ( echo X was entered--now how do I close the batch file from subroutine? ) Else ( goto :fLoop ) endlocal & exit /b