脚本专栏 
首页 > 脚本专栏 > 浏览文章

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

(编辑:jimmy 日期: 2024/12/23 浏览:3 次 )
断开连接提示
复制代码 代码如下:
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\wmi")
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 & "\root\wmi")
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
上一篇:WMI中的Win32_PingStatus类(ping命令实现)
下一篇:VBS的字符串及日期操作相关函数