我在CMD下面运行命令,我想将以下命令的输出分配给变量并在CMD中打印
wmic cpu get name,numberofcores,numberoflogicalprocessors
答案 0 :(得分:0)
我建议您将输出重定向到文本文件,然后处理它以存储到变量中:
<强> myscript.bat:强>
Setlocal EnableDelayedExpansion
wmic cpu get name,numberofcores,numberoflogicalprocessors > out.txt
set txt=
for /f "tokens=*" %%i in (out.txt) do set txt=!txt!%%i
echo !txt!
Endlocal