Re: wbemtest and network adapter events
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 05/07/04
- Next message: ioda: "Re: Win32_Process and ExecutablePath"
- Previous message: Jon Hart: "wbemtest and network adapter events"
- In reply to: Jon Hart: "wbemtest and network adapter events"
- Next in thread: Jon Hart: "Re: wbemtest and network adapter events"
- Reply: Jon Hart: "Re: wbemtest and network adapter events"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 07 May 2004 10:58:18 +0200
Jon Hart wrote:
> I need to detect the connection and disconnection of network adapters.
> I have some code that I think does what I want, but Im not getting any
> events coming through when I unplug my cable ( the system tray sees
> the
> event ).
>
> So Im trying to use wbemtest to monitor the events, but nothing is
> coming through there either.
>
> This is what Im doing:
> (snip)
Hi
If it is network connection/disconnection you want to detect, you can use
MSNdis_StatusMediaConnect, here is a VBScript example that works for me:
Set colMonitoredEvents = GetObject("winmgmts:root\wmi")._
ExecNotificationQuery("Select * from MSNdis_StatusMediaConnect")
Do
Set strLatestEvent = colMonitoredEvents.NextEvent
WScript.Echo "Connected! Do something here"
' enable the line below if you want to exit after the first event.
'Exit Do
Loop
If you want to check a specific adapter, use e.g. a select on the
InstanceName of the adapter:
Set colMonitoredEvents = GetObject("winmgmts:root\wmi")._
ExecNotificationQuery("Select * from MSNdis_StatusMediaConnect" _
& " WHERE InstanceName = '3Com 10/100 Mini PCI Ethernet Adapter'")
Do
Set strLatestEvent = colMonitoredEvents.NextEvent
WScript.Echo "Connected! Do something here"
' enable the line below if you want to exit after the first event.
'Exit Do
Loop
-- 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/community/scriptcenter/default.mspx
- Next message: ioda: "Re: Win32_Process and ExecutablePath"
- Previous message: Jon Hart: "wbemtest and network adapter events"
- In reply to: Jon Hart: "wbemtest and network adapter events"
- Next in thread: Jon Hart: "Re: wbemtest and network adapter events"
- Reply: Jon Hart: "Re: wbemtest and network adapter events"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|