Using wmic to get drives space information

后端 未结 3 1569
忘了有多久
忘了有多久 2020-12-22 08:10

I\'m trying to get info of the physical drives in a computer with wmic to get something like this:

Drive C:
500 GB Total
100 GB Free
20% Free

Drive D:
500 G         


        
3条回答
  •  萌比男神i
    2020-12-22 08:46

    As the errormessage tells you, set is limited to 32-bit-integers. If you can live with an accuracy of MB, you can shorten the numbers like this:

    set SizeMB=%size:~0,-6%
    

    (it takes the string except the last 6 characters)

    It may be not quite correct in a mathematic sense, but should be good enough.

    Of course you will have to shorten %freeMB% the same way.

提交回复
热议问题