停用本地连接后再启用才可以上网的解决办法
来源:高中英语教学交流
发布时间:2010-05-07 13:25:00
查看次数:
最近找到了第三种方法,把下面的代码保存到桌面运行就行了(如果想开机后自动运行,请把这个文件的快捷方式发送到附件中的启动项中)。
Const ssfCONTROLS = 3
sConnectionName = "本地连接 5" '可改成需要控制的连接名称,如"无线网络连接"等
sEnableVerb = "启用(&A)"
sDisableVerb = "停用(&B)" '2k系统中应为 "禁用(&B)"
set shellApp = createobject("shell.application")
set oControlPanel = shellApp.Namespace(ssfCONTROLS)
set oNetConnections = nothing
for each folderitem in oControlPanel.items
if folderitem.name = "网络连接" then
set oNetConnections = folderitem.getfolder: exit for
end if
next
if oNetConnections is nothing then
msgbox "未找到网络连接文件夹"
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 "未找到 '" & 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
将上面代码另存为禁用/启用本地连接.vbs
- 相关文章
- ·Win11更新之后无法连接局域网打印机的解决方法03-08·文件夹变成了快捷方式怎么办?04-22·当EXCEL或WORD打不开时出来怎么办?11-07·佳能MP250系列废墨清零软件12-07·搜索框不能输入文字、字符的解决方法05-22·停用本地连接后再启用才可以上网的解决办法05-07·解决NTLDR is missing的快捷方法10-25
- 最新文章
- ·联想打印机换硒鼓清零教程(轻松解决打印机硒鼓低提05-16·Win11更新之后无法连接局域网打印机的解决方法03-08·佳能打印机故障代码排查09-17·佳能MP250系列废墨清零软件12-07·路由器:静态IP与网关不在同一段的解决方法09-29·多种解决:“Word无法启动转换器”06-02·当EXCEL或WORD打不开时出来怎么办?11-07·解决NTLDR is missing的快捷方法10-25·墨水收集器已满 佳能1980/188001-12
- 阅读排行
- ·文件夹变成了快捷方式怎么办?04-22·搜索框不能输入文字、字符的解决方法05-22·当EXCEL或WORD打不开时出来怎么办?11-07·墨水收集器已满 佳能1980/188001-12·停用本地连接后再启用才可以上网的解决办法05-07·路由器:静态IP与网关不在同一段的解决方法09-29·佳能打印机故障代码排查09-17·解决NTLDR is missing的快捷方法10-25·佳能MP250系列废墨清零软件12-07
点击这里识别二维码关注公众号