Eu modifiquei sua lógica abaixo para executar a maneira como eu a escreveria, da maneira como você explica que deseja que funcione.
Essentially this will. . .
Use the
CALLcommand to call the specified subroutine rather thanGOTOsince it will pass control back to the subroutine that made the call originally as long as it end withGOTO :EOF.Use the
GOTO :EOFat the end of each called subroutine to pass control back to the original caller subroutine so it can continue to process the rest its logic
Script
::Provides 4 action options
@ECHO OFF
C:
CD\
CLS
:MENU
CLS
ECHO ============= MENU NAME =============
ECHO -------------------------------------
ECHO 1. Create "test" folder C drive
ECHO 2. Open Internet Explorer
ECHO 3. Open "test" folder
ECHO 4. Open Devices and printers
ECHO ==========PRESS 'Q' TO QUIT==========
ECHO.
SET INPUT=
SET /P INPUT=Please select a number:
IF /I '%INPUT%'=='1' CALL :Selection1
IF /I '%INPUT%'=='2' CALL :Selection2
IF /I '%INPUT%'=='3' CALL :Selection3
IF /I '%INPUT%'=='4' CALL :Selection4
IF /I '%INPUT%'=='Q' CALL :Quit
CLS
ECHO ============INVALID INPUT============
ECHO -------------------------------------
ECHO Please select a number from the Main
echo Menu [1-4] or select 'Q' to quit.
ECHO -------------------------------------
ECHO ======PRESS ANY KEY TO CONTINUE======
PAUSE > NUL
GOTO :MENU
:Selection1
md c:\test
GOTO :EOF
:Selection2
start iexplore
GOTO :EOF
:Selection3
start c:\test
GOTO :EOF
:Selection4
control printers
GOTO :EOF
:Quit
PAUSE
Mais recursos
-
CALL a subroutine (:label)
The
CALLcommand will pass control to the statement after the label specified along with any specified parameters. To exit the subroutine specifyGOTO :eofthis will transfer control to the end of the current subroutine.