[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] 请教用VBS作一个修改IP的脚本

请教用VBS作一个修改IP的脚本
1.有交互界面,可以手动输入IP地址
2.掩码默认填写24位,但可修改
3.网关跟随IP前三位,最后一位默认为1,但可修改
4.DNS默认114.114.114.114但可修改。

是不是条件有点多啊。请问可实现吗?

回复 1# edison_zhu
你这种 最好还是有偿的好 会有人帮助你的。

TOP

刚好我写了个片断,给你参考加个IE界面再改改应该可以做出来:
  1. Function Chenge_IP(ip)'设置ip,数组中(0-3)为IP,ip(4-7)为掩码ip(8-11)为网关ip(12-19)为DNS
  2.   if UBound(ip)>12 then
  3.       dim DNSServer(1),DNSServer2(0)
  4.       if UBound(ip)>16 then
  5.           DNSServer(1)=ip(16)&"."&ip(17)&"."&ip(18)&"."&ip(19)'Array("DNS1","DNS2")设置DNS服务器
  6.           DNSServer(0)=ip(12)&"."&ip(13)&"."&ip(14)&"."&ip(15)
  7.       else
  8.           DNSServer(0)=ip(12)&"."&ip(13)&"."&ip(14)&"."&ip(15)
  9.           DNSServer2(0)=DNSServer(0)'Array("DNS1","DNS2")设置DNS服务器
  10.       end if
  11.   end if
  12.   if UBound(ip)<5 then
  13.       redim ip(11)
  14.       ip(4)="255":ip(5)="255":ip(6)="255":ip(7)="0":ip(8)=ip(0):ip(9)=ip(1):ip(10)=ip(2):ip(11)="1"
  15.   end if
  16.   'join(array(DNSServer,str_name),"")
  17.   'DNSServer = Array("61.139.44.38", "61.139.2.69")
  18.   Set colNetAdapters=objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
  19.   For Each objNetAdapter in colNetAdapters
  20.     if ip(0)="AUTO" then
  21.         objNetAdapter.DHCPEnabled=true
  22.         if objNetAdapter.DHCPEnabled=true then Chenge_IP="已设为自动"
  23.     else
  24.         Chenge_IP=objNetAdapter.EnableStatic(Array(ip(0)&"."&ip(1)&"."&ip(2)&"."&ip(3)), Array(ip(4)&"."&ip(5)&"."&ip(6)&"."&ip(7)))'设置IP(0-3)和子网掩码(4-7)
  25.         Chenge_IP=objNetAdapter.SetGateways(Array(ip(8)&"."&ip(9)&"."&ip(10)&"."&ip(11)),Array("1"))'设置网关和跃点数
  26.         if UBound(ip)>16 then debug "16":Chenge_IP=objNetAdapter.SetDNSServerSearchOrder(DNSServer) '设置2个DNS
  27.         if UBound(ip)>12 and UBound(ip)<16 then debug "12":Chenge_IP=objNetAdapter.SetDNSServerSearchOrder(DNSServer2) '设置1个DNS
  28.         Chenge_IP="已设为手动IP"
  29.     end if
  30.   Next
  31.   Set colNetAdapters=nothing
  32. End Function
复制代码

TOP

返回列表