我需要通过Windows批处理文件获取本地安装的硬盘/磁盘大小,请帮助
findUser
答案 0 :(得分:0)
你可能想要这样的东西:
@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
答案 1 :(得分:0)
由于LogicalDisk只返回分区大小,而现代驱动器的容量将超过cmd.exe的set / A命令的32位有符号整数数学,我建议使用PowerShell脚本获取一些数据:
$Drives=0 ; $TotalSize=0
get-physicaldisk |
ForEach {$_;$Drives+=1;$TotalSize+=$_.Size}|
Format-Table -auto DeviceID,Size,BusType,MediaType,model,serialnumber
"Drives TotalSize"
"------- --------------"
"{0,-6} {1,15}" -f $Drives,$TotalSize
示例输出:
> .\SO_42525626.ps1
DeviceID Size BusType MediaType model serialnumber
-------- ---- ------- --------- ----- ------------
1 256060514304 SATA SSD Samsung SSD 840 PRO Series xxxxxxxxxxxxxxx
0 2000398934016 SATA HDD ST2000DL003-9VT166 yyyyyyyy
3 1000204886016 USB Unspecified 2105 zzzzzzzzzzzzzzzzzzzz
Drives TotalSize
------- --------------
3 3256664334336