注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 服务器监控策略浅谈
 帮助

本地连接DNS修改器


2008-04-12 15:55:46
 标签:vbs 脚本   [推送到技术圈]

程序代码

Dim mc,mo,cnc,cuc,title,mymac,mydns,mydnsip
cnc = "网通" : cncdns="202.96.64.68"
cuc = "联通" : cucdns="211.93.80.129"
title = "本地连接DNS修改器"
Set mymac=GetObject("Winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each mydns In mymac
   If mydns.IPEnabled=True Then
     mydnsip = mydns.DNSServerSearchOrder
     For   i = 0 to UBound(mydnsip)
           strObj = strObj & mydnsip(i)
     next

         If strobj = cucdns Then
           newstr = "当前连接的DNS:"&Chr(10)&Chr(10)&cuc&":"&strobj&Chr(10)&Chr(10)&"是否修改为:"&Chr(10)&Chr(10)&cnc&":"&cncdns
           msg=MsgBox(newstr,1+32,title)
            
             If msg = 1 Then  
                 mydns.SetDNSServerSearchOrder Array(cncdns)
                 MsgBox "OK!修改成功!",48,title
             End If
        
         ElseIf strobj = cncdns Then
           newstr = "当前连接的DNS:"&Chr(10)&Chr(10)&cnc&":"&strobj&Chr(10)&Chr(10)&"是否修改为:"&Chr(10)&Chr(10)&cuc&":"&cucdns
           msg=MsgBox(newstr,1+32,title)
            
             If msg = 1 Then  
                 mydns.SetDNSServerSearchOrder Array(cucdns)
                 MsgBox "OK!修改成功!",48,title
             End If
    
         End If
      
     Exit For
   End If
Next
(转自http://www.rootkit.net.cn/article.asp?id=35
Change Gateway\DNS for vbs
Const T_GATEWAY = "1.1.1.1" '网关
Const T_NEWDNS1 = "2.2.2.2" 'DNS1
Const T_NEWDNS2 = "3.3.3.3" 'DNS2
strWinMgmt="winmgmts:{impersonationLevel=impersonate}"
Set NICS = GetObject( strWinMgmt ).InstancesOf("Win32_NetworkAdapterConfiguration")
For Each NIC In NICS
If NIC.IPEnabled Then
NIC.SetDNSServerSearchOrder Array(T_NEWDNS1,T_NEWDNS2)
NIC.SetGateways Array(T_GATEWAY)
End If
Next




    文章评论
 
 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: