最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
使用脚本自动修改ip设置
时间:2022-07-02 18:02:39 编辑:袖梨 来源:一聚教程网
vbs脚本的功能非常强大, 管理系统简单方便!下面的脚本win2000和winxp都可以使用,win2003没有测试过,应该也没有问题。如果需要经常切换网关,或是ip,这个脚本是最方便的了。稍微修改一下甚至可以做到1分钟变一次ip。
changeip.vbsstrComputer = "."
Set objWMIService = GetObject("winmgmts:" & strComputer & "ootcimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
sip=objNetAdapter.IPAddress
strIPAddress = 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.254
strGatewayMetric = 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
changeip.vbsstrComputer = "."
Set objWMIService = GetObject("winmgmts:" & strComputer & "ootcimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
sip=objNetAdapter.IPAddress
strIPAddress = 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.254
strGatewayMetric = 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
相关文章
- 幻兽帕鲁饲料箱怎么做 饲料箱制造方法介绍 07-31
- 燕云十六声天泉地位怎么晋升 天泉门派晋升方法 07-31
- 明末渊虚之羽龟纽金宝有什么用 龟纽金宝用途介绍 07-31
- 幻兽帕鲁怎么去掉无用词条 去掉无用词条方法介绍 07-31
- 人渣SCUM未安装EasyAntiCheat启动错误如何解决 解决方法一览 07-31
- 明末渊虚之羽羽族遗骸有什么用 羽族遗骸获取位置介绍 07-31