In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.