The VBScript Network and Systems Administrator's Cafe

Mar 30 2009   4:13PM GMT

Writing a BGINFO like Script: Displaying Processor information with WMI via the Win32_Processor class



Posted by: Jerry Lees
Tags:
bginfo
Systems Administration
Systems administrator tools
systems management
systems reporting
VBScript
VBScript Functions

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:

Function GetCPUs(strComputer)
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService
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
Else
GetCPUs = objItem.name & VbCrLf
end if
Cores = Cores + 1
Next
GetCPUs =  vbTab & Cores & ” Processors/Cores that are: ” & GetCPUs
End Function

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: