Hey this is pretty nice. A simple batch DNS changer. Below I've attached a version with several other DNS servers attached.
I'm sure there's a reason you used the registry to apply these DNS changes, but it isn't working with me, so I went ahead and did the following.
I rewrote it below with more DNS services, switched the method of application to netsh instead of registry, added an admin check as well as ensured support for Windows 10. I've currently only got it setup to work with the main "Local Area Connection" interface and "Ethernet" interface.
For Windows XP through Windows 7:
Code:
@title DNS Changer by privateloader
@echo off
REM Other DNS thrown in there by Zorrophreak on SL
REM I also changed the way DNS is changed
mode con:cols=53 lines=12
REM I intend to allow the script to automatically search for interfaces but for right now it is defined as variable if.
set if=Local Area Connection
:checkadmin
cls
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
goto a
) else (
echo .....................................................
echo .....................................................
echo .....................................................
echo .....................................................
echo ::: Error :::
echo ::: You must run this script as administrator :::
echo ::: Press any key to exit, :::
echo ::: then re-run this script as administrator :::
echo .....................................................
echo .....................................................
echo .....................................................
echo .....................................................
pause>nul
exit
)
:a
cls
echo .....................................................
echo .DNS Changer by privateloader and zorrophreak.
echo Current Interface: "%if%"
echo .....................................................
echo [1] Use Google Public DNS,
echo [2] Use Comodo Secure DNS,
echo [3] Use OpenDNS,
echo [4] Use Cloudflare 1.1.1.1 DNS,
echo [5] Restore Automatic DNS,
echo [6] Exit DNS Changer
set choice=
set /p choice=Choose option 1-6:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto b
if '%choice%'=='2' goto c
if '%choice%'=='3' goto d
if '%choice%'=='4' goto e
if '%choice%'=='5' goto f
if '%choice%'=='6' goto g
:b
REM Google DNS
cls
netsh interface ip set dns "%if%" static 8.8.8.8
netsh interface ip add dns "%if%" 8.8.4.4
echo %if% DNS has been Updated!
pause
cls
goto a
:c
REM Comodo DNS
cls
netsh interface ip set dns "%if%" static 8.26.56.26
netsh interface ip add dns "%if%" 8.20.247.20
echo %if% DNS has been Updated!
pause
cls
goto a
:d
REM OpenDNS
cls
netsh interface ip set dns "%if%" static 208.67.222.222
netsh interface ip add dns "%if%" 208.67.220.220
echo %if% DNS has been Updated!
pause
cls
goto a
:e
REM Cloudflare DNS
cls
netsh interface ip set dns "%if%" static 1.1.1.1
netsh interface ip add dns "%if%" 1.0.0.1
echo %if% DNS has been Updated!
pause
cls
goto a
:f
REM Reset
cls
netsh interface ip set dns "%if%" dhcp
cls
echo %if% DNS has been Reset!
pause
cls
goto a
:g
REM Exit
end
For Windows 8 and Newer:
Code:
@title DNS Changer by privateloader
@echo off
REM Other DNS thrown in there by Zorrophreak on SL
REM I also changed the way DNS is changed
mode con:cols=53 lines=12
REM I intend to allow the script to automatically search for interfaces but for right now it is defined as variable if.
set if=Ethernet
:checkadmin
cls
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
goto a
) else (
echo .....................................................
echo .....................................................
echo .....................................................
echo .....................................................
echo ::: Error :::
echo ::: You must run this script as administrator :::
echo ::: Press any key to exit, :::
echo ::: then re-run this script as administrator :::
echo .....................................................
echo .....................................................
echo .....................................................
echo .....................................................
pause>nul
exit
)
:a
cls
echo .....................................................
echo .DNS Changer by privateloader and zorrophreak.
echo Current Interface: "%if%"
echo .....................................................
echo [1] Use Google Public DNS,
echo [2] Use Comodo Secure DNS,
echo [3] Use OpenDNS,
echo [4] Use Cloudflare 1.1.1.1 DNS,
echo [5] Restore Automatic DNS,
echo [6] Exit DNS Changer
set choice=
set /p choice=Choose option 1-6:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto b
if '%choice%'=='2' goto c
if '%choice%'=='3' goto d
if '%choice%'=='4' goto e
if '%choice%'=='5' goto f
if '%choice%'=='6' goto g
:b
REM Google DNS
cls
netsh interface ip set dns "%if%" static 8.8.8.8
netsh interface ip add dns "%if%" 8.8.4.4
echo %if% DNS has been Updated!
pause
cls
goto a
:c
REM Comodo DNS
cls
netsh interface ip set dns "%if%" static 8.26.56.26
netsh interface ip add dns "%if%" 8.20.247.20
echo %if% DNS has been Updated!
pause
cls
goto a
:d
REM OpenDNS
cls
netsh interface ip set dns "%if%" static 208.67.222.222
netsh interface ip add dns "%if%" 208.67.220.220
echo %if% DNS has been Updated!
pause
cls
goto a
:e
REM Cloudflare DNS
cls
netsh interface ip set dns "%if%" static 1.1.1.1
netsh interface ip add dns "%if%" 1.0.0.1
echo %if% DNS has been Updated!
pause
cls
goto a
:f
REM Reset
cls
netsh interface ip set dns "%if%" dhcp
cls
echo %if% DNS has been Reset!
pause
cls
goto a
:g
REM Exit
end
For those who don't feel like copying this over, I have the batch files hosted below along with their respective VTs
Windows XP through Windows 7:
Download
VirusTotal
Windows 8 and Above:
Download
VirusTotal