Hack Forums
[.NET] Vbscript DNS Server IP Changer - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Vbscript DNS Server IP Changer (/showthread.php?tid=4306809)



Vbscript DNS Server IP Changer - DuguWudi - Jun 26, 2014

This is one of the oldest vbscript example in the internet, similar/same examples alot from different sites. I got it from here


Code
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrDNSServers = Array("8.8.8.8", "8.8.4.4")
    objNetCard.SetDNSServerSearchOrder(arrDNSServers)
Next


You change the dns server ip "("8.8.8.8", "8.8.4.4")", to your own isp dns/etc and save it to different script names eg. google.vbs, opendns.vbs etc.

I use it often, one for google and another one is my isp dns, so when one breakdown, I just double click the other dns script, and I can still surf the internet.🤣


* - zeroexp - Jun 26, 2014

Sorry but.. why are you posting it here if it's all over the internet and it's old... ?
Btw... i don't think vbs scripts are really related to VB.NET ...
Anyways, i guess.. Thanks for the share :P


* - DuguWudi - Jun 26, 2014

I posted here in case someone needs it, my isp dns just breakdown again(as usual), I'm using google dns to access HF now.