Dim IP
Ip=Inputbox("请输入IP")
strSubnetMask=Array("255.255.255.0")
DefaultIPGateway=Array("192.168.2.253")
DNSServer=Array("61.139.2.69")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress=Array(Ip)
For Each objNetAdapter in colNetAdapters
errEnable=objNetAdapter.EnableStatic(strIPAddress, strSubnetMask,DefaultIPGateway,DNSServer)
Ip=Inputbox("请输入IP")
strSubnetMask=Array("255.255.255.0")
DefaultIPGateway=Array("192.168.2.253")
DNSServer=Array("61.139.2.69")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress=Array(Ip)
For Each objNetAdapter in colNetAdapters
errEnable=objNetAdapter.EnableStatic(strIPAddress, strSubnetMask,DefaultIPGateway,DNSServer)
Next
本文转自 luoguo 51CTO博客,原文链接:http://blog.51cto.com/luoguoling/1183897