2

I have a .bat file in which there's the following command and can list available drives on my computer :

for /f "skip=1 delims=" %%x in ('wmic logicaldisk get caption') do @echo.%%x

And give the the following result :

C:
D:
E:
J:
R:

This link could help me to get all available drives : See available drives from Windows CLI?

Now I want to list just available hard drives (letters) not dvd-rom or any other else...

This is my available drives on computer that get them with diskpart and then list volume commands :

 Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
 ----------  ---  -----------  -----  ----------  -------  ---------  --------
 Volume 0     D                       DVD-ROM         0 B  No Media
 Volume 1     C                NTFS   Partition     39 GB  Healthy    System
 Volume 2     J   New Volume   NTFS   Partition    100 MB  Healthy
 Volume 3     E   New Volume   NTFS   Partition     50 MB  Healthy
 Volume 4     R   New Volume   NTFS   Partition    130 MB  Healthy

The main questions :

  • How can I achieve this (to get just hard drives excluding dvd or any other none-storage drives)??
  • Also Is it feasible to get all hard drives except system drive (I mean windows drive) ??
  • In a nutshell, I want drive letters of this list :

     Volume 2     J   New Volume   NTFS   Partition    100 MB  Healthy
     Volume 3     E   New Volume   NTFS   Partition     50 MB  Healthy
     Volume 4     R   New Volume   NTFS   Partition    130 MB  Healthy
    

Notice : I just want to list drive letters not any more.

1 Answers1

3
wmic logicaldisk where drivetype=3 get caption

Drive Type of 3 = Local Disk

0   Unknown
1   No root directory
2   Removable disk
3   Local disk
4   Network drive
5   Compact disk
6   RAM disk

enter image description here