子菜单中的批处理子菜单,命令goto主菜单执行子菜单

时间:2016-11-01 21:40:21

标签: windows batch-file cmd menu

我正在使用我每天使用的命令构建最终批处理文件,让我们解决问题。到目前为止,我尝试改变并拥有多个变量,试图尽可能多地将它分开"在几乎所有事情上,但它仍然是相同的。

所以第一个菜单工作正常,第二个菜单工作正常,但第二个菜单/子菜单(子菜单1)中的子菜单(子菜单11)当我输入0作为变量返回主菜单时,子菜单11中的每个命令都被执行。我试着尽力解释。

代码低于你,请尝试给我一些新的观点。 谢谢。

P.S。重新启动被注释掉了

@ECHO off

:start
CLS
ECHO
ECHO Main Menu
ECHO 1. Windows
ECHO 0. Exit
ECHO.
set /p choice=

if "%choice%"=="1" goto submenu_1
if "%choice%"=="0" goto exit

:submenu_1
ECHO
ECHO Windows
ECHO 1 - Test Mode
ECHO 0 - Main Manu
ECHO.
set /p a=

if "%a%"=="1" goto submenu11
if "%a%"=="0" goto start

:submenu11
@ECHO on
ECHO
ECHO Test Mode
ECHO 1 - Enable Test Mode
ECHO 2 - Disable Test Mode
ECHO 0 - Main Menu
ECHO.

set /p b=

if "%b%"=="1" ECHO
ECHO Enable Test Mode
ECHO.
bcdedit -set loadoptions DISABLE_INTEGRITY_CHECKS
bcdedit -set TESTSIGNING ON
ECHO
ECHO Windows will restart
ECHO.
Pause
::shutdown -r -t 10

if "%b%"=="2" ECHO
ECHO Disable Test Mode
ECHO.
bcdedit.exe -set loadoptions ENABLE_INTEGRITY_CHECKS
bcdedit.exe -set TESTSIGNING OFF
ECHO
ECHO Windows will restart
ECHO.
Pause
::shutdown -r -t 10
if "%b%"=="0" goto start
goto submenu_1

:exit

1 个答案:

答案 0 :(得分:0)

试试这样:

@echo off&cls
:start
cls
ECHO Main Menu
ECHO 1. Windows
ECHO 0. Exit
ECHO.
set /p choice=

if "%choice%"=="1" goto submenu_1
if "%choice%"=="0" exit
goto:error

:submenu_1
cls
ECHO Windows
ECHO 1 - Test Mode
ECHO 0 - Main Manu
ECHO.
set /p a=

if "%a%"=="1" goto submenu11
if "%a%"=="0" goto start
goto:error

:submenu11
cls
ECHO Test Mode
ECHO 1 - Enable Test Mode
ECHO 2 - Disable Test Mode
ECHO 0 - Main Menu
ECHO.

set /p b=

if "%b%"=="1" (
ECHO Enable Test Mode
ECHO.
bcdedit -set loadoptions DISABLE_INTEGRITY_CHECKS
bcdedit -set TESTSIGNING ON
ECHO
ECHO Windows will restart
ECHO.
Pause
rem shutdown -r -t 10
)

if "%b%"=="2" (
ECHO Disable Test Mode
ECHO.
bcdedit.exe -set loadoptions ENABLE_INTEGRITY_CHECKS
bcdedit.exe -set TESTSIGNING OFF
ECHO
ECHO Windows will restart
ECHO.
Pause
rem shutdown -r -t 10
)

if "%b%"=="0" goto start

:error
echo Invalid Answer