本帖最后由 xsjtxy 于 2010-8-21 14:39 编辑 #include <Constants.au3>
Dim $SetIPAddress[2]
$SetIPAddress[0] = @IPAddress1
$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
|