【发布时间】:2014-06-19 23:24:04
【问题描述】:
我有以下代码:
@echo off
set scriptTitle=Mode Changer
title %scriptTitle%
rem Take Details
set /p machine=Enter machine name:%=%
echo. %machine%
set /p rMSNewMode=Mode (t/l):%=%
echo. %rMSNewMode%
rem Perform Task
cls
rem Check machine existence
ping %machine% -n 1
if %errorLevel% == 1 call:error "The specified machine (%machine%) could not be located."
:error
color 4f
title ERROR: %scriptTitle%
cls
echo. The following error has occurred:
echo.
echo. %~1
echo.
pause
goto EOF
批处理文件完成后,我按预期得到“按任意键继续”。但是,它需要在批处理文件结束之前按两次“任意键”。如果我替换以下行,就会出现:
if %errorLevel% == 1 call:error "The specified machine (%machine%) could not be located."
与
if %errorLevel% == 1 goto error
我只收到一次提示。
有什么问题?
【问题讨论】:
标签: windows batch-file scripting