网络连接状态建立于断开的VBS脚本

2019-01-16 01:36:11丽君
断开连接提示

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & strComputer & "rootwmi")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("Select * from MSNdis_StatusMediaDisconnect")

Do While True
Set strLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo "A network connection has been lost:"
WScript.Echo strLatestEvent.InstanceName, Now
Wscript.Echo
Loop


建立连接提示

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & strComputer & "rootwmi")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("Select * from MSNdis_StatusMediaConnect")

Do While True
Set strLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo "A network connection has been made:"
WScript.Echo strLatestEvent.InstanceName, Now
Wscript.Echo
Loop

您可能感兴趣的文章:

C#中判断本地系统的网络连接状态的方法android 检查网络连接状态实现步骤c#判断网络连接状态