The VBScript Network and Systems Administrator's Cafe

Apr 7 2009   4:23PM GMT

Writing a BGINFO like Script: Displaying Operating System Information with WMI via the Win32_OperatingSystem class

Jerry Lees Jerry Lees Profile: Jerry Lees

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:

Function GetOSVersion(strComputer)
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService
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
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.

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:

Share this item with your network: