In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to use vbs to disable or enable local connections". In daily operation, I believe many people have doubts about how to use vbs to disable or enable local connections. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to use vbs to disable or enable local connections." Next, please follow the editor to study!
The copy 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
At this point, the study on "how to use vbs to disable or enable local connections" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.