Writing a BGINFO like Script: Displaying Memory information via WMI using the Win32_PhysicalMemory 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 total amount of physical memory in a system.
You can view all the scripts in this BGINFO series here.
Here is the code:
Dim colItems, objItem, address
Dim objWMIService, RAM
GetPhysicalMemory = VbCrLf
RAM = 0
StrQuery = “SELECT * FROM Win32_PhysicalMemory”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)
For Each objItem in colItems
RAM = RAM + objItem.capacity
GetPhysicalMemory = GetPhysicalMemory & vbTab & (((RAM/1024)/1024)/1024) & ” Gb” & VbCrLf