VBscript to fetch the number of physical processors (Windows)

Posted on 2007-07-24
Last Modified: 2012-06-27
Can any one help me to get a VBscript to fetch the number of physical processors installed on a windows machine..
Question by:Viswa8888
    LVL 63

    Expert Comment

    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 !
    LVL 63

    Accepted Solution

    LVL 65

    Assisted Solution

    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

    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



    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Hyper-convergence systems have taken the IT world by storm and have quickly started to change our point of view of how the data center should and could be architected. In this article, I’ll explain the benefits of employing a hyper-converged system …
    Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
    This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now