网络连接状态建立于断开的VBS脚本
更新时间:2011年02月22日 20:41:08 作者:
断开连接提示与建立连接提示实现代码。
断开连接提示
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
复制代码 代码如下:
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
相关文章
可以修改脚本自身运行次数的vbs(Self modifying script)
通过脚本修改脚本的内容,这里以统计脚本运行次数为例,想学习vbs的朋友可以参考下2013-08-08利用WSH里的MapNetworkDrive方法脚本蠕虫的传播方式
利用WSH里的MapNetworkDrive方法脚本蠕虫的传播方式...2007-02-02VBS教程:函数-ScriptEngineMajorVersion 函数
VBS教程:函数-ScriptEngineMajorVersion 函数...2006-11-11
最新评论