1
我想創建一個批處理文件,其中基於條件,它將轉到批處理文件中的一個部分。目前它只有部分工作。如果我選擇'Y'安裝'Holmes','N'選擇'ReportServer','N'選擇'Apache',那麼它會提示我輸入「SQLServerName」。但是,如果我選擇'N'來安裝Holmes,'Y'來安裝'ReportServer',那麼它應該問我同樣的問題到「輸入SQLServername」,但是現在就結束了。任何人都知道如何才能正確地工作?批處理文件條件
setlocal ENABLEDELAYEDEXPANSION
set SETTINGS_FILE=c:\temp\settings.txt
if "%InstallHolmes%"=="" (
choice /C yn /N /M "Do you want to install Holmes? : "
if %ERRORLEVEL% ==1 (
set InstallHolmes=Y
) else (
set InstallHolmes=N
)
echo InstallHolmes=!InstallHolmes! >> %SETTINGS_FILE%
)
if "%InstallReportServer%"=="" (
choice /C yn /N /M "Do you want to install Report Server? : "
if %ERRORLEVEL% ==1 (
set InstallReportServer=Y
) else (
set InstallReportServer=N)
)
echo InstallReportServer=!InstallReportServer! >> %SETTINGS_FILE%
)
if "%InstallApache%"=="" (
choice /C yn /N /M "Do you want to install Apache? : "
if %ERRORLEVEL% ==1 (
set InstallApache=Y
) else (
set InstallApache=N
)
echo InstallApache=!InstallApache! >> %SETTINGS_FILE%
)
set "TRUE="
if "%InstallHolmes%"=="Y" set TRUE=1
if "%InstallReportServer%"=="Y" set TRUE=1
if "%TRUE%" == "1" set InstallEitherAppOrReports=Y
if "%TRUE%" == "1" goto sqlinfo
set "TRUE="
if "%InstallHolmes%"=="N" set TRUE=2
if "%InstallReportServer%"=="N" set TRUE=2
if "%TRUE%" == "2" goto end
:sqlinfo
if "%SQLServer%"=="" (
set /p SQLServer="Enter SQLServer name : "
echo SQLServer=!SQLServer!>> %SETTINGS_FILE%
)
)