1,502
社区成员
发帖
与我相关
我的任务
分享
Function ModifyIP()
strComputer = "."
Set objWMIServiceGL = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIServiceGL.ExecQuery("Select * from Win32_NetworkAdapterConfiguration")
For Each objNetAdapter In colNetAdapters
strIPAddress = Array("192.168.1.107") 'IP地址
strSubnetMask = Array("255.255.255.0") '子网掩码
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
Exit For '只修改第一个网卡的设置
Next
End Function
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