找回密码
 加入
搜索
楼主: bj17209

[网络通信] au3 怎么才能添加多个IP?

 火.. [复制链接]
发表于 2010-8-23 10:52:45 | 显示全部楼层
如何删除添加的IP呢?
发表于 2010-8-23 11:50:50 | 显示全部楼层
回复 16# zhj0887
#include <Constants.au3>

$ip1 = @IPAddress1

Dim $SetIPAddress[2]
$SetIPAddress[0] = $ip1
$SetIPAddress[1] = "192.168.1.199"


$foo = Run(@SystemDir&"\ipconfig.exe", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($foo)
$text=StdoutRead($foo)
$text=StringTrimLeft($text, StringInStr($text, "Subnet Mask")+35)
$text=StringLeft($text, StringInStr($text, " ")-4)



if StringLen($text) < 8 then $text = "255.255.255.0"

Dim $SetSubnetmask[2]
$SetSubnetmask[0] = $text
$SetSubnetmask[1] = "255.255.255.0"


$objWMIService = ObjGet("winmgmts:\" & "." & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", 0x10 + 0x20)
$colComputers = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
If IsObj($colItems) Then
        For $objNetAdapter In $colItems
                $objNetAdapter.EnableStatic($SetIPAddress, $SetSubnetmask)
        Next
EndIf

runwait(@ComSpec&" /c ipconfig&pause")

Dim $SetIPAddress[1]
$SetIPAddress[0] = $ip1

Dim $SetSubnetmask[1]
$SetSubnetmask[0] = $text
$objWMIService = ObjGet("winmgmts:\" & "." & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", 0x10 + 0x20)
$colComputers = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
If IsObj($colItems) Then
        For $objNetAdapter In $colItems
                $objNetAdapter.EnableStatic($SetIPAddress, $SetSubnetmask)
        Next
EndIf
runwait(@ComSpec&" /c ipconfig&pause")
发表于 2010-8-23 12:15:53 | 显示全部楼层
谢谢 你正是及时雨
收下学习!!!!
发表于 2010-8-23 12:26:35 | 显示全部楼层
还漏了网关哈
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-15 07:47 , Processed in 0.064398 second(s), 13 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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