See available drives from Windows CLI?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Droplet of life
--
Chapters
00:00 See Available Drives From Windows Cli?
00:17 Accepted Answer Score 170
00:41 Answer 2 Score 92
01:11 Answer 3 Score 37
01:41 Answer 4 Score 14
01:56 Answer 5 Score 12
02:22 Thank you
--
Full question
https://superuser.com/questions/139899/s...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows #commandline
#avk47
ACCEPTED ANSWER
Score 170
> 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
ANSWER 2
Score 92
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.
ANSWER 3
Score 37
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)
ANSWER 4
Score 14
If you're using powershell then you can type in
get-psdrive -psprovider filesystem
Edited in response to comments to only show filesystems
ANSWER 5
Score 12
wmic logicaldisk get volumename,name
You can get (query) multiple properties this way. This will give you the partition/drive letter and the label you gave the drive/partition when you formatted the drive:
Name VolumeName
C: OS
D: Data
E: Programs
For help and to list all the permission options:
wmic logicaldisk /?
then
wmic logicaldisk get /?