Writing a BGINFO like Script: Displaying Operating System Information with WMI via the Win32_OperatingSystem class
Posted by: Jerry Lees
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 operating system and service pack information installed on a system.
You can view all the scripts in this BGINFO series here.
Here is the code:
Dim colItems, objItem, address
GetOSVersion = VbCrLfStrQuery = “SELECT * FROM Win32_OperatingSystem”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)
For Each objItem in colItems
GetOSVersion = GetOSVersion & vbTab & replace(objItem.caption,”(R)”,”") & VbCrLf
GetOSVersion = GetOSVersion & vbTab & “Service Pack ” & objitem.ServicePackMajorVersion & VbCrLf