Published in: DOS Batch
|
|
|
URL: http://serverfault.com/questions/62578/
Someone on Serverfault was asking for a Batch script to get a list of drive letters and their associated labels on a windows system. This is my suggested answer.
Expand |
Embed | Plain Text
@ECHO OFF :A VOL A: :B VOL B: :C VOL C: :D VOL D: :E VOL E: :F VOL F: :G VOL G: :H VOL H: :I VOL I: :J VOL J: :K VOL K: :L VOL L: :M VOL M: :N VOL N: :O VOL O: :P VOL P: :Q VOL Q: :R VOL R: :S VOL S: :T VOL T: :U VOL U: :V VOL V: :W VOL W: :X VOL X: :Y VOL Y: :Z VOL Z: :END
Comments
Subscribe to comments
You need to login to post a comment.

This fails for Winbond devices assigned a drive letter but no media is loaded. Message Windows - No Disk Excpetion Processing messaage ....................................
Cancel TryAgain Continue Using the original idear i have created on the will display drive lettters or Vol information @echo off set INFO=%1
call :Drive A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
goto :EOF
:Drive vol %1: > nul 2>nul If ERRORLEVEL 1 goto Next
if not "X"%INFO%=="X" (vol %1:) else echo %1: :Next shift if NOT "X"%1=="X" goto :Drive
@echo off
rem Vol information is displayed if called with an argument, otherwise the drive letters are displayed
set INFO=%1
call :Drive A B C D E F G H I J K L M N O P Q R S T U V W X Y Z set INFO= goto :EOF
:Drive vol %1: > nul 2>nul If ERRORLEVEL 1 goto Next
if not "X"%INFO%=="X" (vol %1:) else echo %1: :Next shift if NOT "X"%1=="X" goto :Drive
@echo off
rem Vol information is displayed if called with an argument, otherwise the drive letters are displayed
set INFO=%1
call :Drive A B C D E F G H I J K L M N O P Q R S T U V W X Y Z set INFO= goto :EOF
:Drive vol %1: > nul 2>nul If ERRORLEVEL 1 goto Next
if not "X"%INFO%=="X" (vol %1:) else echo %1: :Next shift if NOT "X"%1=="X" goto :Drive
@echo off
rem Vol information is displayed if called with an argument, otherwise the drive letters are displayed
set INFO=%1
call :Drive A B C D E F G H I J K L M N O P Q R S T U V W X Y Z set INFO= goto :EOF
:Drive vol %1: > nul 2>nul If ERRORLEVEL 1 goto Next
if not "X"%INFO%=="X" (vol %1:) else echo %1: :Next shift if NOT "X"%1=="X" goto :Drive
This fails for Winbond devices assigned a drive letter but no media is loaded. Message Windows - No Disk Excepetion Processing messaage .................................... Cancel TryAgain Continue
To find a better version search for list drives letters or volume details