使用脚本自动修改ip设置

王朝c#·作者佚名  2006-12-17
窄屏简体版  字體: |||超大  

应该也没有问题。如果需要经常切换网关,或是ip,这个脚本是最方便的了。稍微修改一下甚至可以做到1分钟变一次ip。

"."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set colNetAdapters = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")For Each objNetAdapter in colNetAdapterssip=objNetAdapter.IPAddressstrIPAddress = sip '保持原来的ip,如果需要修改ip为192.168.0.200:strIPAddress = Array("192.168.0.200")strSubnetMask = Array("255.255.255.0")strGateway = Array("192.168.0.254") '修改网关为192.168.0.254strGatewayMetric = Array(1) errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask) errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric) If errEnable = 0 Then WScript.Echo "The IP address has been changed." Else WScript.Echo "The IP address could not be changed." End If exit for '只修改第一个网卡的设置Next

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航