Find Number of CPUs and Cores per CPU using Command Prompt
Solution 1
Based upon your comments - your path
statement has been changed/is incorrect or the path
variable is being incorrectly used for another purpose.
Solution 2
You can use the environment variable NUMBER_OF_PROCESSORS
for the total number of processors:
echo %NUMBER_OF_PROCESSORS%
Solution 3
You can also enter msinfo32
into the command line.
It will bring up all your system information. Then, in the find box, just enter processor
and it will show you your cores and logical processors for each CPU. I found this way to be easiest.
Solution 4
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
:
@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.
Related videos on Youtube
Mustafa
Updated on July 09, 2022Comments
-
Mustafa almost 2 years
I am trying to retrieve the Number of CPUs and Cores per CPU using Command Prompt. I have executed the following command:
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
I am executing this on a Windows Server 2008 R2 machine. I believe the 'wmic' command is compatible on this windows.
The directory I am running the command promt from is 'C:\Windows>
Any advice please?
-
Michael Burr about 10 yearsIs
C:\Windows\System32\Wbem
on your path, and is there actually a fileC:\Windows\System32\wbem\WMIC.exe
? -
Stephan about 10 yearsif you need the count of physical CPUs, use
wmic computersystem get numberofprocessors
-
Mustafa@MichaelBurr I just have literally 'C:\Windows>wmic cpu get NumberOfCores, NumberOfLogicalProcessors/Format:List There is a filepath that leads to C:\Windows\System32\wbem\WMIC.exe
-
-
rubynorails over 8 yearsDoes this environment variable exist on all versions of Windows??? That is incredibly useful. Are you aware of it's OS version compatibility?
-
R1tschY over 8 yearsI only found that it was introduced in Windows 2000/NT. I guess it exists in every Windows desktop and server version after Windows 2000.
-
Magier about 8 yearsThis delivers the total Number of Cores but not the number of CPUs.
-
northben almost 8 yearsI confirmed that this shows the total number of cores across all sockets
-
RBT about 7 yearsthis command returns
CPU 1
. What do you mean by absence of physical sockets? A CPU can't be present on a motherboard without a socket isn't it? I believe this command simply tells you the number of CPU sockets on your machine. -
BatteryBackupUnit over 6 yearsWhen executing on the command line I had to replace the double
%%
with single%
. Like:for /f "tokens=*" %f in ('wmic cpu get NumberOfCores /value ^| find "="') do set %f
-
Chucky almost 5 yearsNot really getting the information on the command line, though ;-)
-
Halil İbrahim Oymacı about 4 yearsThis is not total number of cores in my hp Windows 10 Pro desktop pc. It is number of Logical processors. My pc has 6 cores and 12 processors so it gives 12. Is anyone knows how can I get that number 6 (number of cores)?
-
Chaminda Bandara almost 4 yearsThis is not working windows or linux... I have received empty in windows and linux both. Why it is ?