windows 使用命令提示符查找每个 CPU 的 CPU 和内核数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22919076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 11:30:01  来源:igfitidea点击:

Find Number of CPUs and Cores per CPU using Command Prompt

windowscmdsoftware-design

提问by Mustafa

I am trying to retrieve the Number of CPUs and Cores per CPU using Command Prompt. I have executed the following command:

我正在尝试使用命令提示符检索每个 CPU 的 CPU 和内核数。我已经执行了以下命令:

wmic cpu get NumberOfCores, NumberOfLogicalProcessors/Format:List

wmic cpu get NumberOfCores, NumberOfLogicalProcessors/Format:List

I get this error: wmic' is not recognized as an internal or external command, operable program or batch file

我收到此错误: wmic' is not recognized as an internal or external command, operable program or batch file

I am executing this on a Windows Server 2008 R2 machine. I believe the 'wmic' command is compatible on this windows.

我正在 Windows Server 2008 R2 机器上执行此操作。我相信 'wmic' 命令在这个窗口上是兼容的。

The directory I am running the command promt from is 'C:\Windows>

我正在运行命令提示符的目录是“C:\Windows>

Any advice please?

请问有什么建议吗?

采纳答案by foxidrive

Based upon your comments - your pathstatement has been changed/is incorrect or the pathvariable is being incorrectly used for another purpose.

根据您的评论 - 您的path陈述已更改/不正确或path变量被错误地用于其他目的。

回答by R1tschY

You can use the environment variable NUMBER_OF_PROCESSORSfor the total number of cores:

您可以将环境变量NUMBER_OF_PROCESSORS用于内核总数:

echo %NUMBER_OF_PROCESSORS%

回答by DomainsFeatured

You can also enter msinfo32into the command line.

也可以进入msinfo32命令行。

It will bring up all your system information. Then, in the find box, just enter processorand it will show you your cores and logical processors for each CPU. I found this way to be easiest.

它将显示您的所有系统信息。然后,在查找框中,只需输入processor,它就会显示每个 CPU 的内核和逻辑处理器。我发现这种方法最简单。

回答by kiewic

If you want to find how many processors (or CPUs) a machine has the same way %NUMBER_OF_PROCESSORS%shows you the number of cores, save the following script in a batch file, for example, GetNumberOfCores.cmd:

如果你想找到一台机器有多少个处理器(或 CPU),以同样的方式%NUMBER_OF_PROCESSORS%显示内核数,请将以下脚本保存在批处理文件中,例如GetNumberOfCores.cmd

@echo off
for /f "tokens=*" %%f in ('wmic cpu get NumberOfCores /value ^| find "="') do set %%f

And then execute like this:

然后像这样执行:

GetNumberOfCores.cmd

echo %NumberOfCores%

The script will set a environment variable named %NumberOfCores%and it will contain the number of processors.

该脚本将设置一个名为的环境变量%NumberOfCores%,它将包含处理器的数量。

回答by Harendra Dhiman

In order to check the absence of physical sockets run:

为了检查是否没有物理套接字,请运行:

wmic cpu get SocketDesignation