返回列表 发帖

[转贴] VBS版本地连接DNS修改器

家里终于装上宽带了,联通的小区宽带,让我郁闷的是公司的宽带是网通的,虽然家里的路由按照公司的来配置了,但是每次都要修改DNS是个问题啊。用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
NextCOPY


http://www.rootkit.net.cn/article.asp?id=35

返回列表