Get the App
SLTechnology News&Howtos  ›  Development  › 

How VBS monitors network connections and disconnections

Shulou Source: shulou.com Published: 2022-06-03 07:48:21 11月15日 Update

Editor to share with you how VBS monitors network connections and disconnections, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

Monitor network connections:

The copy code is as follows:

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

The monitoring network is down:

The copy code is as follows:

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

Loop

The above is all the contents of the article "how VBS monitors network connections and disconnections". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Network monitoring code articles content not much most more knowledge industry information channels channels references learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Microsoft Xiaomi macOS Redmi