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.

3
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

4
  • Thanks, this could help me but how can I except windows drive (I mean c drive) also? – BattleTested_закалённый в бою May 17 '19 at 15:15
  • Maybe drivetype=1? I am on a laptop with an SSD and no partitions, so I can't test multiple scenarios i'm afraid. – spikey_richie May 17 '19 at 15:16
  • How to add drivetype=3 and drivetype != 1 in wmic? – BattleTested_закалённый в бою May 17 '19 at 15:24
  • I meant where drivetype=1 instead of 3, but I tested it on a VM with 4 drives and it returned 0. I guess you'll need to find some other was to trim/remove C: from the output. – spikey_richie May 17 '19 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.