Function ModifyIP() strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objSWbemObjectSet = objSWbemServices.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where Description='" & Combo1.Text & "'")
For Each objNetAdapter In colNetAdapters sip = objNetAdapter.IPaddress(0)
If Option1.Value = True Then 'DHCP is enabled
objNetAdapter.EnableDHCP
errDNS = objNetAdapter.SetDNSServerSearchOrder()
Else strIPAddress = Array(Text1.Text)
strSubnetMask = Array(Text2.Text)
strGateway = Array(Text3.Text)
strGatewaymetric = Array(1)
StrDns = Array(Text4.Text, Text5.Text)
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
errDNS = objNetAdapter.SetDNSServerSearchOrder(StrDns)
'Exit For '只修改第一个网卡的设置
End If Next End Function
--------------------next---------------------
阅读(440) | 评论(0) | 转发(0) |