Windows 通过CMD命令在批处理文件变量中设置值

Windows 通过CMD命令在批处理文件变量中设置值,windows,batch-file,cmd,Windows,Batch File,Cmd,我想从CMD获取该命令的值wmic cpu get numberofcores(我只需要这个数字),并将其设置为批处理文件变量totalcore。有人能帮我吗?我尝试了一些代码并在谷歌上搜索了一下,但没有找到这个问题的答案。好吧,有一个问题,这是9天前回答的 @echo off setlocal ENABLEEXTENSIONS set totalcore=Unknown for /F %%A in ('wmic cpu get numberofcores') do @if %%A GTR 0

我想从CMD获取该命令的值
wmic cpu get numberofcores
(我只需要这个数字),并将其设置为批处理文件变量
totalcore
。有人能帮我吗?我尝试了一些代码并在谷歌上搜索了一下,但没有找到这个问题的答案。

好吧,有一个问题,这是9天前回答的

@echo off
setlocal ENABLEEXTENSIONS
set totalcore=Unknown
for /F %%A in ('wmic cpu get numberofcores') do @if %%A GTR 0 set totalcore=%%A

echo NumberOfCores=%totalcore%
@Echo off
for /f %%A in ('wmic cpu get numberofcores^|findstr "^[0-9]"') do set /A totalcore=%%A
好吧,这是9天前回答的

@Echo off
for /f %%A in ('wmic cpu get numberofcores^|findstr "^[0-9]"') do set /A totalcore=%%A
我告诉你,这是一场瘟疫。我告诉你,这是一场瘟疫。