SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Retrieving Networking Configuration Inform...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Retrieving Networking Configuration Information Using Visual Basic.NET and VBScript
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2006-01-11

    Table of Contents:
  • Retrieving Networking Configuration Information Using Visual Basic.NET and VBScript
  • How to List all IPAddresses of a computer using Visual Basic.NET – the code
  • How to retrieve MAC address and other miscellaneous network information using Visual Basic.NET – preparing the wrapper
  • How to retrieve MAC address and other miscellaneous network information using Visual Basic.NET – the code
  • How to retrieve Network Client Information using Visual Basic.NET
  • How to retrieve Win Proxy Information using Visual Basic.NET

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Retrieving Networking Configuration Information Using Visual Basic.NET and VBScript - How to retrieve MAC address and other miscellaneous network information using Visual Basic.NET – the code


    (Page 4 of 6 )

    Once you complete the creation of the wrapper (as specified in the previous section), proceed with the following VB.NET code to list all the in-depth details of network configuration information available on your system.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                Dim searcher As New ManagementObjectSearcher( _
                             "root\CIMV2", _
                             "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
                Dim dt As DataTable = globals.getNetworkConfigStructure
                For Each queryObj As ManagementObject In searcher.Get()
                    Dim IPXNetworkNumber As String = ""
                    If queryObj("IPXNetworkNumber") Is Nothing Then
                        IPXNetworkNumber = queryObj("IPXNetworkNumber")
                    Else
                        Dim arrIPXNetworkNumber As String()
                        arrIPXNetworkNumber = queryObj("IPXNetworkNumber")
                        For Each arrValue As String In arrIPXNetworkNumber
                            IPXNetworkNumber &= arrValue
                        Next
                    End If
                    globals.addNetworkConfig(dt, queryObj("Caption"), queryObj("IPFilterSecurityEnabled"), queryObj("IPPortSecurityEnabled"), queryObj("IPXAddress"), queryObj("IPXEnabled"), IPXNetworkNumber, queryObj("MACAddress"), queryObj("WINSPrimaryServer"), queryObj("WINSSecondaryServer"))
                Next
                Me.DataGrid1.DataSource = dt
            Catch err As Exception
                MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
            End Try

    You can achieve the same thing with VBScript as follows:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery( _
        "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True",,48)
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "IPFilterSecurityEnabled: " & objItem.IPFilterSecurityEnabled
        Wscript.Echo "IPPortSecurityEnabled: " & objItem.IPPortSecurityEnabled
        Wscript.Echo "IPXAddress: " & objItem.IPXAddress
        Wscript.Echo "IPXEnabled: " & objItem.IPXEnabled
        If isNull(objItem.IPXNetworkNumber) Then
            Wscript.Echo "IPXNetworkNumber: "
        Else
            Wscript.Echo "IPXNetworkNumber: " & Join(objItem.IPXNetworkNumber, ",")
        End If
        Wscript.Echo "MACAddress: " & objItem.MACAddress
        Wscript.Echo "WINSPrimaryServer: " & objItem.WINSPrimaryServer
        Wscript.Echo "WINSSecondaryServer: " & objItem.WINSSecondaryServer
    Next

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · [i]This article explains how to retrieve “Network settings” information dynamically...
       · This is a very good article, but a little insight on adding a reference for...
       · Hello,Actually, within the same article I already added the following...
     

    VISUAL BASIC.NET ARTICLES

    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway