程序代码

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
(转自 [url]http://www.rootkit.net.cn/article.asp?id=35[/url])
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
转自( [url]http://hi.baidu.com/vbs_zone/blog/item/55645408f665e1d262d986d1.html[/url])