ipconfig.vbs

on error resume next
strComputer = InputBox("请输入计算机名或者IP地址", "输入")
'strcomputer="."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress =array( InputBox("请输入更换成的IP地址", "输入"))
strSubnetMask =array( "255.255.255.0")
strGateway = array("192.168.1.1")
strDNSServer= Array("202.96.128.86")

For Each objNetAdapter in colNetAdapters
intSetDNSServers = objNetAdapter.SetDNSServerSearchOrder(strDNSServer)
errGateways = objNetAdapter.SetGateways(strGateway)
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
If errEnable = 0 Then
WScript.Echo "The IP configruation has been changed."
Else
WScript.Echo "The IP configruation could not be changed."
End If
Next

你可能感兴趣的:(config)