Menu

A VBScript for displaying only IPv4 Addresses with BGInfo

I wanted to use BGInfo to display only the IPv4 address(es) of a workstation. BGInfo’s built-in IP address ouput returns both IPv4 and IPv6 formatted addresses, but you can use the output of a VBScript as a data source for a custom field. Starting with the nice script provided in the comments of the TechNet forum thread at: WMI Query to retrieve only active IPv4 address, I’ve made a few aesthetic changes so that the IPv4 addresses of active network adapters are displayed in a single column.

Ideally, I’d be able to report whether the IP address was attached to a wired or wireless adapter, but that is beyond the scope of this particular project.

But, in the event that someone wants to do something that sophisticated, Microsoft’s WMI Code Creator v1.0 would be a very good place to start.

The WMI Code Creator tool allows you to generate VBScript, C#, and VB .NET code that uses WMI to complete a management task such as querying for management data, executing a method from a WMI class, or receiving event notifications using WMI.
http://www.microsoft.com/en-us/download/details.aspx?id=8572

Hint: look at the Description property of the Win32_NetworkAdapterConfiguration class.

I believe that the script works fine, in the context of BGINFO, when line 25 begins with “Echo” and not “WScript.Echo”. But I also believe that if you were to simply run the script with wscript.exe, then you are better off using “WScript.Echo”

Trying to run this on Windows 7 and Server 2012 systems, I get an error that line 7 returns null (error 0x80041021). I wondered if maybe I need something more than “.” for my strComputer, but no one else has reported a problem with this. Any tips on what I may be missing?