|
【方法一】fsutil
@echo off
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable.* 可移动"') do (
set DriveU=%%h
)
)
echo.%DriveU%
pause
【方法二】WMIC
@echo off
for /f "tokens=2 delims==" %%a in ('wmic LogicalDisk where "DriveType='2'" get DeviceID /value') do (
set DriveU=%%a
)
echo.%DriveU%
pause
【方法三】BAT + VBS (优点是可以兼容Win2000系统)
@echo off
<%~fs0 more +10>%temp%\GetU.vbs
for /f %%a in ('cscript /nologo "%temp%\GetU.vbs"') do (
set "DriveU=%%a"
)
echo.%DriveU%
pause
goto :eof
''''''''''''''''''''''''''''''''''''''''''''''''''''
Set Fso = CreateObject("Scripting.FileSystemObject")
Set B = Fso.Drives
For Each A in B
If A.DriveType = 1 Then
aDisk = aDisk & A.DriveLetter & ": "
End If
Next
aDisk = Replace(aDisk, "A: ","")
WScript.Echo aDisk
----------------------------------------------------------------by h4rra----------------------------------------------------------------------
不要等到失去才知道曾经拥有
机会来临,但已经错过 |
|