Const ssfCONTROLS = 3
sConnectionName = "本地连接" '可改成需要控制的连接名称,如"无线网络连接"等
sEnableVerb = "启用(&A)"
sDisableVerb = "停用(&B)" '2003系统中应为 "禁用(&B)"
set shellApp = createobject("
shell.application")
set ōControlPanel = shellApp.Namespace(ssfCONTROLS)
set ōNetConnections = nothing
for each folderitem in oControlPanel.items
if folderitem.name = "网络连接" then
set ōNetConnections = folderitem.getfolder: exit for
end if
next
if oNetConnections is nothing then
msgbox "未找到网络连接文件夹"
wscrīpt.quit
end if
set ōLanConnection = nothing
for each folderitem in oNetConnections.items
if lcase(folderitem.name) = lcase(sConnectionName) then
set ōLanConnection = folderitem: exit for
end if
next
if oLanConnection is nothing then
msgbox "未找到 '" & sConnectionName & "' item"
wscrīpt.quit
end if
bEnabled = true
set ōEnableVerb = nothing
set ōDisableVerb = nothing
s = "Verbs: " & vbcrlf
for each verb in oLanConnection.verbs
s = s & vbcrlf & verb.name
if verb.name = sEnableVerb then
set ōEnableVerb = verb
bEnabled = false
end if
if verb.name = sDisableVerb then
set ōDisableVerb = verb
end if
next
if bEnabled then
oDisableVerb.DoIt
else
oEnableVerb.DoIt
end if
wscrīpt.sleep 400