Get network status through WMI

  • Thread starter Thread starter Norton
  • Start date Start date
N

Norton

Hi all,

May i know how to get the network status through WMI, i have searched the
WMI properties but cannot find the related property to use.
thx in advance

Norton
 
Hi,

If you are looking to check network status for an active network
connection. You need to a reference to system.management.dll for this to
work.

http://msdn.microsoft.com/library/d.../en-us/wmisdk/wmi/win32_networkconnection.asp

Private Sub GetNetworkStatus()
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_NetworkConnection")

moReturn = moSearch.Get
For Each mo In moReturn
Dim strOut As String
strOut = String.Format("{0} - Status {1}", mo("Name").ToString,
mo("Status").ToString)
Trace.WriteLine(strOut)
Next
End Sub

Here is a link to see if you are connected to a network that uses a
ping

http://msdn.microsoft.com/library/d...ry/en-us/dndotnet/html/northwindunplugged.asp

Ken
 
thx a lot ~ it works ~

Ken Tucker said:
Hi,

If you are looking to check network status for an active network
connection. You need to a reference to system.management.dll for this to
work.

http://msdn.microsoft.com/library/d.../en-us/wmisdk/wmi/win32_networkconnection.asp

Private Sub GetNetworkStatus()
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_NetworkConnection")

moReturn = moSearch.Get
For Each mo In moReturn
Dim strOut As String
strOut = String.Format("{0} - Status {1}", mo("Name").ToString,
mo("Status").ToString)
Trace.WriteLine(strOut)
Next
End Sub

Here is a link to see if you are connected to a network that uses a
http://msdn.microsoft.com/library/d...ry/en-us/dndotnet/html/northwindunplugged.asp

Ken
 
Hi I just tried this and I am propably missing something but I can't
get it to work. I belive that the problem is when moSearch.Get is
executed, in the debug output i get the following: "The thread '<No
Name>' (0xc88) has exited with code 0 (0x0)"

Thanks

Jacob
 
Back
Top