最近朋友说他维护的一台电脑绑定了MAC-IP地址,但是每次关机之后,IP都会被设置成自动获取,需要重新手动指定IP之后才能使用。在GPT上撸了这么一个更改IP地址的脚本。在windows 10下测试通过
vbsOption Explicit On Error Resume Next Dim strIPAddress, strSubnetMask, strGateway, strDNSServerSearchOrder strIPAddress = Array("192.168.10.252") strSubnetMask = Array("255.255.255.0") strGateway = Array("192.168.10.254") strDNSServerSearchOrder = Array("114.114.114.114", "114.114.115.115") Dim objWMIService, colNetAdapters, objNetAdapter, intSetIP, intSetGateway, intSetDNS Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colNetAdapters = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") For Each objNetAdapter In colNetAdapters intSetIP = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask) intSetGateway = objNetAdapter.SetGateways(strGateway) intSetDNS = objNetAdapter.SetDNSServerSearchOrder(strDNSServerSearchOrder) Next