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

讨论一段禁用/启用网络连接的代码

[复制链接]
发表于 2009-3-11 13:23:38 | 显示全部楼层 |阅读模式
;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 在公司局域网中。发现在在网络连接已经启用的情况下,运行后可以禁用,但是脚本就结束了,没有启用~。此时机器网络连接是禁用状态,再运行一次,就启用了。  请问如何解决???
 楼主| 发表于 2009-3-11 22:05:31 | 显示全部楼层
顶上去求解!!!!!!!!
发表于 2009-3-11 23:57:38 | 显示全部楼层
这个脚本本来就是如此的。要想合适自己用的,必须更改。
发表于 2009-3-12 08:21:31 | 显示全部楼层
这个用devcon 更快
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-24 19:35 , Processed in 0.075831 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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