Search code examples
windowsbatch-filewmic

windows batch wmic diskdrive get size where media type = Fixed hard disk media


I need to get the size of locally installed hard disk/disks size via windows batch file, please help

for /f ? %%f in ('wmic diskdrive where (MediaType='Fixed hard disk media') get size /value') do echo "%%f"

Solution

  • You may want something like this:

    @Echo Off
    For /F "Skip=1 Delims=" %%A In (
        '"WMIC LogicalDisk Where (DriveType='3') Get DeviceID, Size"'
    ) Do For /F "Tokens=1-2" %%B In ("%%A") Do Echo(%%B - %%C
    Timeout -1