2 qq 25410713 qq_25410713 于 2016.04.02 12:19 提问

bat 运行错误 'if'不是内部或外部命令

@echo off
setlocal enabledelayedexpansion
echo.
set Drive=0
For /F "Skip=1" %%i in ('Wmic Logicaldisk Where "DriveType=3" Get Name') Do (
set /a Drive=!Drive!+1
set Drive[!Drive!]=%%i
)
set /a Drive=!Drive!-1
set var=1
:DriveChoose
echo.
set /p output=请选择安装磁盘(<nul
for /l %%i in (1,1,!Drive!) do (
call set /p output=%%Drive[%%i]::=%%/<nul)
echo )
set /p enter=请输入安装磁盘:
for /l %%i in (1,1,!Drive!) do (
call set "output=if [%%%%enter%%%%]==%%Drive[%%i]::=%% do (set var=0)"
!output!
)
if %var%==1 (goto :DriveChoose)
echo ............
pause

1个回答

qq_25410713
qq_25410713   2016.04.02 17:52

set Drive=0
For /F "Skip=1" %%i in ('Wmic Logicaldisk Where "DriveType=3" Get Name') Do (
set /a Drive+=1
set Drive[!Drive!]=%%i
)
set /a Drive=!Drive!-1
set var=1
:DriveChoose
cls
echo.
set /p output=请选择安装磁盘(<nul
for /l %%i in (1,1,!Drive!) do (
call set /p output=%%Drive[%%i]::=%%/<nul)
echo )
set /p enter=请输入安装磁盘:
for /l %%i in (1,1,!Drive!) do (
set Drive[%%i]=!Drive[%%i]:~0,1!
if /i [!enter!]==!Drive[%%i]!
if /i [!enter!]==!Drive[%%i]!:
if /i [!enter!]==!Drive[%%i]!:/
)
if %var%==1 (goto :DriveChoose)

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!