关闭/开启本地连接的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
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
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


if bEnabled then
oDisableVerb.DoIt
else
oEnableVerb.DoIt
end if

wscript.sleep 1000 以上存为net.vbs运行即可
引用通告: 我要引用此文章
Tags: 代码  
相关日志:
  • 宽屏壁纸收集  (2006-7-16 19:12:50)
  • 按键妖怪  (2006-4-14 13:5:19)
  • 流氓软件清除器  (2006-3-13 15:7:14)
  • 申请了vpp 号码是185841174  (2006-3-2 22:45:39)
  • 增强型 cmd 命令行.支持列表  (2006-2-10 14:30:44)
  • 关于男生追女生的数学模型  (2006-2-10 9:37:12)
  • asp 解压rar的写法  (2006-1-5 9:45:0)
  • 精品笑话调用  (2006-1-4 14:59:11)
  • Wanago:为你的网站增加Tag功能   (2005-12-17 23:53:42)
  • QQ论坛顶部音乐电台的调用例子  (2005-12-14 14:52:47)
  • 评论: 0 | 引用: 0 | 查看次数:
    发表评论
    昵 称:
    邮 箱:
    主 页:
    内 容: