Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the network connection state based on the disconnected VBS script

Shulou Source: shulou.com Published: 2022-06-03 06:49:19 11月15日 Update

This article is to share with you about how to achieve network connection status based on disconnected VBS scripts. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Disconnect prompt

The 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

Wscript.Echo

Loop

Tips for establishing a connection

The 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

Thank you for reading! This is the end of the article on "how to achieve the network connection status based on the disconnected VBS script". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Status network script code content more articles tips good practical articles read knowledge reference help about Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Microsoft Apple Shulou Tech Info Docker