VBscript to fetch the number of physical processors (Windows)

Can any one help me to get a VBscript to fetch the number of physical processors installed on a windows machine..
Viswa8888Asked:
Who is Participating?
 
SysExpertCommented:
0
 
SysExpertCommented:
would look at the set command since it is probably already stored in the environmental variables.

Type set form a command prompt and filter the results using find or similar from DOS

I hope this helps !
0
 
RobSampsonCommented:
Hi, I'm not in a position to test this at the moment, but try this on a machine that has two processsors, as well as two or more cores in one processor, because the results may be different, and you might have to look carefully to distinguish the physical processors.
I have a feeling the ProcessorID might be the one that tells you the difference.
'===================
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _
                                       wbemFlagReturnImmediately + wbemFlagForwardOnly)

WScript.Echo "NumberOfProcessors: " & objItem.NumberOfProcessors


Set colItems = Nothing
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
                                       wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
   WScript.Echo "Caption: " & objItem.Caption
   WScript.Echo "DeviceID: " & objItem.DeviceID
   WScript.Echo "Name: " & objItem.Name
   WScript.Echo "ProcessorId: " & objItem.ProcessorId
   WScript.Echo "UniqueId: " & objItem.UniqueId
Next

Set colItems = Nothing
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProcessor", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
   WScript.Echo "GroupComponent: " & objItem.GroupComponent
   WScript.Echo "PartComponent: " & objItem.PartComponent
Next
'===================

Regards,

Rob.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.