Quantcast
Channel: The VBScript Network and Systems Administrator's Cafe » DataCenter
Viewing all articles
Browse latest Browse all 10

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

$
0
0

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


Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>