Digging into Network Adapters with Visual Basic.NET and VBScript using WMI
(Page 1 of 4 )
This article explains how you can retrieve network adapter information using both Visual Basic.NET and VB Script together with WMI.
A downloadable file for this article is available
here.
The sample downloadable solution (zip) is entirely developed using Visual Studio.NET 2003 Enterprise Architect on Windows Server 2003 Standard Edition. But I am confident that it would work with other versions of Windows (which support .NET 1.1) as well. To work with Visual Studio 2005, the coding may need minor modifications (I didn't really test it yet). If you come across any problems, please do post them in the discussion, so that I can guide you accordingly.
If you wanted to use WMI with JavaScript (on the client side using IE), you may need to regularly check www.devarticles.com for a contribution dealing with this topic.
Some global routines used for my WMI development
I already contributed several articles on WMI with Visual Basic.NET and VB Script. I'm trying to cover almost all of the latest aspects of WMI. I strongly suggest you go through my series on "WMI Programming with Visual Basic.NET" before reading this article. The series even covers "event handling" using WMI with Visual Basic .NET in the form of a Windows service.
For flexibility in retrieving WMI information (using VB.NET), I frequently used the following simple global routines which help me to work with other areas of development very easily.
Public Sub addRow(ByRef dt As DataTable, ByVal p As String, ByVal v As String)
Dim dr As DataRow
dr = dt.NewRow
dr("Property") = p
dr("Value") = v
dt.Rows.Add(dr)
End Sub
Public Function getStructure() As DataTable
Dim dt As New DataTable
dt.Columns.Add(New DataColumn("Property"))
dt.Columns.Add(New DataColumn("Value"))
Return dt
End Function
Two of my global routines are the above ones, "getStructure" and "addRow." Both are generally used if I have a "Property->value" scenario. "GetStructure" just creates a data table structure and "AddRow" simply adds a data row for every data table passed to it.
Next: Listing network adapter information using WMI >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee