@ECHO OFF SETLOCAL ENABLEEXTENSIONS REM mode 85,25 ECHO.&ECHO Searching for Harddisk volumes using WMIC.&ECHO. IF /I NOT EXIST "%SystemRoot%\system32\wbem\wmic.exe" ECHO WMIC.EXE not found ...exit here&PAUSE>NUL&GOTO:_END IF /I NOT EXIST "%SystemRoot%\system32\findstr.exe" ECHO FINDSTR.EXE not found ...exit here&PAUSE>NUL&GOTO:_END ECHO Please wait...&ECHO. ::_____________________________________________________________________________ :: :: Get OS. If XP - tag it. fsutil resource is not available under XP :: (needed to get \DEvice\HD-VolumeNr). ::_____________________________________________________________________________ SET "OsXP=" FOR /F "skip=1 tokens=2 delims==" %%a IN ('"WMIC OS GET CAPTION /VALUE"') DO ( ECHO OS: %%a&ECHO.&ECHO. ECHO %%a 2>NUL|FIND /I "XP" >NUL 2>&1 && SET "OsXP=1") ::_____________________________________________________________________________ :: :: get UUIDs ::_____________________________________________________________________________ SET /A COUNT=-1 FOR /F "" %%a IN ('MOUNTVOL^|FINDSTR "\<\\Volume"') DO (CALL:_Utils "%%a") :_END ECHO. ECHO End Of File PAUSE>NUL ENDLOCAL Exit ::_____________________________________________________________________________ :_Utils :: count calls SET /A COUNT=COUNT+1 ::_____________________________________________________________________________ :: :: get the UUID's corresponding drive letter (if available) ::_____________________________________________________________________________ IF %COUNT%==0 ( FOR /F %%z IN ('MOUNTVOL^|FINDSTR "[*] [A-Za-z]:\\\\"') DO ( SET "Drv=%%z" GOTO:_ExDrvLetter ) ) ELSE ( FOR /F "skip=%COUNT%" %%y IN ('MOUNTVOL^|FINDSTR "[*] [A-Za-z]:\\\\"') DO ( SET "Drv=%%y" GOTO:_ExDrvLetter ) ) :_ExDrvLetter ::_____________________________________________________________________________ :: :: pass UUID to fsutil to get the drive type string value ::_____________________________________________________________________________ SET "DrvType=" FOR /F "tokens=*" %%x IN ('fsutil fsinfo drivetype %~1') DO (SET "DrvType=%%x") ::_____________________________________________________________________________ :: :: pass UUID to fsutil to get the volume label (if available) ::_____________________________________________________________________________ SET "Lbl=" FOR /F "tokens=2 delims=:" %%w IN ('fsutil fsinfo volumeinfo %~1') DO ( ECHO %%w 2>NUL|FINDSTR ".*" >NUL 2>&1 && SET "Lbl=%%w" & GOTO:_ExLbl) :_ExLbl ::_____________________________________________________________________________ :: :: if OS is not xp "fsutil resource info" is available :: - pass UUID to it - command holds the \Device\HarddiskVolume string ::_____________________________________________________________________________ IF DEFINED OsXP GOTO:_ExDevID SET "DevID=" FOR /F "tokens=2-3 delims=\" %%v IN ('fsutil resource info %~1') DO ( ECHO \%%v\%%w 2>NUL|FIND "\Device\" >NUL 2>&1 && SET "DevID=\%%v\%%w") :_ExDevID ::_____________________________________________________________________________ :: :: Prepare Outputs ::_____________________________________________________________________________ :: %Drv%: if not a drive letter replace value with "NA" ECHO %DRV% 2>NUL |FINDSTR "[A-Za-z]:\\\\" >NUL 2>&1 || SET "Drv=N/A" :: %DrvType%: snip everything before first "hyphen-space" (including the hyphen) IF DEFINED DrvType SET "DrvType=%DRVTYPE:*- =%" :: %Lbl%: delete everything before the first two spaces SET Lbl=%Lbl:* =% :: %Lbl%: delete everything before the first space SET Lbl=%Lbl:* =% :: %Lbl%: if not defined replace value with "NA" IF NOT DEFINED Lbl SET "Lbl=N/A" :: %DrvID% if not defined replace value with "NA" IF NOT DEFINED DevID SET "DevID=N/A" :: Output Echo Drv: %DRV% ECHO Lbl: %LBL% ECHO Type: %DRVTYPE% ECHO UUID: %~1 ECHO DevID: %DEVID% ECHO. GOTO:EOF