找回密码
 加入
搜索
查看: 2743|回复: 4

网关切换问题???

[复制链接]
发表于 2008-6-7 21:19:44 | 显示全部楼层 |阅读模式
#include 
#include 
#NoTrayIcon
$ip = @IPAddress1
$result = StringTrimLeft($ip,10)

For $i=1 To 40 ;IP地址为1-40的机器
If $i = $result Then
; MsgBox(0, "bbb", $result)
Dim $SetDns[2],$SetGateway[1]
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
$colComputers = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem") 

If IsObj($colItems) Then

For $objNetAdapter in $colItems
$SetGateway[0] = "192.168.1.254"
$SetDns[0] = "221.228.255.1"
$SetDns[1] = "192.168.1.254"
$objNetAdapter.SetGateways($SetGateway)
$objNetAdapter.SetDNSServerSearchOrder($SetDns)

Next
EndIf

EndIf
Next 


用开机通道运行后,效果如图:


客户机经常会时通时断,QQ一会上线,一会掉,感觉很不稳定,
高手帮我看看代码有没有问题!!!
多谢了!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2008-6-8 04:22:10 | 显示全部楼层
切换完成后停用网卡在启用试试。
发表于 2008-6-8 07:55:41 | 显示全部楼层
尝试这样。我一直这样用,没有过任何问题。

 
Func _SetGatway($Gateway)

Dim $SetGateway[1]
 $SetGateway[0] = $Gateway
Local  $wbemFlagReturnImmediately ,$wbemFlagForwardOnly 
Local  $strComputer,$objWMIService,$colItems,$objNetAdapter  

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)

For $objNetAdapter in $colItems
                    $objNetAdapter.SetGateways($SetGateway) 
Next

EndFunc
 楼主| 发表于 2008-6-11 23:44:37 | 显示全部楼层
还是有同样的问题存在,看来只能用其它方法试一下了
 楼主| 发表于 2008-6-19 15:23:24 | 显示全部楼层
#include <GuiIPAddress.au3>
#NoTrayIcon
$ip = @IPAddress1
$result = StringTrimLeft($ip,10)
Run(@ComSpec & " /c " & " ARP -S 192.168.1.254 00-00-00-00-00-00", "", @SW_HIDE)    ;绑定默认网关
For $i=1 To 15       ;IP地址为1-15的机器
        Run(@ComSpec & " /c " & " ARP -S 192.168.1.254 ff-ff-ff-ff-ff-ff", "", @SW_HIDE)    ;网关切换
Next 


现在用一另类方法做网关切换,好像效果还不错。哈。。。。
00-00-00-00-00-00  为默认网关192.168.1.254的MAC地址
ff-ff-ff-ff-ff-ff   为另一网关192.168.1.154的MAC地址,
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-24 09:32 , Processed in 0.076525 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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