Sysinternals Homepage
Forum Home Forum Home > Sysinternals Utilities > BgInfo
  New Posts New Posts RSS Feed - Custom WMI to eclude (none) and IPv6
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Custom WMI to eclude (none) and IPv6

 Post Reply Post Reply Page  12>
Author
Message
allenm876 View Drop Down
Newbie
Newbie


Joined: 01 November 2010
Location: Hull - UK
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote allenm876 Quote  Post ReplyReply Direct Link To This Post Topic: Custom WMI to eclude (none) and IPv6
    Posted: 01 November 2010 at 11:04am
Hi

We are currently setting up BgInfo onto our users desktops. To keep it as tidy as possible I have used the following to hide the (none) values for the IP address:

SELECT IPAddress FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'True' 

This worked great for getting rid of the (none) value but it has now added the IPv6 address to the output. 

Does anyone know of a way to exclude IPv6 from the output?


Thanks in advance for your help.


Steve
Back to Top
allenm876 View Drop Down
Newbie
Newbie


Joined: 01 November 2010
Location: Hull - UK
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote allenm876 Quote  Post ReplyReply Direct Link To This Post Posted: 09 November 2010 at 10:57am
Anyone able to help with this? 

Thanks
Back to Top
WindowsStar View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 June 2010
Status: Offline
Points: 740
Post Options Post Options   Thanks (0) Thanks(0)   Quote WindowsStar Quote  Post ReplyReply Direct Link To This Post Posted: 18 February 2011 at 8:50am
Sure add and If/Then
 
If NOT InStr(strIPAddress,":") Then echo strIPAddress
 
 
Back to Top
Pepé Le Pew View Drop Down
Newbie
Newbie
Avatar

Joined: 20 February 2011
Location: Hampshire
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pepé Le Pew Quote  Post ReplyReply Direct Link To This Post Posted: 20 February 2011 at 12:11am
Originally posted by WindowsStar WindowsStar wrote:

Sure add and If/Then
 
If NOT InStr(strIPAddress,":") Then echo strIPAddress
 
 


I'm afraid it doesn't work for me.  Using the original string of the first post displays the following result: 192.168.1.69 fe80::31c2:3a45:11a1:1496

When adding the suggested "If NOT InStr(strIPAddress,":") Then echo strIPAddress" part I get the following result: (Query failed)

What should the new string look with the "and if/then..." addition to get it to work?
Back to Top
WindowsStar View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 June 2010
Status: Offline
Points: 740
Post Options Post Options   Thanks (0) Thanks(0)   Quote WindowsStar Quote  Post ReplyReply Direct Link To This Post Posted: 20 February 2011 at 4:03am
If you will post the entire script I will modify it to work for you. Thanks -WS
Back to Top
Pepé Le Pew View Drop Down
Newbie
Newbie
Avatar

Joined: 20 February 2011
Location: Hampshire
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pepé Le Pew Quote  Post ReplyReply Direct Link To This Post Posted: 21 February 2011 at 12:06pm
I don't really use a script of sorts.  On my machines BGInfo deploys to C:\BGInfo  and a shortcut gets placed in the Startup folder that points to C:\BGInfo\BGInfo.cmd  this runs minimised and looks like this:
-----------------------------
@ECHO OFF
TITLE BGInfo refresh on logon
SETLOCAL

C:\BGInfo\BgInfo.exe /iC:\BGInfo\BGInfo_Config.bgi /timer:0 /nolicprompt

EXIT

------------------------------

The BGInfo_Config.bgi file then uses one of the fields; created in the Custom option to display the IP address.  When configuring the BGInfo_Config.bgi file I selected the Custom button to add/edit the user defined fields.  Here I have created the Identifier as Active IP, the Type is WMI Query and the path is SELECT IPAddress FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'True'

When you have entered the path you can click on the Browse button which will open the WMI Query Selection box and then when you click on the Evaluate button, the Query Result(s) displays what the output will look like.  In this case it displays it as 192.168.1.69 fe80::31c2:3a45:11a1:1496

I just want to display the IPV4 address only, dropping the IPV6 address altogether.

Just as an FYI, In addition to the default Fields in BGInfo this is the full list of all the custom variables I use, depending on the OS and what the machine is built for:

1. Active DNS - WMI Query - SELECT DNSServerSearchOrder FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'True'
2. Active IP - WMI Query - SELECT IPAddress FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'True'
3. Active MAC Address - WMI Query - SELECT MACAddress FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'True'
4. Active Subnet Mask - WMI Query - SELECT IPSubnet FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'True'
5. Manufacturer - WMI Query - SELECT Manufacturer FROM Win32_ComputerSystem
6. Model - WMI Query - SELECT Model FROM Win32_ComputerSystem
7. OS and Edition - Registry Value - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName
8. OS Architecture - WMI Query - SELECT OSArchitecture FROM Win32_OperatingSystem
9. OS Architecture XP2K3 - Registry Value - HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE
10. Workgroup - WMI Query - SELECT Workgroup FROM Win32_ComputerSystem



From all this my layout on the machine desktop ends up like this (nicely spaced and in line, not crappy as it displays on this forum page Wink :

________________________________________________________________

     User  <User Name>  is currently logged on to  <Host Name>
________________________________________________________________

Domain:    <Machine Domain>

OS Version:    <OS and Edition> (<OS Architecture>) - <Service Pack>
Last Startup:    <Boot Time>

Machine:    <Manufacturer>  -  <Model>
CPU:    <CPU>
Memory:    <Memory>

MAC Address:    <Active MAC Address>

Active IP Address:    <Active IP>

Subnet Mask:    <Active Subnet Mask>

Default Gateway:    <Default Gateway>

Active DNS:    <Active DNS>

Free Space:    <Free Space>


Thanks,

Back to Top
WindowsStar View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 June 2010
Status: Offline
Points: 740
Post Options Post Options   Thanks (0) Thanks(0)   Quote WindowsStar Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2011 at 7:27am

Here are a few scripts to help you out:

I had already written these to help with my installs. I did not know you were using direct WMI calls and not scripts. The scripts are more flexible because you can filter the output.

You will need to change your “Custom…” from WMI Query to Script File.
 
Copy and paste each script into notepad and save in your BGInfo Folder. Make sure to include the " at the front and back of the file name to make sure it is named .VBS and not .TXT.

 

Replace #2 with this script: Script Name “OnlyIPv4Address.vbs”

 

' Special BGInfo Script

' Only IPv4 Address v1.7

' Programmed by WindowsStar - Copyright (c) 2009-2011

' --------------------------------------------------------

 

strComputer = "."

On Error Resume Next

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'True'")

 

For Each objIP in colSettings

   For i=LBound(objIP.IPAddress) to UBound(objIP.IPAddress)

      If InStr(objIP.IPAddress(i),":") = 0 Then Echo objIP.IPAddress(i)

   Next

Next

 

Incase at a later date you want IPv6

Add this script: Script Name “OnlyIPv6Address.vbs”

 

' Special BGInfo Script

' Only IPv6 Address v1.7

' Programmed by WindowsStar - Copyright (c) 2009-2011

' --------------------------------------------------------

 

strComputer = "."

On Error Resume Next

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'True'")

 

For Each objIP in colSettings

   For i=LBound(objIP.IPAddress) to UBound(objIP.IPAddress)

      If InStr(objIP.IPAddress(i),":") <> 0 Then Echo objIP.IPAddress(i)

   Next

Next

 

Replace # 7 with this script: Script Name “OperatingSystemInformation.vbs”

 

' Special BGInfo Script

' Operating System Information v1.3

' Programmed by WindowsStar - Copyright (c) 2009-2010

' --------------------------------------------------------

 

strComputer = "."

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")

 

For Each objOperatingSystem in colOperatingSystems

    OSCaption = Trim(Replace(objOperatingSystem.Caption,"Microsoft ",""))

    OSCaption = Replace(OSCaption,"Microsoft","")

    OSCaption = Replace(OSCaption,"(R)","")

    OSCaption = Trim(Replace(OSCaption,",",""))

    Echo OSCaption

Next

 

Replace # 8 and 9 with this script: Script Name “OSArchitecture.vbs”

 

' Special BGInfo Script

' OS Architecture v1.5

' Programmed by WindowsStar - Copyright (c) 2009

' ---------------------------------------------------

 

strComputer = "."

On Error Resume Next

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery ("Select * from Win32_Processor")

For Each objComputer in colSettings

     If objComputer.Architecture = 0 Then ArchitectureType = "32Bit"

     If objComputer.Architecture = 6 Then ArchitectureType = "Intel Itanium"

     If objComputer.Architecture = 9 Then ArchitectureType = "64Bit"

Next

 

Echo ArchitectureType

 

Replacing the Operation System Information will display any OS Edition. The OS Architecture script will remove the need for 2 different versions to cover different OS’s.

 
Enjoy -WS


Edited by WindowsStar - 22 February 2011 at 7:31am
Back to Top
Pepé Le Pew View Drop Down
Newbie
Newbie
Avatar

Joined: 20 February 2011
Location: Hampshire
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pepé Le Pew Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2011 at 8:56am
AWESOME!!! Thanks WindowsStar,  I will start implementing them today.

Beer
Back to Top
WindowsStar View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 June 2010
Status: Offline
Points: 740
Post Options Post Options   Thanks (0) Thanks(0)   Quote WindowsStar Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2011 at 9:26am
Let me know how it goes.
Back to Top
67_dbc View Drop Down
Newbie
Newbie
Avatar

Joined: 23 June 2011
Location: Houston, Texas
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote 67_dbc Quote  Post ReplyReply Direct Link To This Post Posted: 23 June 2011 at 2:43pm
Works like a charm. Good post!
Back to Top
 Post Reply Post Reply Page  12>
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.06
Copyright ©2001-2016 Web Wiz Ltd.