照葫芦画瓢。大概看了一下。其实代码还可以精简的。有兴趣的朋友不妨修改一下。
;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)
XP SP3 平台下测试成功。
后续更新会写在BLOG。
http://www.lunhui.net.cn/article.asp?id=20 |