Writing a BGINFO like Script: Displaying Processor information with WMI via the Win32_Processor class
I recently had to provide the information displayed with BGINFO on a number of systems. Unfortunately, BGInfo only generates a bitmap, so far as I know, so I decided to write a script to generate the information and use this displayed information to send back to the person who requested it.
The function below is a part of the script I mentioned. It retrieves and returns text that represents the Processor information in the system and teh number of processors in the system. (Note: At this time I don’t have a dual core system to test it with, I believe that it will diplay the number of cores in the system. So, 4 dual core processors will be displayed as 8 processors/cores.)
You can view all the scripts in this BGINFO series here.
Here is the code:
Dim colItems, objItem, address
Dim CoresCores = 0
StrQuery = “SELECT * FROM Win32_Processor”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\CIMV2”)
Set colItems = objWMIService.ExecQuery(strQuery,,48)
For Each objItem in colItems
If Replace(objItem.name,”GHz”,””) = objItem.name then
GetCPUs =(round(objItem.CurrentClockSpeed/1024,1)) & “GHz” & ” ” & objItem.name & VbCrLf
GetCPUs = objItem.name & VbCrLf
Cores = Cores + 1
GetCPUs = vbTab & Cores & ” Processors/Cores that are: ” & GetCPUs