希望这里能成为我工作成长过程的积累。。

禁用&启动网卡

上一篇 / 下一篇  2008-07-23 09:31:16 / 个人分类:VbScript

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
相关阅读:

TAG: VbScript

 

评分:0

我来说两句

日历

« 2024-04-29  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 8523
  • 日志数: 15
  • 建立时间: 2007-06-10
  • 更新时间: 2008-07-23

RSS订阅

Open Toolbar