吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 7217|回复: 15
收起左侧

[其他转载] VBS之改IP配置

[复制链接]
ipqfhvk 发表于 2012-7-9 14:59
终于成为会员,注册了52.关注很久了。
自己发一个用WMI VBS写的改IP配置工具
各位见笑了
需要的拿去吧,喜欢VBS的简单 IP SET.rar (1.88 KB, 下载次数: 165)

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

287166966 发表于 2012-7-9 15:03
无图无真相,,,,拿出你的能力吧!
fyll 发表于 2012-7-9 15:11
Demo 发表于 2012-7-9 15:12
 楼主| ipqfhvk 发表于 2012-7-9 16:02
哦,没想到还是被鄙视了,好吧。直接贴源码
源码如下,复制后另存为IP SET.VBS即可

------------------
On Error Resume Next
Set moWindow=WScript.CreateObject("InternetExplorer.Application", "IE_")
moWindow.Navigate2 "about:blank"
With moWindow.Document.ParentWindow

.Document.Write "<input type='button' value='一键修改网关192.168.0.1' name='Button'/></br>"

.Document.Write "<input type='button' value='一键修改网关192.168.1.1' name='Button2'/></br>"

.Document.Write "<input type='text' size='30' name='ip'/><input type='text' size='30' name='xip'/></br>"

.Document.Write "<input type='text' size='30' name='mac'/><input type='text' size='30' name='xmac'/></br>"

.Document.Write "<input type='text' size='30' name='dhcp'/><input type='text' size='30' name='xdhcp'/></br>"

.Document.Write "<input type='text' size='30' name='IPGateway'/><input type='text' size='30' name='xIPGateway'/></br>"

.Document.Write "<input type='text' size='30' name='IPSubnet'/><input type='text' size='30' name='xIPSubnet'/></br>"

.Document.Write "<input type='text' size='30' name='DNS1'/><input type='text' size='30' name='xDNS1'/></br>"

.Document.Write "<input type='text' size='30' name='DNS2'/><input type='text' size='30' name='xDNS2'/></br>"

.Document.Write "<input type='button' value='自定义修改IP网关DNS等' name='IPset'/></br><body background='//1.jpg'><body bgcolor='#0000'></br></br></br>"

.Document.Write "<input type='button' value='  一键获取本机设置    ' name='getip'/></br>"

.MoveTo .Screen.AvailWidth/2-140,.Screen.AvailHeight/2-225

.ResizeTo 280,650

.Document.Title="沈寂 高级IP修改器 QQ:312782705"

End With

moWindow.Document.Close

With moWindow

.FullScreen=0

.MenuBar=0

.AddressBar=0

.ToolBar=0

.StatusBar=0

.Resizable=0

.Visible=1

Set Form=.Document.All

Set .Document.All.Button.onClick=GetRef("Button_onClick")

Set .Document.All.Button2.onClick=GetRef("Button2_onClick")

Set .Document.All.IPset.onClick=GetRef("IPset_onClick")

Set .Document.All.getip.onClick=GetRef("getip_onClick")

End With

mbFinished=False

Do Until mbFinished

WScript.Sleep 50

Loop

'____________________________________________________________________________退出代码

Sub IE_onQuit

mbFinished=True

End Sub

'____________________________________________________________________________自定义1

Sub Button_onClick

xiugaiip "192.168.0.174","192.168.0.1","255.255.255.0","202.96.199.133","61.151.246.246"

End Sub

'____________________________________________________________________________自定义2

Sub Button2_onClick

xiugaiip "192.168.1.74","192.168.1.1","255.255.255.0","202.96.199.132","202.96.209.5"

End Sub

''____________________________________________________________________________自定义修改IP

Sub IPset_onClick

if (moWindow.Document.All.IPset.value="填写好了,确定修改") then

msgbox "123"

xiugaiip moWindow.Document.All.xip.value,moWindow.Document.All.xIPGateway.value,moWindow.Document.All.xIPSubnet.value,moWindow.Document.All.xDNS1.value,moWindow.Document.All.xDNS1.value

else

moWindow.Document.ParentWindow.ResizeTo 580,450

getip_onClick

msgbox "左边为本机原始设置,请在右边填写你修改后的设置",,"提示"

moWindow.Document.All.IPset.value="填写好了,确定修改"

end if

End Sub

'____________________________________________________________________________获取本机设置

Sub getip_onClick

Dim objWMIService,colItems,objItem,objAddress

Set bjWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")

Set colItems =bjWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objItem in colItems

For Each objAddress in objItem.IPAddress

  If objAddress <> "" then

  IP = objAddress  'IP地址

  mac =objItem.MACAddress 'MAC地址

  DHCPEnabled=objItem.DHCPEnabled  '是否启用DHCP

  DefaultIPGateway=objItem.DefaultIPGateway(0) '网关

  IPSubnet=objItem.IPSubnet(0) '子网掩码

  DNSServerSearchOrder1=objItem.DNSServerSearchOrder(0) 'DNS设置1

  DNSServerSearchOrder2=objItem.DNSServerSearchOrder(1) 'DNS设置2

  Exit For

End If  

Next

Exit For

Next

moWindow.Document.All.ip.value="IP地址是:" & ip

moWindow.Document.All.xip.value=ip

moWindow.Document.All.mac.value="MAC地址是::" & mac

moWindow.Document.All.xmac.value="不能修改"

moWindow.Document.All.dhcp.value="是否启用DHCP:" & DHCPEnabled

moWindow.Document.All.xdhcp.value="不能修改"

moWindow.Document.All.IPGateway.value="网关是:" & DefaultIPGateway

moWindow.Document.All.xIPGateway.value=DefaultIPGateway

moWindow.Document.All.IPSubnet.value="子网掩码是:" & IPSubnet

moWindow.Document.All.xIPSubnet.value=IPSubnet

moWindow.Document.All.DNS1.value="DNS1:" & DNSServerSearchOrder1

moWindow.Document.All.xDNS1.value=DNSServerSearchOrder1

moWindow.Document.All.DNS2.value="DNS2:" & DNSServerSearchOrder2

moWindow.Document.All.xDNS2.value=DNSServerSearchOrder2

End Sub

'____________________________________________________________________________自定义修改函数

Function xiugaiip(ip,IPGateway,IPSubnet,DNS1,DNS2)

STR_GATEWAY = IPGateway

STR_NEWDNS1 = DNS1

STR_NEWDNS2 = DNS2

STR_IP = ip

STR_zwym=IPSubnet

Set fs=CreateObject("Scripting.FileSystemObject")

strWinMgmt="winmgmts:{impersonationLevel=impersonate}"

Set objNICs = GetObject( strWinMgmt ).InstancesOf("Win32_NetworkAdapterConfiguration")

For Each objNIC In objNICs

If objNIC.IPEnabled Then

objNIC.SetDNSServerSearchOrder Array(STR_NEWDNS1,STR_NEWDNS2)

objNIC.SetGateways Array(STR_GATEWAY)

End If

Next

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=True")

strIPAddress = Array(STR_IP)

strSubnetMask = Array(IPSubnet)

For Each objNetAdapter in colNetAdapters

errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)

Next

msgbox "已经设置为" & vbcrlf & "网关:" & IPGateway & vbcrlf & "ip地址:" & ip & vbcrlf & "子网掩码:" & IPSubnet & vbcrlf & "DNS1:" & DNS1 & vbcrlf & "DNS2:" &DNS2,,"提示"

end Function
乱码 发表于 2012-7-9 16:54
On Error Resume Next
Set
moWindow=WScript.CreateObject("InternetExplorer.Application", "IE_")
moWindow.Navigate2
"about:blank"
With moWindow.Document.ParentWindow
    .Document.Write
"<input type='button' value='一键修改网关192.168.0.1' name='Button'/></br>"
   
.Document.Write "<input type='button' value='一键修改网关192.168.1.1' name='Button2'/></br>"
   
.Document.Write "<input type='text' size='30' name='ip'/><input type='text' size='30' name='xip'/></br>"
   
.Document.Write "<input type='text' size='30' name='mac'/><input type='text' size='30' name='xmac'/></br>"
   
.Document.Write "<input type='text' size='30' name='dhcp'/><input type='text' size='30' name='xdhcp'/></br>"
   
.Document.Write "<input type='text' size='30' name='IPGateway'/><input type='text' size='30' name='xIPGateway'/></br>"
   
.Document.Write "<input type='text' size='30' name='IPSubnet'/><input type='text' size='30' name='xIPSubnet'/></br>"
   
.Document.Write "<input type='text' size='30' name='DNS1'/><input type='text' size='30' name='xDNS1'/></br>"
   
.Document.Write "<input type='text' size='30' name='DNS2'/><input type='text' size='30' name='xDNS2'/></br>"
   
.Document.Write "<input type='button' value='自定义修改IP网关DNS等' name='IPset'/></br><body background='//1.jpg'><body bgcolor='#0000'></br></br></br>"
   
.Document.Write "<input type='button' value='  一键获取本机设置    ' name='getip'/></br>"
   
.MoveTo .Screen.AvailWidth/2-140,.Screen.AvailHeight/2-225
   
.ResizeTo 280,650
   
.Document.Title="沈寂 高级IP修改器 QQ:312782705"
End With

moWindow.Document.Close

With moWindow
    .FullScreen=
0
   
.MenuBar=0
   
.AddressBar=0
   
.ToolBar=0
   
.StatusBar=0
   
.Resizable=0
   
.Visible=1
   
Set Form=.Document.All
   
Set .Document.All.Button.onClick=GetRef("Button_onClick")
   
Set .Document.All.Button2.onClick=GetRef("Button2_onClick")
   
Set .Document.All.IPset.onClick=GetRef("IPset_onClick")
   
Set .Document.All.getip.onClick=GetRef("getip_onClick")
End With

mbFinished=False

Do Until
mbFinished
    WScript.Sleep
50
Loop

'____________________________________________________________________________退出代码
Sub IE_onQuit
    mbFinished=
True
End Sub

'____________________________________________________________________________自定义1
Sub Button_onClick
    xiugaiip
"192.168.0.174","192.168.0.1","255.255.255.0","202.96.199.133","61.151.246.246"
End Sub

'____________________________________________________________________________自定义2
Sub Button2_onClick
    xiugaiip
"192.168.1.74","192.168.1.1","255.255.255.0","202.96.199.132","202.96.209.5"
End Sub

''____________________________________________________________________________自定义修改IP
Sub IPset_onClick
   
If (moWindow.Document.All.IPset.value="填写好了,确定修改") Then
        
MsgBox "123"
        
xiugaiip moWindow.Document.All.xip.value,moWindow.Document.All.xIPGateway.value,moWindow.Document.All.xIPSubnet.value,moWindow.Document.All.xDNS1.value,moWindow.Document.All.xDNS1.value
   
Else
        
moWindow.Document.ParentWindow.ResizeTo 580,450
        
getip_onClick
        MsgBox
"左边为本机原始设置,请在右边填写你修改后的设置",,"提示"
        
moWindow.Document.All.IPset.value="填写好了,确定修改"
   
End If
End Sub

'____________________________________________________________________________获取本机设置
Sub getip_onClick
   
Dim objWMIService,colItems,objItem,objAddress
   
Set bjWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
   
Set colItems =bjWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
   
For Each objItem In colItems
        
For Each objAddress In objItem.IPAddress
            
If objAddress <> "" Then
               
IP = objAddress  
'IP地址
               
mac =objItem.MACAddress 'MAC地址
               
DHCPEnabled=objItem.DHCPEnabled  '是否启用DHCP
               
DefaultIPGateway=objItem.DefaultIPGateway(0) '网关
               
IPSubnet=objItem.IPSubnet(0) '子网掩码
               
DNSServerSearchOrder1=objItem.DNSServerSearchOrder(0) 'DNS设置1
               
DNSServerSearchOrder2=objItem.DNSServerSearchOrder(1) 'DNS设置2
               
Exit For
            End If
        Next
        Exit For
    Next
   
moWindow.Document.All.ip.value="IP地址是:" & ip
    moWindow.Document.All.xip.value=ip
    moWindow.Document.All.mac.value=
"MAC地址是::" & mac
    moWindow.Document.All.xmac.value=
"不能修改"
   
moWindow.Document.All.dhcp.value="是否启用DHCP:" & DHCPEnabled
    moWindow.Document.All.xdhcp.value=
"不能修改"
   
moWindow.Document.All.IPGateway.value="网关是:" & DefaultIPGateway
    moWindow.Document.All.xIPGateway.value=DefaultIPGateway
    moWindow.Document.All.IPSubnet.value=
"子网掩码是:" & IPSubnet
    moWindow.Document.All.xIPSubnet.value=IPSubnet
    moWindow.Document.All.DNS1.value=
"DNS1:" & DNSServerSearchOrder1
    moWindow.Document.All.xDNS1.value=DNSServerSearchOrder1
    moWindow.Document.All.DNS2.value=
"DNS2:" & DNSServerSearchOrder2
    moWindow.Document.All.xDNS2.value=DNSServerSearchOrder2
End Sub

'____________________________________________________________________________自定义修改函数
Function xiugaiip(ip,IPGateway,IPSubnet,DNS1,DNS2)
    STR_GATEWAY = IPGateway
    STR_NEWDNS1 = DNS1
    STR_NEWDNS2 = DNS2
    STR_IP = ip
    STR_zwym=IPSubnet
   
Set fs=CreateObject("Scripting.FileSystemObject")
    strWinMgmt=
"winmgmts:{impersonationLevel=impersonate}"
   
Set objNICs = GetObject( strWinMgmt ).InstancesOf("Win32_NetworkAdapterConfiguration")
   
For Each objNIC In objNICs
        
If objNIC.IPEnabled Then
            
objNIC.SetDNSServerSearchOrder Array(STR_NEWDNS1,STR_NEWDNS2)
            objNIC.SetGateways Array(STR_GATEWAY)
        
End If
    Next
   
strComputer = "."
   
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
   
Set colNetAdapters = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=True")
    strIPAddress = Array(STR_IP)
    strSubnetMask = Array(IPSubnet)
   
For Each objNetAdapter In colNetAdapters
        errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
   
Next
   
MsgBox "已经设置为" & vbCrLf & "网关:" & IPGateway & vbCrLf & "ip地址:" & ip & vbCrLf & "子网掩码:" & IPSubnet & vbCrLf & "DNS1:" & DNS1 & vbCrLf & "DNS2:" &DNS2,,"提示"
End Function

帮你整理了一下代码、、
IE对象玩的这么溜,为什么不用HTA呢,要知道,现在用IE浏览器的不多了、、
如果代码是你写的,建议改成HTA,不是你写的,网上有很多,你找个HTA版的发上来好了、
别见怪,我是有啥说啥的人,没针对你、、


q5293435 发表于 2012-7-9 17:20
看看吧!学习下
 楼主| ipqfhvk 发表于 2012-7-22 22:29
乱码 发表于 2012-7-9 16:54
帮你整理了一下代码、、
IE对象玩的这么溜,为什么不用HTA呢,要知道,现在用IE浏览器的不多了、、
如果 ...

这些代码完全是自己手写的啊。只是用了一个工具
mereoywy 发表于 2012-9-25 13:20
至此比较喜欢这个东西!谢谢楼主!
fkhhkf 发表于 2013-2-3 15:42
好东西,感谢楼主
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-20 11:22

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表