- 如果在C:\下执行下面的批处理代码,则返回 Current drive is C:
@ECHO OFF :: CURDRIVE.BAT :: Written by Rob van der Woude :: Places the current drive letter in environment variable CURRDRIVE :: SET CURDRIVE= CD | CHOICE /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ > NUL IF ERRORLEVEL 1 SET CURDRIVE=A IF ERRORLEVEL 2 SET CURDRIVE=B IF ERRORLEVEL 3 SET CURDRIVE=C IF ERRORLEVEL 4 SET CURDRIVE=D IF ERRORLEVEL 5 SET CURDRIVE=E IF ERRORLEVEL 6 SET CURDRIVE=F IF ERRORLEVEL 7 SET CURDRIVE=G IF ERRORLEVEL 8 SET CURDRIVE=H IF ERRORLEVEL 9 SET CURDRIVE=I IF ERRORLEVEL 10 SET CURDRIVE=J IF ERRORLEVEL 11 SET CURDRIVE=K IF ERRORLEVEL 12 SET CURDRIVE=L IF ERRORLEVEL 13 SET CURDRIVE=M IF ERRORLEVEL 14 SET CURDRIVE=N IF ERRORLEVEL 15 SET CURDRIVE=O IF ERRORLEVEL 16 SET CURDRIVE=P IF ERRORLEVEL 17 SET CURDRIVE=Q IF ERRORLEVEL 18 SET CURDRIVE=R IF ERRORLEVEL 19 SET CURDRIVE=S IF ERRORLEVEL 20 SET CURDRIVE=T IF ERRORLEVEL 21 SET CURDRIVE=U IF ERRORLEVEL 22 SET CURDRIVE=V IF ERRORLEVEL 23 SET CURDRIVE=W IF ERRORLEVEL 24 SET CURDRIVE=X IF ERRORLEVEL 25 SET CURDRIVE=Y IF ERRORLEVEL 26 SET CURDRIVE=Z IF "%CURDRIVE%"=="" ECHO Error checking current drive IF NOT "%CURDRIVE%"=="" ECHO Current drive is %CURDRIVE%: