回复 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")
|