这里它是愚蠢的问题,但请帮助或我的大脑会爆炸! ;))一些愚蠢的东西,我不明白...Windows批处理文件 - GOTO命令被忽略
总之:为什么选择7号(退出)后返回的ERRORLEVEL是正确的,但GOTO指定的标签被忽略,而是它去allTasksReboot标签。 ..
这是我的 “代码” ...
@echo off
mode con: cols=150 lines=65
@echo ------------------------------------------------------------------------------------------------
@echo INSTALLATION MENU
@echo ------------------------------------------------------------------------------------------------
@echo [ 1 ].All tasks - Unattended with reboot on finish
@echo [ 2 ].All tasks - Unattended without reboot on finish
@echo [ 3 ].All tasks except Software group - Unattended with reboot on finish
@echo [ 4 ].All tasks except Software group - Unattended without reboot on finish
@echo [ 5 ].All tasks except Java 7 installation - Unattended without reboot on finish
@echo [ 6 ].Install only VNC - Unattended
@echo [ 7 ].Exit
@echo ------------------------------------------------------------------------------------------------
@echo ------------------------------------------------------------------------------------------------
CHOICE /C:1234567 /N /M "Choose number for installation type."
@echo You press: %ERRORLEVEL%
@pause
IF ERRORLEVEL 1 GOTO allTasksReboot
IF ERRORLEVEL 2 GOTO allTasks
IF ERRORLEVEL 3 GOTO allExceptSoftwareReboot
IF ERRORLEVEL 4 GOTO allExceptSoftware
IF ERRORLEVEL 5 GOTO allTasksExceptJava
IF ERRORLEVEL 6 GOTO onlyVnc
IF ERRORLEVEL 7 GOTO scriptend
:allTasksReboot
@echo **************************************************************************
@echo All tasks - Unattended with reboot on finish
@echo **************************************************************************
@pause
goto scriptend
:scriptend
@echo Lets exit...
@pause
:goexit
我选择你的答案的,因为你的解释,为什么这个“错误”的发生。还要感谢你使用label-%errorlevel%:)的代码技巧示例 – binball