In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to achieve local connection disabled / enabled batch script", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to implement local connection disabled / enabled batch script" this article.
The code is as follows:
Const ssfCONTROLS = 3
SConnectionName = "local connection" can be changed to the name of the connection to be controlled, such as "wireless network connection", etc.
SEnableVerb = "enable (A)"
SDisableVerb = "disable (& B)" in XP system should be "disable (& B)"
Set shellApp = createobject ("shell.application")
Set oControlPanel = shellApp.Namespace (ssfCONTROLS)
Set oNetConnections = nothing
For each folderitem in oControlPanel.items
If folderitem.name = "Network connection" then
Set oNetConnections = folderitem.getfolder: exit for
End if
Next
If oNetConnections is nothing then
Msgbox "Network connection folder not found"
Wscript.quit
End if
Set oLanConnection = nothing
For each folderitem in oNetConnections.items
If lcase (folderitem.name) = lcase (sConnectionName) then
Set oLanConnection = folderitem: exit for
End if
Next
If oLanConnection is nothing then
Msgbox "not found" & sConnectionName & "'item"
Wscript.quit
End if
BEnabled = true
Set oEnableVerb = nothing
Set oDisableVerb = nothing
S = "Verbs:" & vbcrlf
For each verb in oLanConnection.verbs
S = s & vbcrlf & verb.name
If verb.name = sEnableVerb then
Set oEnableVerb = verb
BEnabled = false
End if
If verb.name = sDisableVerb then
Set oDisableVerb = verb
End if
Next
'debugging displays left just in case...
'
'msgbox 's': wscript.quit
'msgbox "Enabled:" & bEnabled': wscript.quit
'not sure why, but invokeverb always seemed to work
'for enable but not disable.
'
'saving a reference to the appropriate verb object
'and calling the DoIt method always seems to work.
'
If bEnabled then
'oLanConnection.invokeverb sDisableVerb
ODisableVerb.DoIt
Else
'oLanConnection.invokeverb sEnableVerb
OEnableVerb.DoIt
End if
'adjust the sleep duration below as needed...
'
'if you let the oLanConnection go out of scope
'and be destroyed too soon, the action of the verb
'may not take...
'
Wscript.sleep 400
The above is all the contents of the article "how to implement local connection disabled / enabled batch scripts". 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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.