Windows – How to get a list of drive letters on a system through a windows shell (bat, cmd)

batch-filewindowswindows-command-prompt

How do I get a list of drive letters and their associated labels on a windows system through a bat file?

Best Answer

This will get most of it:

Net Use

If you have any drives mapped via subst you would also need to get those:

Subst

For completeness, you would do it like this in Powershell (if you are on windows 7 or have installed it):

gwmi win32_LogicalDisk -filter DriveType=4

You can also do it from the command prompt or a batch file using WMI like this:

wmic logicaldisk get caption,providername,drivetype,volumename