恩,写了一段改IP的代码,用WMI来改的,
要管理员才行。我想干脆用Styme来运行好了。
下面是以前的代码,想在Styme下运行
#Region ;**** 参数创建于 AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <GuiIPAddress.au3>
$MainForm = GUICreate("IP Change - YangZB", 680, 190, @DesktopWidth / 2 - 680 / 2, @DesktopHeight / 3 - 190/3)
$LabSelectCard = GUICtrlCreateLabel("选择网卡:", 8, 8, 64,20, $SS_RIGHT)
$CmbCard = GUICtrlCreateCombo ("", 75, 5,525, 21, $CBS_DROPDOWNLIST)
$ButRefreshCard=GUICtrlCreateButton ("刷新",605,4,70,21,$BS_FLAT)
$GroupCurIP = GUICtrlCreateGroup("当前IP配置 ", 8, 30, 200, 150)
$LabCurIP = GUICtrlCreateLabel("I P 地址:", 16, 55, 64, 20, $SS_RIGHT)
$SysCurIP = _GUICtrlIpAddressCreate($MainForm, 90, 53, 110, 21, $WS_CHILD)
$LabCurMask = GUICtrlCreateLabel("子网掩码:", 16, 80, 64, 20, $SS_RIGHT)
$SysCurMask = _GUICtrlIpAddressCreate($MainForm, 90, 78, 110, 21, $WS_CHILD)
$LabCurGateway = GUICtrlCreateLabel("默认网关:",16, 105, 64, 20, $SS_RIGHT)
$SysCurGateway= _GUICtrlIpAddressCreate($MainForm, 90, 102, 110, 21, $WS_CHILD)
$LabCurPDNS = GUICtrlCreateLabel("首选 DNS:", 16, 130, 64, 20, $SS_RIGHT)
$SysCurPDNS= _GUICtrlIpAddressCreate($MainForm, 90, 128, 110, 21, $WS_CHILD)
$LabCurADNS = GUICtrlCreateLabel("备用 DNS:", 16, 155, 64, 20, $SS_RIGHT)
$SysCurADNS= _GUICtrlIpAddressCreate($MainForm, 90, 152, 110, 21, $WS_CHILD)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupNewIP = GUICtrlCreateGroup("IP设置 ",218, 30, 200, 150)
$LabNewIP = GUICtrlCreateLabel("I P 地址:", 226, 55, 64, 20, $SS_RIGHT)
$SysNewIP = _GUICtrlIpAddressCreate($MainForm, 300, 53, 110, 21, $WS_CHILD)
$LabNewMask = GUICtrlCreateLabel("子网掩码:", 226, 80, 64, 20, $SS_RIGHT)
$SysNewMask = _GUICtrlIpAddressCreate($MainForm, 300, 78, 110, 21, $WS_CHILD)
$LabNewGateway = GUICtrlCreateLabel("默认网关:",226 ,105, 64, 20, $SS_RIGHT)
$SysNewGateway= _GUICtrlIpAddressCreate($MainForm, 300, 102, 110, 21, $WS_CHILD)
$LabNewPDNS = GUICtrlCreateLabel("首选 DNS:", 226, 130, 64, 20, $SS_RIGHT)
$SysNewPDNS= _GUICtrlIpAddressCreate($MainForm, 300, 128, 110, 21, $WS_CHILD)
$LabNewADNS = GUICtrlCreateLabel("备用 DNS:", 226, 155, 64, 20, $SS_RIGHT)
$SysNewADNS= _GUICtrlIpAddressCreate($MainForm, 300, 152, 110, 21, $WS_CHILD)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupSelectIP = GUICtrlCreateGroup("IP配置表 ",428, 30, 245, 150)
$ButSetIP = GUICtrlCreateButton("切换配置", 600, 45, 65, 28, $BS_FLAT)
$ButEditIP = GUICtrlCreateButton("修改配置", 600, 78, 65, 28, $BS_FLAT)
$ButAddIP = GUICtrlCreateButton("添加配置", 600 ,111, 65, 28, $BS_FLAT)
$ButDeleteIP = GUICtrlCreateButton("删除配置", 600, 144, 65, 28, $BS_FLAT)
$LstSelectIP = GUICtrlCreateList("", 435, 45, 160, 135)
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
If $SectionNames <> 1 Then
For $i = 1 To $SectionNames[0]
GUICtrlSetData($LstSelectIP, $SectionNames[$i], $SectionNames[1])
Next
Else
Dim $SectionNames[2]
$SectionNames[1] = ""
EndIf
GUICtrlCreateGroup("", -99, -99, 1, 1)
_GetCard()
_CurrentIPConfig()
_ShowSelectIP(GUICtrlRead($LstSelectIP))
GUICtrlSetState($SysCurIP,$GUI_DISABLE)
GUISetState()
#EndRegion ### END Koda GUI section ###
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MainForm, "int", 500, "long", 0x00090000)
Exit
Case $ButRefreshCard
_GetCard()
Case $CmbCard
_CurrentIPConfig()
Case $LstSelectIP
$SectionNames = GUICtrlRead($LstSelectIP)
_ShowSelectIP($SectionNames)
Case $ButAddIP
_AddIP()
Case $ButEditIP
$SectionNames = GUICtrlRead($LstSelectIP)
_UpDateIP($SectionNames)
Case $ButDeleteIP
$SectionNames = GUICtrlRead($LstSelectIP)
_DeleteIP($SectionNames)
$SectionNames = GUICtrlRead($LstSelectIP)
_ShowSelectIP($SectionNames)
Case $ButSetIP
$SectionNames = GUICtrlRead($LstSelectIP)
$StrCardName=GUICtrlRead ($CmbCard)
_SetIp($SectionNames,$StrCardName)
EndSwitch
WEnd
Func _GetCard() ;取得网卡列表
Local $strComputer = "."
Local $wbemFlagReturnImmediately = 0x10,$wbemFlagForwardOnly = 0x20
Local $StrCrad ="",$strCradOne=""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colNIC = $objWMIservice.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", $wbemFlagReturnImmediately + _
$wbemFlagForwardOnly)
$colItemName = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", 0x30)
For $objCard In $colNIC
For $objName In $colItemName
If $objName.Index = $objCard.Index Then
if $StrCrad="" Then
$StrCrad=$objName.NetConnectionID
$strCradOne=$objName.NetConnectionID
Else
$StrCrad= $StrCrad & "|" & $objName.NetConnectionID
EndIf
ExitLoop
EndIf
Next
Next
GUICtrlSetData ($CmbCard,"")
GUICtrlSetData ($CmbCard,$StrCrad,$strCradOne)
EndFunc
Func _CurrentIPConfig() ;显示当前IP方案
$StrCardName=GUICtrlRead ($CmbCard)
If StringIsSpace ($StrCardName) or $StrCardName="" Then
_GUICtrlIpAddressSet($SysCurIP, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurMask, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurGateway,"0.0.0.0")
_GUICtrlIpAddressSet($SysCurPDNS, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurADNS, "0.0.0.0")
Else
Local $strComputer = "."
local $CardIndex=-1
Local $wbemFlagReturnImmediately = 0x10,$wbemFlagForwardOnly = 0x20
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItemName = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter Where NetConnectionID='" & $StrCardName & "'", "WQL", 0x30)
For $objName In $colItemName
If $objName.NetConnectionID = $StrCardName Then
$CardIndex=$objName.Index
ExitLoop
EndIf
Next
if $CardIndex =-1 Then
MsgBox(0,"选择网卡",'找不到网卡“' & $StrCardName & '”,请刷新网卡列表。' )
_GUICtrlIpAddressSet($SysCurIP, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurMask, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurGateway,"0.0.0.0")
_GUICtrlIpAddressSet($SysCurPDNS, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurADNS, "0.0.0.0")
Else
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE And Index='" & $CardIndex & "'" , "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
For $objItem In $colItems
if $objItem.Index= $CardIndex Then
$LocalIP = $objItem.IPAddress (0)
$LocalSubnetmask = $objItem.IPSubnet (0)
$LocalGateway = $objItem.DefaultIPGateway (0)
$LocalDns1 = $objItem.DNSServerSearchOrder (0)
$LocalDns2 = $objItem.DNSServerSearchOrder (1)
ExitLoop
EndIf
Next
_GUICtrlIpAddressSet($SysCurIP, $LocalIP)
_GUICtrlIpAddressSet($SysCurMask, $LocalSubnetmask)
_GUICtrlIpAddressSet($SysCurGateway, $LocalGateway)
_GUICtrlIpAddressSet($SysCurPDNS, $LocalDns1)
_GUICtrlIpAddressSet($SysCurADNS, $LocalDns2)
EndIf
EndIf
EndFunc
Func _ShowSelectIP($CurrentSectionName = "") ;显示IP配置方案 $CurrentSectionName:选中的配置方案名
GUICtrlSetData($GroupNewIP, "IP配置 - " & $CurrentSectionName , "")
$IPAddress = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "IPAddress", "")
$Subnetmask = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "SubnetMask", "")
$Gateway = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "Gateway", "")
Dim $Dns[2]
$Dns[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "DNSServer1", "")
$Dns[1] = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "DNSServer2", "")
_GUICtrlIpAddressSet($SysNewIP, $IPAddress)
_GUICtrlIpAddressSet($SysNewMask, $Subnetmask)
_GUICtrlIpAddressSet($SysNewGateway, $Gateway)
_GUICtrlIpAddressSet($SysNewPDNS, $Dns[0])
_GUICtrlIpAddressSet($SysNewADNS, $Dns[1])
EndFunc ;==>_ShowSelectIP
Func _AddIP() ;新增IP配置方案
$AddForm= GUICreate("添加IP配置", 225, 270, @DesktopWidth / 2 - 225 / 2, @DesktopHeight / 3 - 270 / 3, $WS_SYSMENU, $WS_EX_WINDOWEDGE, $MainForm)
$GroupAddIP = GUICtrlCreateGroup("新IP配置", 10, 15, 205, 175)
Local $index = 3
GUICtrlCreateLabel("I P 地址:", 20, 35, 60, 15)
$AddNewIP = _GUICtrlIpAddressCreate($AddForm, 80, 33, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("子网掩码:", 20, 60, 60, 15)
$AddNewMask = _GUICtrlIpAddressCreate($AddForm, 80, 57, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("默认网关:", 20, 85, 60, 15)
$AddNewGateway = _GUICtrlIpAddressCreate($AddForm, 80, 80, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("首选 DNS:", 20, 110, 60, 15)
$AddNewPDns = _GUICtrlIpAddressCreate($AddForm, 80, 105, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("备用 DNS:", 20, 135, 60, 15)
$AddNewADns = _GUICtrlIpAddressCreate($AddForm, 80, 130, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("配置名称", 20, 160, 60, 15)
$AddNewName = GUICtrlCreateInput("新IP配置", 80, 155, 125, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ButADD = GUICtrlCreateButton("添加", 10, 200, 60, 30)
$ButReset = GUICtrlCreateButton("重置", 83, 200, 60, 30)
$ButCancel = GUICtrlCreateButton("取消", 155, 200, 60, 30)
GUISetState()
While 1
$AddMsg = GUIGetMsg(1)
Switch $AddMsg[0]
Case $ButADD
$IPAddress = _GUICtrlIpAddressGet($AddNewIP)
$Subnetmask = _GUICtrlIpAddressGet($AddNewMask)
$Gateway = _GUICtrlIpAddressGet($AddNewGateway)
Dim $Dns[2]
$Dns[0] = _GUICtrlIpAddressGet($AddNewPDns)
$Dns[1] = _GUICtrlIpAddressGet($AddNewADns)
$NewSectionName = GUICtrlRead($AddNewName)
Dim $Configuration[5][2] = [ [ "IPAddress", $IPAddress ], [ "SubnetMask", $Subnetmask ], ["Gateway", $Gateway], ["DNSServer1", $Dns[0]], ["DNSServer2", $Dns[1]] ]
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
$flag = 1
If $SectionNames == 1 Then
IniWriteSection(@ScriptDir & "\IP Configlist.ini", $NewSectionName, $Configuration, 0)
ElseIf $SectionNames <> 1 Then
For $i = 1 To $SectionNames[0]
If $NewSectionName == $SectionNames[$i] Then
$selete = MsgBox(36, "确认配置替换", "配置“" & $NewSectionName & "”已存在,是否替换?")
If $selete == 6 Then
ExitLoop
ElseIf $selete <> 6 Then
$flag = 0
ExitLoop
EndIf
EndIf
Next
EndIf
If $flag = 0 Then
ContinueLoop
EndIf
IniWriteSection(@ScriptDir & "\IP Configlist.ini", $NewSectionName, $Configuration, 0)
GUICtrlSetData($LstSelectIP, "", "")
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
For $i = 1 To $SectionNames[0]
GUICtrlSetData($LstSelectIP, $SectionNames[$i], $NewSectionName)
Next
_ShowSelectIP($NewSectionName)
ExitLoop
Case $ButReset
_GUICtrlIpAddressSet($AddNewIP, "0.0.0.0")
_GUICtrlIpAddressSet($AddNewMask, "0.0.0.0")
_GUICtrlIpAddressSet($AddNewGateway, "0.0.0.0")
_GUICtrlIpAddressSet($AddNewPDns, "0.0.0.0")
_GUICtrlIpAddressSet($AddNewADns, "0.0.0.0")
GUICtrlSetData($AddNewName, "新IP配置")
ContinueLoop
Case $ButCancel
ExitLoop
Case $GUI_EVENT_CLOSE
If $AddMsg[1] == $AddForm Then
ExitLoop
EndIf
EndSwitch
WEnd
GUIDelete($AddForm)
If Not WinActive($MainForm) Then
WinActivate($MainForm)
EndIf
EndFunc ;==>_AddIP
Func _DeleteIP($DeleteSectionName = 0) ;删除IP配置方案 $DeleteSectionName:配置方案名
$selete = MsgBox(36, "确认删除", "确实要删除“" & $DeleteSectionName & "”IP配置吗?")
If $selete == 6 Then
IniDelete(@ScriptDir & "\IP Configlist.ini", $DeleteSectionName)
GUICtrlSetData($LstSelectIP, "", "")
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
If $SectionNames <> 1 Then
For $i = 1 To $SectionNames[0]
GUICtrlSetData($LstSelectIP, $SectionNames[$i], $SectionNames[$i])
Next
EndIf
EndIf
If Not WinActive($MainForm) Then
WinActivate($MainForm)
EndIf
EndFunc ;==>_DeleteIP
Func _UpDateIP($OldSectionName = "") ;更改IP配置方案 $OldSectionName:配置方案名
$IPAddress = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "IPAddress", "")
$Subnetmask = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "SubnetMask", "")
$Gateway = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "Gateway", "")
Dim $Dns[2]
$Dns[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "DNSServer1", "")
$Dns[1] = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "DNSServer2", "")
$UpDateForm = GUICreate("修改IP配置", 225, 270, @DesktopWidth / 2 - 225 / 2, @DesktopHeight / 3 - 270 / 3, $WS_SYSMENU, $WS_EX_WINDOWEDGE, $MainForm)
$GroupUpDateIP = GUICtrlCreateGroup($OldSectionName & "IP配置", 10, 15, 205, 175)
Local $index = 3
GUICtrlCreateLabel("I P 地址:", 20, 35, 60, 15)
$UpDateIP = _GUICtrlIpAddressCreate($UpDateForm, 80, 33, 125, 20, $WS_CHILD)
_GUICtrlIpAddressSet($UpDateIP, $IPAddress)
GUICtrlCreateLabel("子网掩码:", 20, 60, 60, 15)
$UpDateMask = _GUICtrlIpAddressCreate($UpDateForm, 80, 57, 125, 20, $WS_CHILD)
_GUICtrlIpAddressSet($UpDateMask, $Subnetmask)
GUICtrlCreateLabel("默认网关:", 20, 85, 60, 15)
$UpDateGateway = _GUICtrlIpAddressCreate($UpDateForm, 80, 80, 125, 20, $WS_CHILD)
_GUICtrlIpAddressSet($UpDateGateway, $Gateway)
GUICtrlCreateLabel("首选 DNS:", 20, 110, 60, 15)
$UpDatePDNS = _GUICtrlIpAddressCreate($UpDateForm, 80, 105, 125, 20, $WS_CHILD)
_GUICtrlIpAddressSet($UpDatePDNS, $Dns[0])
GUICtrlCreateLabel("备用 DNS:", 20, 135, 60, 15)
$UpDateADNS = _GUICtrlIpAddressCreate($UpDateForm, 80, 130, 125, 20, $WS_CHILD)
_GUICtrlIpAddressSet($UpDateADNS, $Dns[1])
GUICtrlCreateLabel("配置名称", 20, 160, 60, 15)
$UpDateName = GUICtrlCreateInput($SectionNames, 80, 155, 125, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ButEdit = GUICtrlCreateButton("修改", 10, 200, 60, 30)
$ButReset = GUICtrlCreateButton("重置", 83, 200, 60, 30)
$ButCancel = GUICtrlCreateButton("取消", 155, 200, 60, 30)
GUISetState()
While 1
$EditMsg = GUIGetMsg(1)
Switch $EditMsg[0]
Case $ButEdit
$IPAddress = _GUICtrlIpAddressGet($UpDateIP)
$Subnetmask = _GUICtrlIpAddressGet($UpDateMask)
$Gateway = _GUICtrlIpAddressGet($UpDateGateway)
$Dns[0] = _GUICtrlIpAddressGet($UpDatePDNS)
$Dns[1] = _GUICtrlIpAddressGet($UpDateADNS)
$NewSectionName = GUICtrlRead($UpDateName)
Dim $Configuration[5][2] = [ [ "IPAddress", $IPAddress ], [ "SubnetMask", $Subnetmask ], ["Gateway", $Gateway], ["DNSServer1", $Dns[0]], ["DNSServer2", $Dns[1]] ]
If ($OldSectionName <> $NewSectionName) And (Not IniRenameSection(@ScriptDir & "\IP Configlist.ini", $OldSectionName, $NewSectionName, 0)) Then
$selete = MsgBox(36, "确认配置替换", "配置“" & $NewSectionName & "”已存在,是否替换?")
If $selete == 6 Then
IniRenameSection(@ScriptDir & "\IP Configlist.ini", $OldSectionName, $NewSectionName, 1)
Else
ContinueLoop
EndIf
EndIf
IniWriteSection(@ScriptDir & "\IP Configlist.ini", $NewSectionName, $Configuration, 0)
GUICtrlSetData($LstSelectIP, "", "")
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
For $i = 1 To $SectionNames[0]
GUICtrlSetData($LstSelectIP, $SectionNames[$i], $NewSectionName)
Next
_ShowSelectIP($NewSectionName)
ExitLoop
Case $ButReset
_GUICtrlIpAddressSet($UpDateIP, $IPAddress)
_GUICtrlIpAddressSet($UpDateMask, $Subnetmask)
_GUICtrlIpAddressSet($UpDateGateway, $Gateway)
_GUICtrlIpAddressSet($UpDatePDNS, $Dns[0])
_GUICtrlIpAddressSet($UpDateADNS, $Dns[1])
GUICtrlSetData($UpDateName, $OldSectionName)
ContinueLoop
Case $ButCancel
ExitLoop
Case $GUI_EVENT_CLOSE
If $EditMsg[1] == $UpDateForm Then
ExitLoop
EndIf
EndSwitch
WEnd
GUIDelete($UpDateForm)
If Not WinActive($MainForm) Then
WinActivate($MainForm)
EndIf
EndFunc ;==>_UpDateIP
Func _SetIP($SectionNames = "",$StrCardName="") ;设置系统IP $SectionNames:选中的配置方案名 $StrCardName:选中的网卡名
Local $strComputer = "."
local $CardIndex=-1
Local $wbemFlagReturnImmediately = 0x10,$wbemFlagForwardOnly = 0x20
Dim $SetIPAddress[1]
$SetIPAddress[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "IPAddress", "")
Dim $SetSubnetmask[1]
$SetSubnetmask[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "SubnetMask", "")
Dim $SetGateway[1]
$SetGateway[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "Gateway", "")
Dim $SetDns[2]
$SetDns[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "DNSServer1", "")
$SetDns[1] = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "DNSServer2", "")
TrayTip("设置", "正在设置IP,请稍等...", 1)
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItemName = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter Where NetConnectionID='" & $StrCardName & "'", "WQL", 0x30)
For $objName In $colItemName
If $objName.NetConnectionID = $StrCardName Then
$CardIndex=$objName.Index
ExitLoop
EndIf
Next
if $CardIndex =-1 Then
MsgBox(0,"切换配置",'找不到网卡“' & $StrCardName & '”,请刷新网卡列表。' )
TrayTip("错误", '未找到网卡“' & $StrCardName & @CRLF & '”,IP配置更改失败。', 1)
Else
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE And Index='" & $CardIndex & "'" , "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objNetAdapter In $colItems
$objNetAdapter.EnableStatic ($SetIPAddress, $SetSubnetmask)
$objNetAdapter.SetGateways ($SetGateway)
$objNetAdapter.SetDNSServerSearchOrder ($SetDns)
Next
EndIf
TrayTip("IP设置完成","I P 地址:" & $SetIPAddress[0] & @CRLF & "子网掩码:" & $SetSubnetmask[0] & @CRLF & "网 关:" _
& $SetGateway[0] & @CRLF & "首选 DNS:" & $SetDns[0] & @CRLF & "备用 DNS:" & $SetDns[1], 1)
_CurrentIPConfig()
Endif
EndFunc ;==>_SetIP |