Re: Win32_NetworkConnection returns empty
From: Dharani Babu S (dharanibabus_at_hotmail.com.(donotspam))
Date: 10/27/04
- Next message: rayudu_kamma: "IWbemServices->ConnectServer() failure"
- Previous message: SlimFlem: "using ManagementClass.GetInstances() with object in ASP.NET Cache"
- In reply to: Torgeir Bakken \(MVP\): "Re: Win32_NetworkConnection returns empty"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 26 Oct 2004 20:31:01 -0700
Thanks for your reply.
I am using IPEnabled property of Win32_NetworkAdapterConfiguration to find
outthe connectivity to network . Your alternatives are for 2000 , XP and
above but Win32_NetworkAdapterConfiguration.IPEnabled works fine for NT and
2000 . Is it a valid alternative ?
"Torgeir Bakken (MVP)" wrote:
> Dharani Babu S wrote:
>
> > Hi all
> > I am trying to find out whether a system is connected to network or not . So
> > I thought ConnectionState property of Win32_NetworkConnection will give me
> > the status of the system . But when I executed the ExecQuery( "select * from
> > Win32_NetworkConnection " or "select ConnectionState from
> > Win32_NetworkConnection ") it returns with no values . It does not return
> > NULL also . Could anyone point tome the problem ? and is
> > Win32_NetworkConnection the right class to find out the presence of a system
> > in a network ?
> Hi
>
> Note that Win32_NetworkConnection only represents mapped drives, and
> not if your system is connected to a network or not.
>
> Some alternatives maybe:
>
>
> Windows XP and beyond:
>
> '--------------------8<----------------------
> sComputerName = "." ' Use "." for local computer
> Set oWMIService = GetObject("winmgmts:\\" & sComputerName & "\root\cimv2")
>
> For Each oAdapter In oWMIService.InstancesOf("Win32_NetworkAdapter")
> If oAdapter.NetConnectionStatus = 2 Then
> WScript.Echo "Network connection """ & oAdapter.NetConnectionID _
> & """ is connected"
> End If
> Next
> '--------------------8<----------------------
>
>
>
> Windows 2000 and beyond:
>
> '--------------------8<----------------------
> sComputerName = "." ' Use "." for local computer
>
> Set oWMIService = GetObject("winmgmts:\\" & sComputerName & "\root\wmi")
> Set oNicCollection = oWMIService.InstancesOf("MSNdis_MediaConnectStatus")
>
> For Each oNic In oNicCollection
> If oNic.NdisMediaConnectStatus = 0 Then
> sNicStatus = "connected"
> Elseif oNic.NdisMediaConnectStatus = 1 Then
> sNicStatus = "disconnected"
> Else
> sNicStatus = "unknown"
> End If
>
> WScript.Echo "Status of " & oNic.InstanceName & ": " & sNicStatus
> Next
> '--------------------8<----------------------
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>
- Next message: rayudu_kamma: "IWbemServices->ConnectServer() failure"
- Previous message: SlimFlem: "using ManagementClass.GetInstances() with object in ASP.NET Cache"
- In reply to: Torgeir Bakken \(MVP\): "Re: Win32_NetworkConnection returns empty"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|