首页 > 编程 > VBScript > 正文

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

2020-06-26 18:26:39
字体:
来源:转载
供稿:网友
断开连接提示与建立连接提示实现代码。
 
断开连接提示 
复制代码代码如下:

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 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表