+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28
Scripts Thread, BGInfo: Dispaying Text: Custom Query in Coding and Web Development; It would appear that, for some of the stations here, duplicated IP Addresses are being introduced by the 1394 Net ...
  1. #16

    DaveP's Avatar
    Join Date
    Oct 2006
    Location
    Can't talk now: The mother-ship is calling!
    Posts
    9,353
    Thank Post
    353
    Thanked 1,347 Times in 925 Posts
    Blog Entries
    4
    Rep Power
    1202
    It would appear that, for some of the stations here, duplicated IP Addresses are being introduced by the 1394 Net Adapter [Firewire Card]

    I would like to find a way of disabling this via Group Policy/Group Policy Preferences as we do not use Firewire here.

    Has anyone successfully done this?

    Or perhaps I could adjust the script:

    Code:
    Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
    Set colItems = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True",,48)
    
    strIPAddresses = ""
    
    For Each objItem In colItems
        For Each address In objItem.IPAddress
            blnValidIP = (InStr (address, ".") > 0) _
                    And (InStr (objItem.Caption, "VMware Virtual") = 0) _
                    And address <> "0.0.0.0"
            If blnValidIP Then
                strIPAddresses = strIPAddresses & address & "|"
            End If
        Next
    Next
    
    If Len (strIPAddresses) > 0 Then
        strIPAddresses = Left (strIPAddresses,Len(strIPAddresses)-1)
        strIPAddresses = Replace (strIPAddresses, "|", ", ")
    Else
        strIPAddresses = "(disconnected)"
    End If
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("C:\Windows\TEMP\IP.TXT", 2, 1)
    objFile.Write(strIPAddresses)
    objFile.Close

    to omit the installed Firewire card?

    Many thanks.
    Last edited by DaveP; 23rd June 2010 at 12:05 PM.

  2. #17
    Chad's Avatar
    Join Date
    May 2007
    Location
    Elgin
    Posts
    74
    Thank Post
    5
    Thanked 20 Times in 19 Posts
    Rep Power
    19
    Just for reference,

    Here's the script I use to display the user's full name via BGInfo (save as a .vbs file and add as a custom field):

    Code:
    ' ======================================
    On Error Resume Next
    Dim colWMI, objItem, colQuery, strUserID, strName
    Set colWMI = GetObject("WinMgmts:root/cimv2")
    Set colQuery = colWMI.ExecQuery("Select UserName FROM Win32_ComputerSystem")
    
    For Each objItem In colQuery
        strUserID = UCase(objItem.UserName)
        strName = Split(strUserID, "\")
        If strName(0) = strName(1) Then
    	strUserID = strName(1) & "\" & strName(2)
        End If
    Next
    
    Set colQuery = colWMI.ExecQuery("Select * FROM Win32_NetworkLoginProfile")
    
    For Each objItem In colQuery
        If UCase(objItem.Name) = strUserID Then
            Echo objItem.Fullname
        End If
    Next
    ' ======================================
    This gets round the multiple user names on screen issue, and also displays the name correctly in situations where users log in as domain\username rather than username@domain.

    Your solution looks more elegant, I may give it some testing :-)

    Chad

  3. #18

    Join Date
    May 2009
    Posts
    103
    Thank Post
    11
    Thanked 5 Times in 5 Posts
    Rep Power
    12
    Hi Dave

    Did you manage to get a script working that would only display the IP addresses in BGInfo when the connection had an address. Weve got the same problem you had where multiple IPs with "None" are coming up ie when a second NIC is disconnected but cant get a script working that would omit these when needed?

    Thanks
    Paul

  4. #19

    DaveP's Avatar
    Join Date
    Oct 2006
    Location
    Can't talk now: The mother-ship is calling!
    Posts
    9,353
    Thank Post
    353
    Thanked 1,347 Times in 925 Posts
    Blog Entries
    4
    Rep Power
    1202
    Quote Originally Posted by ba9ag View Post
    Hi Dave

    Did you manage to get a script working that would only display the IP addresses in BGInfo when the connection had an address. Weve got the same problem you had where multiple IPs with "None" are coming up ie when a second NIC is disconnected but cant get a script working that would omit these when needed?

    Thanks
    Paul
    Hi Paul,

    Have a look at this thread:

    Link: Select Single Paragraph From Text File At Random

    Starting at this post:

    Link: Select Single Paragraph From Text File At Random [Post number 18]

    With the able assistance of Edugeek member LosOjos I was able to get something I am much more happy with. Occasionally is does not display properly but that is probably down to our network rather than the solution.

    You will need to deploy the appropriate version of the .Net framework.

    This was very easy to set up once I got my head around it.

    Let me [or LosOjos?] know if you still have problems.

    Dave.

  5. #20

    Join Date
    May 2009
    Posts
    103
    Thank Post
    11
    Thanked 5 Times in 5 Posts
    Rep Power
    12
    Hi Dave

    Thanks for the info, have thread through the thread. Just a little confused as to how it all ties intogether to be used by BGInfo. I have had a go playing around with the custom fields with no joy to date. Is it possible to have a look at the scripts you are running on the custom BGInfo field removing redundant IPs then I can hopefully mod them to work at the school!

  6. #21

    DaveP's Avatar
    Join Date
    Oct 2006
    Location
    Can't talk now: The mother-ship is calling!
    Posts
    9,353
    Thank Post
    353
    Thanked 1,347 Times in 925 Posts
    Blog Entries
    4
    Rep Power
    1202
    Quote Originally Posted by ba9ag View Post
    Hi Dave

    Thanks for the info, have thread through the thread. Just a little confused as to how it all ties intogether to be used by BGInfo...
    I have had a quick look at the other post and at Group Policy/Active Directory. Unfortunately I am in a bit of a hurry this evening and I can't find what I want in a timely fashion. I will have a look again tomorrow.
    Last edited by DaveP; 2nd August 2010 at 08:14 PM. Reason: Correct spelling mistake.

  7. #22

    Join Date
    May 2009
    Posts
    103
    Thank Post
    11
    Thanked 5 Times in 5 Posts
    Rep Power
    12
    OK thanks much appreciated

  8. #23

    DaveP's Avatar
    Join Date
    Oct 2006
    Location
    Can't talk now: The mother-ship is calling!
    Posts
    9,353
    Thank Post
    353
    Thanked 1,347 Times in 925 Posts
    Blog Entries
    4
    Rep Power
    1202
    I think I need to reconstruct how I got to the solution I do now.

    The steps:

    1. use BGInfo's own IP query. [Select 'IP Address' from fields available on the right of BGInfo selection box (see below)]



    I found that some workstations and all laptops [with wireless enabled] reported multiple IP addresses with the addresses reported on screen one below the other. e.g.:

    192.168.1.200
    0.0.0.0

    I did some work and started using a script:

    Code:
    Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
    Set colItems = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True",,48)
    
    strIPAddresses = ""
    
    For Each objItem In colItems
        For Each address In objItem.IPAddress
            blnValidIP = (InStr (address, ".") > 0) _
                    And (InStr (objItem.Caption, "VMware Virtual") = 0) _
                    And address <> "0.0.0.0"
            If blnValidIP Then
                strIPAddresses = strIPAddresses & address & "|"
            End If
        Next
    Next
    
    If Len (strIPAddresses) > 0 Then
        strIPAddresses = Left (strIPAddresses,Len(strIPAddresses)-1)
        strIPAddresses = Replace (strIPAddresses, "|", ", ")
    Else
        strIPAddresses = "(disconnected)"
    End If
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("C:\Windows\TEMP\IP.TXT", 2, 1)
    objFile.Write(strIPAddresses)
    objFile.Close
    but what this script would do is report the IP address in multiples [this time on a single line: 192.168.3.200,192.168.3.200]

    I had an idea that I could use a utility that Edugeek member LosOjos helped me to get working on another thread: Link: Select Single Paragraph From Text File At Random

    What GetLine does [in this instance] is looks at IP.TXT, as created above, and only takes the left-most characters before the comma that separates them so you end up with:

    192.168.3.200

    or whatever your station IP happens to be.

    It works but I am sure that there is probably a neater way of doing it.

    I think that if you want to deploy this solution and you are having problems follow the steps that led me to what I have in place.

    Get your duplicate IP addresses displayed by querying IP.TXT using BGInfo [Confirms that IP.TXT exists and that the script to create it is working]

    Get your single IP address displayed using GetLine.exe to query IP.TXT to create RealIP.TXT and then use BGInfo to query the contents of RealIP.TXT and display that.

    I hope this is helpful [I am not good at explaining stuff!]

    If you still have problems feel free to get in touch again.

  9. Thanks to DaveP from:

    ba9ag (2nd August 2010)

  10. #24

    Join Date
    May 2009
    Posts
    103
    Thank Post
    11
    Thanked 5 Times in 5 Posts
    Rep Power
    12
    Hi Dave

    Thanks, just tested it all and it works perfectly.

    The only issue I have come across is on machines where there are not multiple IPs, the text in IP.txt will be something like 192.168.1.1. Then when you run getline on this it falls over and comes up with the message "This is not a comma/tab seperated file" and outputs nothing to RealIP.txt if this makes sense!

    Perhaps I could see if LosOjos can edit Getline so that if the original input file only contains one IP it just passes this output to RealIP.txt and if it contains more than one it continues to run the code removing redundant ones?

  11. #25

    DaveP's Avatar
    Join Date
    Oct 2006
    Location
    Can't talk now: The mother-ship is calling!
    Posts
    9,353
    Thank Post
    353
    Thanked 1,347 Times in 925 Posts
    Blog Entries
    4
    Rep Power
    1202
    Quote Originally Posted by ba9ag View Post
    Hi Dave

    Thanks, just tested it all and it works perfectly.

    The only issue I have come across is on machines where there are not multiple IPs, the text in IP.txt will be something like 192.168.1.1. Then when you run getline on this it falls over and comes up with the message "This is not a comma/tab seperated file" and outputs nothing to RealIP.txt if this makes sense!

    Perhaps I could see if LosOjos can edit Getline so that if the original input file only contains one IP it just passes this output to RealIP.txt and if it contains more than one it continues to run the code removing redundant ones?
    @ba9ag,

    I have just checked this thread and LosOjos has not posted in it [so he may not be aware of this conversation]

    However I have this from another post:

    Quote Originally Posted by LosOjos View Post
    Always feel free to request more features, I'm an old skool geek who enjoys a little programming to break up my day
    Link to post: Select Single Paragraph From Text File At Random

    Sounds like he might like to hear of another challenge!

    If you PM him I am sure that he would be willing to help? GetLine was recompiled/rewritten for me twice!

  12. #26

    Join Date
    May 2009
    Posts
    103
    Thank Post
    11
    Thanked 5 Times in 5 Posts
    Rep Power
    12
    Yeah have put a post on that thread, hopefuly he will be able to work his magic once more!

  13. #27

    DaveP's Avatar
    Join Date
    Oct 2006
    Location
    Can't talk now: The mother-ship is calling!
    Posts
    9,353
    Thank Post
    353
    Thanked 1,347 Times in 925 Posts
    Blog Entries
    4
    Rep Power
    1202
    Seems like a good chap. From my experience you can expect a reply tomorrow.

    Hope it works out!

  14. #28

    Join Date
    Jan 2011
    Location
    Oslo
    Posts
    1
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    This WMI query will find active IPs for you with BGInfo
    SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True

    (Find IPs on "enabled" Network adapters)



SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Convert Text On Image Into Editable Text
    By DaveP in forum General Chat
    Replies: 4
    Last Post: 30th May 2013, 10:10 AM
  2. Replies: 0
    Last Post: 10th January 2010, 08:05 AM
  3. BGInfo
    By OllieC in forum Windows
    Replies: 1
    Last Post: 17th August 2009, 06:10 PM
  4. SQL Query Using Full Text Engine inSQL 2005
    By Phanikumar in forum Web Development
    Replies: 0
    Last Post: 22nd September 2008, 09:47 AM
  5. Query of existing query data in PHP
    By markwilliamson2001 in forum Web Development
    Replies: 5
    Last Post: 5th October 2007, 09:43 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •