看上去是命令行写的有问题
#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <ComboConstants.au3>
#include <GuiStatusBar.au3>
#include <Array.au3>
#Region ### START Koda GUI section ###Form=
Global Const $aArray = GetAdapterProperty()
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Button1 = GUICtrlCreateButton("确定", 440, 328, 75, 25)
$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 96, 128, 130, 21) ;80
_GUICtrlIpAddress_Set($IPAddress1, "192.168.0.0")
$IPAddress2 = _GUICtrlIpAddress_Create($Form1, 96, 176, 130, 21) ;128
_GUICtrlIpAddress_Set($IPAddress2, "255.255.255.0")
$IPAddress3 = _GUICtrlIpAddress_Create($Form1, 96, 224, 130, 21) ;176
_GUICtrlIpAddress_Set($IPAddress3, "192.168.0.0")
$IPAddress4 = _GUICtrlIpAddress_Create($Form1, 96, 264, 130, 21) ;224
_GUICtrlIpAddress_Set($IPAddress4, "192.168.0.1")
$IPAddress5 = _GUICtrlIpAddress_Create($Form1, 96, 304, 130, 21) ;264
_GUICtrlIpAddress_Set($IPAddress5, "192.168.0.2")
$Combo1 = GUICtrlCreateCombo("请下拉选择网卡", 25, 90, 280, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
$aaa = _ArrayToString($aArray)
;_ArrayDisplay($aArray)
GUICtrlSetData($Combo1, $aaa)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$ipset = GUICtrlRead($Combo1)
$ip = _GUICtrlIpAddress_Get($IPAddress1)
$ym = _GUICtrlIpAddress_Get($IPAddress2)
$wg = _GUICtrlIpAddress_Get($IPAddress3)
$dns = _GUICtrlIpAddress_Get($IPAddress4)
$dns1 = _GUICtrlIpAddress_Get($IPAddress5)
;MsgBox(64,"ok",$ip)
;MsgBox(64,"ok",$ipset)
RunWait(@ComSpec & ' /c netsh interface ip set address "' & $ipset & '" static' & " " & $ip & " " & $ym & " " & $wg & " " & 'gwmetric=1', '', @SW_HIDE)
RunWait('netsh interface ip set dns name = "' & $ipset & '" source = static addr = ' & $dns & ' register = PRIMARY', "c:\windows\system32", @SW_HIDE)
RunWait('netsh interface ip add dns name = "' & $ipset & '" addr = ' & $dns1 & ' index=2', "c:\windows\system32", @SW_HIDE)
;MsgBox(64,"ok",$ipset)
EndSwitch
WEnd
Func GetAdapterProperty()
Local $objShare
Local $objEveryColl
$objShare = ObjCreate("HNetCfg.HNetShare.1")
If Not IsObj($objShare) Then Return
$objEveryColl = $objShare.EnumEveryConnection
If Not IsObj($objEveryColl) Then Return
Local $objNetConn, $objShareCfg, $objNCProps, $str
Local $aProps[0][5]
For $objNetConn In $objEveryColl
$objShareCfg = $objShare.INetSharingConfigurationForINetConnection($objNetConn)
If IsObj($objShareCfg) Then
$objNCProps = $objShare.NetConnectionProps($objNetConn)
If IsObj($objNCProps) Then
ReDim $aProps[UBound($aProps) + 1][2]
$aProps[UBound($aProps) - 1][0] = $objNCProps.Name
EndIf
EndIf
Next
Return $aProps
EndFunc ;==>GetAdapterProperty
|