Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ghostly CPU...

Status
Not open for further replies.

JPJeffery

Technical User
May 26, 2006
600
GB
My PC has but the one CPU.

Yet this bit of code produces its output twice (implying there are two CPUs or that the single CPU is multi-threaded - which it's not):
Code:
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
'   WScript.Echo "CPU:"

    For Each objItem In colItems
        strCPU_Manufacturer = objItem.Manufacturer
        strCPU_Name = objItem.Name
'       WScript.Echo "CPU_Manufacturer: " & objItem.Manufacturer
'       WScript.Echo "CPU_Name: " & objItem.Name
'       Next

        'while instr(strCPU_Name, "  ") > 0
        '    strCPU_Name = replace(strCPU_Name, "  ", " ")
        'wend
        WScript.Echo " CPU Manufacturer: " & vbTAB & strCPU_Manufacturer
        strCPU_Name = "   " & strCPU_Name
        do while left(strCPU_Name,1) = " "
            'wscript.echo " (CPU name is " & len(strCPU_Name) & " characters long"
            strCPU_Name = right(strCPU_Name,(len(strCPU_Name)-1))
            'WScript.Echo " CPU Name: " & vbTAB & vbTAB & strCPU_Name
        loop
        WScript.Echo " CPU Name: " & vbTAB & vbTAB & strCPU_Name
        objInventoryFile.write "CPU," & strCPU_Manufacturer & "," & strCPU_Name & ",3,4,5,6,7,8,9,10" & vbCrLf
    Next

A similar block of code produced similar results at my previous place of employment which used different PCs/CPUs.

Can anyone tell me why I get double output?

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
OK, my bad, looking at Task Manager it does appear that my CPU is dual threaded.
[blush]
So my question changes, how do I get the script to ignore any extra threading and report on each physical CPU once only?

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
is there a property of the wmi class which is unique to the processor,.,.i.e, instances with the same value of the property are infact the same CPU, pnpidentity perhaps?

is there another wmi class you could associate with and get the result you are after?

sorry for possing more questions :)
 
No, at least not that I could see.

However, I spotted that the second thread has a ProcessorId of 0000000000000000 so I just get my script to ignore that instance like this:
Code:
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor" _
     & " WHERE ProcessorId<>'0000000000000000'" _
     , "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
Another option is to put the CPU in a dictionary object. The objProcessor.Description will be unique.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top