Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to list the available drives from cmd.exe ? (Other than manually typying

c:
d:
...

and seeing which ones return errors)

share|improve this question
up vote 58 down vote accepted
> wmic logicaldisk get caption

Caption
C:
D:
E:

if probably the easiest one. Doesn't need administrative privileges, doesn't return more or less than what's needed, etc.

If you want to use it in a script, then wrap it in for /f with the skip=1 option:

for /f "skip=1 delims=" %%x in ('wmic logicaldisk get caption') do @echo.%%x
share|improve this answer
1  
only for users with administrator rights – Carlos Campderrós Apr 16 '15 at 16:16
    
@CarlosCampderrós: works fine for me from a limited user account. – Joey Apr 16 '15 at 16:51
1  
Quoting from support.microsoft.com/en-us/kb/290216 "Wmic.exe can only be used by the local system administrators regardless of WMI namespace permissions on the local machine", and it failed on my machine (a VM with winXP) – Carlos Campderrós Apr 17 '15 at 8:42
2  
It worked just fine under a non-admin account on a Windows 8.1 here. Note that the KB article applies only to legacy operating systems. – Joey Apr 17 '15 at 10:33
    
@Joey, Why caption instead of wmic logicaldisk get name ? – Pacerier Apr 23 '15 at 17:33

If you're in Command Prompt:

diskpart

then

list volume

sample output:

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     E                       DVD-ROM         0 B  No Media
  Volume 1         System Rese  NTFS   Partition    100 MB  Healthy    System
  Volume 2     C   System       NTFS   Partition     99 GB  Healthy    Boot
  Volume 3     F   Data (local  NTFS   Partition    365 GB  Healthy

and finally

exit

to return to the command line.

share|improve this answer
    
in contrast to the net use command, this will only list local physical drives. (i think.) see diskpart at technet and diskpart at support.microsoft.com – quack quixote May 11 '10 at 12:33
2  
diskpart needs administrative privileges. If you just want a list of drive letters that's a bit much to ask for ... – Joey May 11 '10 at 13:30

For the sake of completeness, there is yet another way:

fsutil fsinfo drives

which returns:

Drives: C:\ D:\ E:\ F:\

(Not a very scripting-friendly output, but it may be useful for human eye)

Some reference. That should work since win2k but only with Administrator account.

(Thanks @Carlos Campderrós for enhancing the answer)

share|improve this answer
3  
It should be noted that this only work if you are using an Administrator account – Carlos Campderrós Apr 16 '15 at 16:11
    
Thanks, just tested on w7hprem. – saulius2 Apr 17 '15 at 17:08

If you're using powershell then you can type in

get-psdrive -psprovider filesystem

Edited in response to comments to only show filesystems

share|improve this answer
    
That will also return other non-filesystem drives that are mounted, such as Cert:, Alias: and Function:. Furthermore, it will return other file-system directories mounted as a PSDrive (such as Home: for %UserProfile% for me). – Joey May 11 '10 at 13:31
    
This is the only answer that worked for me. All other solutions seem to require administrator access. (At least on my horribly outdated Windows XP system.) – Ajedi32 Jul 6 '15 at 17:22

Use the doskey built in function to create an alias that runs the wmic command with the necessary atributes

doskey v=wmic logicaldisk get caption

This will create an aliases "v" that whenever typed will run the given command and list all volume letters.

share|improve this answer
    
oh nice, didn't know about doskey (like powershell's Set-Alias) – BananaAcid Jun 15 at 22:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .