How do I get a list of drive letters and their associated labels on a windows system through a bat file?
|
up vote
1
down vote
favorite
|
|||
|
|
|
up vote
6
down vote
accepted
|
This will get most of it:
If you have any drives mapped via subst you would also need to get those:
For completeness, you would do it like this in Powershell (if you are on windows 7 or have installed it):
You can also do it from the command prompt or a batch file using WMI like this:
|
||||||||||||
|
|
up vote
0
down vote
|
Somewhat kludgy, but works from a batch file:
|
||
|
|
|
up vote
0
down vote
|
If anyone is lucky enough to be using Vista (Vista Ultimate SP2 b6002, in my case) and the gwmi and wmic snippets given here don't work exactly, here is what I did to make it work. For gwmi, if you receive no output, try changing the DriveType to 3. If still having problems, remove the -filter option altogether and analyze output.
For wmic, if you receive "Invalid GET Expression", then try putting the get expression in quotes:
|
||
|
|
|
up vote
-2
down vote
|
|
||||||||
|