找回密码
 加入
搜索
查看: 1729|回复: 1

多网卡中怎样禁用指定网卡【非活动网卡】

[复制链接]
发表于 2009-8-19 00:06:23 | 显示全部楼层 |阅读模式
本帖最后由 jycel 于 2009-8-19 00:07 编辑

使用_NetworkAdapterInfo()函数获取所有网卡信息!
如果判断到有非活动网卡,怎样来禁用这一个,而不是全部禁用
 楼主| 发表于 2009-8-19 23:01:46 | 显示全部楼层
本帖最后由 jycel 于 2009-8-19 23:03 编辑

以下是坛子里找的禁用/启用,还不熟悉vbs和wmi,那位帮我改下,根据网卡名称只禁用或分开来
;AU3版本禁用/启用网卡
; www.autoitx.com 中文论坛版权所有
Global Const $ssfCONTROLS = 3 
$sConnectionName = "本地连接"
$sEnableVerb = "启用(&A)" 
$sDisableVerb = "停用(&B)" ;2003 应改为“禁用(&B)”
$shellApp = ObjCreate("shell.application")
$oControlPanel = $shellApp.Namespace($ssfCONTROLS) 

$oNetConnections = "" 
for $folderitem in $oControlPanel.items 
   if $folderitem.name = "网络连接" then    
$oNetConnections = $folderitem.getfolder
ExitLoop
endif
next
if $oNetConnections ="" then  
   MsgBox(0,"","未找到网络连接文档夹")
Exit
endif

$oLanConnection = ""
for $folderitem in $oNetConnections.items 
if StringLower($folderitem.name) = StringLower($sConnectionName) then  
   $oLanConnection = $folderitem
ExitLoop 
   endif 
next 
if $oLanConnection ="" then 
Exit 
endif 

$bEnabled = true 
$oEnableVerb = ""
$oDisableVerb = ""
$s = "Verbs: " & @crlf 
for $verb in $oLanConnection.verbs  
$s = $s & @crlf & $verb.name 
if $verb.name = $sEnableVerb then    
$oEnableVerb = $verb    
   $bEnabled = false    
endif 
if $verb.name = $sDisableVerb then    
$oDisableVerb = $verb  
endif 
next 
if $bEnabled then 
$oDisableVerb.DoIt 
else    
$oEnableVerb.DoIt
endif 
sleep(1000)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-9 04:07 , Processed in 0.090821 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表