au3 怎么才能添加多个IP?
au3 怎么才能添加多个IP?这个是修改1个IP,怎么才能在现有网卡,现有IP的基础上载加个IP地址啊
Dim $SetIPAddress
$Config_IPAddress = "10.1.1.1"
$Config_Subnetmask = "255.0.0.0"
$SetIPAddress = $Config_IPAddress
Dim $SetSubnetmask
$SetSubnetmask = $Config_Subnetmask
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer = "localhost"
$colItems = ""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\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
$objNetAdapter.EnableStatic($SetIPAddress, $SetSubnetmask)
;$objNetAdapter.SetGateways ($SetGateway)
;$objNetAdapter.SetDNSServerSearchOrder ($SetDns)
Next
EndIf
谢谢大家了,我急用啊!
Dim $SetIPAddress
$SetIPAddress = "192.168.1.198"
$SetIPAddress = "192.168.1.199"
Dim $SetSubnetmask
$SetSubnetmask = "255.255.255.0"
$SetSubnetmask = "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
多一个IP。必须再多一个掩码。
想设置多少个都可以。 本帖最后由 xsjtxy 于 2010-8-20 15:03 编辑
Dim $SetIPAddress
$SetIPAddress = "192.168.1.195"
$SetIPAddress = "192.168.1.196"
$SetIPAddress = "192.168.1.197"
$SetIPAddress = "192.168.1.198"
$SetIPAddress = "192.168.1.199"
Dim $SetSubnetmask
$SetSubnetmask = "255.255.255.0"
$SetSubnetmask = "255.255.255.0"
$SetSubnetmask = "255.255.255.0"
$SetSubnetmask = "255.255.255.0"
$SetSubnetmask = "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 那么我怎么设置第一IP,是本机默认IP,只修改第2个ip,第一IP默认不动,怎么写啊,谢谢了,我急用啊 帮人帮到头
Dim $SetIPAddress
$SetIPAddress = @IPAddress1
$SetIPAddress = "192.168.1.199"
Dim $SetSubnetmask
$SetSubnetmask = "255.255.255.0"
$SetSubnetmask = "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
现在是IP可以改了,子网掩码还得修改,怎么才能让第一个子网掩码变成默认的啊
Dim $SetIPAddress
$SetIPAddress = @IPAddress1
$SetIPAddress = "192.168.1.199"
Dim $SetSubnetmask
$SetSubnetmask = "255.255.255.0"
$SetSubnetmask = "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
$SetSubnetmask = "255.255.255.0"
啊 回复 7# bj17209
默认的是什么意思? WMI修改IP需要重启生效吗? 也就是,不修改机器本身的第一个IP和第一个ip的子网掩码啊,就修改第2个的ip和子网掩码啊,帮帮我啊,急用啊 获取子网可以通过ipconfig /all来。如果纯AU3无法获取的话 Dim $SetIPAddress
$SetIPAddress = @IPAddress1
$SetIPAddress = "192.168.1.199"
Dim $SetSubnetmask
$SetSubnetmask = "255.255.255.0" 怎么才能不用修改啊!!
$SetSubnetmask = "255.255.255.0"
就想IP1一样不用修改 本帖最后由 xsjtxy 于 2010-8-21 14:39 编辑
#include <Constants.au3>
Dim $SetIPAddress
$SetIPAddress = @IPAddress1
$SetIPAddress = "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
$SetSubnetmask = $text
$SetSubnetmask = "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
留脚印学习,感谢分享 学习了,IP地址添加
页:
[1]
2