请帮我编写一个VBS能禁用和启用2003系统的本地连接

来源:百度知道 编辑:UC知道 时间:2024/05/27 02:39:08
执行VBS时能弹出一个选择,连接或者禁用,不胜感激

Const ssfCONTROLS = 3
sConnectionName = "本地连接" '可改成需要控制的连接名称,如"无线网络连接"等
sEnableVerb = "启用(&A)"
sDisableVerb = "停用(&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