Friday, May 30, 2014

BGinfo display only active IP address

One of the pains of using BGinfo is that it lists too many non functional IP addresses.  To solve this (partly), this post talks about using a custom entry:

http://www.renjithmenon.com/how-to-set-bginfo-to-display-only-the-active-network-cards-ip-address/

This, for me, is only a partial solution as I want to show only the active network card information for things like the DNS, Subnet etc.  To do this, I created custom fields in BGinfo and (sort of replaced) the existing fields.

Here are the details:

I clicked Custom > New > WMI Query > Browse.  For the Identified (name) I use the same name as exists, but I do 2 things differently so that I don't overwrite the existing BGinfo entry.  First, I use 2 spaces in the name.  This means the identifier looks the same, but doesn't replace it. So now, in the list of fields, it appears as though there are 2 IP Address entries.  The seocnd thing I do so that I can tell the different in I use a lower case letter for the second word.  Therefore, I have an "IP Address" entry and a "IP  address".  The now look very similar, but I can tell the difference.

At this point, you can build the necessary query string using the interface to (first) select the right WMI Class (Win32_NetworkAdapterConfiguration) and (second) select the Class Property (for example IPAddress).  At this point, click Evaluate to see the list (since there are multiple IP addresses).

Next, limit the list using the WHERE clause.  For example, in my case the only IP addresses I want happen to be both active as well as have DHCP enabled.  So I use:


SELECT IPAddress FROM Win32_NetworkAdapterConfiguration Where IPEnabled=True and DHCPEnabled=True

For me, this returns just the IP address I'm interested in.  I replace the "IP Address" entry in BGinfo with my "IP  address" entry.

I create the following custom entries:


  • DNS  serverSELECT DNSServerSearchOrder FROM Win32_NetworkAdapterConfiguration Where IPEnabled=True and DHCPEnabled=True
  • IP  address - SELECT IPAddress FROM Win32_NetworkAdapterConfiguration Where IPEnabled=True and DHCPEnabled=True
  • Network  card - SELECT Description FROM Win32_NetworkAdapterConfiguration Where IPEnabled=True and DHCPEnabled=True
  • Subnet  maskSELECT IPSubnet FROM Win32_NetworkAdapterConfiguration Where IPEnabled=True and DHCPEnabled=True
Here is the end result:




Here is the bgi file that was saved: https://drive.google.com/file/d/0B35FDpn8GEl0RFhTZExIdjlRQm8/edit?usp=sharing



4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Very good and helpful post. thanks bro

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Unfortunately when I tried this method, BGinfo still returns null values in the output.

    ReplyDelete