下面提到的批处理文件显示PC的硬盘大小,但如果PC中安装了多于1个硬盘,那么如何设置变量?怎么做?
set _hdd=
For /F "Skip=1 Delims=" %%A In (
'"WMIC diskdrive Where (MediaType="Fixed hard disk media") Get Size"'
) Do For /F "Tokens=1-2" %%B In ("%%A") Do set _hdd=%%B
Echo %_hh%
pause
答案 0 :(得分:0)
> Q:\Test\2017-03\01\SO_42530497.cmd
_hdd[1]=2000396321280
_hdd[2]=256052966400
示例输出:
{
"sdk": {
"version": "1.0.0-preview2-1-003177"
}}
答案 1 :(得分:0)
与我的上一个答案和已经提供的答案类似:
@Echo Off
For /F "Skip=1 Delims=" %%A In (
'"WMIC DiskDrive Where (MediaType Like 'Fixed%%') Get Index, Size"'
) Do For /F "Tokens=1-2" %%B In ("%%A") Do Set "HD%%B=%%C"
Set HD
Timeout -1