Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- set dNs=
- set gAteWaY=
- set MainDNS=
- set SecondDNS=
- set WifiSecond=
- set SecondResult=
- set WifiSet=
- set WifiOn=
- for /f "tokens=15" %%A in ('ipconfig /all ^| find "DNS Servers"') do @set dNs=%%A
- for /f "tokens=13" %%A in ('ipconfig ^| find "Gateway"') do @set gAteWaY=%%A
- for /f "tokens=2" %%G in ('nslookup 98.139.183.24 ^| find "Server:"') do @set h0stNamE=%%G
- :main
- echo.
- echo DNS Changer
- echo Author : AltenatorIWnet
- echo Date : 20 May 2012
- echo - Support Local Area Network Adapter
- echo - Support Wireless Adapter
- echo.
- echo Knows Bug :
- echo - NetSH can't run without administrator privileges..
- echo.
- echo Note :
- echo - I only test this batch in Win7 Ultimate, and i not sure
- echo this batch work on other Windows OS...
- echo.
- echo.
- echo Your Current Main DNS..
- echo - %dNs% [ %h0stNamE% ]
- echo.
- :submit
- echo.
- echo ---------------------------------------
- set /p MainDNS=Your Primary DNS )
- echo ---------------------------------------
- echo.
- echo ---------------------------------------------------------
- echo It's ok to leave blank here because secondary almost isn't important
- echo.
- set /p SecondDNS=Secondary DNS [may leave blank] )
- echo ---------------------------------------------------------
- goto:checkout
- exit
- :checkout
- IF NOT DEFINED MainDNS (
- cls
- echo.
- echo Please dude, make sure Primary DNS is inserted
- goto:submit
- exit
- )
- IF DEFINED SecondDNS (
- set SecondsDNS=netsh int ip add dns "Local Area Connection" %SecondDNS%
- set WifiSecond=netsh int ip add dns "Wireless Network Connection" %SecondDNS%
- set SecondResult=Second DNS Server = %SecondDNS%
- ) else (
- set SecondsDNS=echo Settings DNS without secondary DNS
- set WifiSecond=echo Settings DNS without secondary DNS
- set SecondResult=Second DNS Server = No Second DNS exist
- )
- for /f "tokens=1" %%G in ('ipconfig /all ^| find "Wireless LAN"') do @set WifiSet=%%G
- if DEFINED WifiSet (
- set WifiOn=1
- ) else (
- set WifiOn=0
- )
- goto:settingsdns
- exit
- :settingsdns
- echo.
- echo Tweaking Up for Local Area Network..
- echo.
- netsh int ip set dns "Local Area Connection" static %MainDNS% primary>nul
- if %errorlevel%==1 call:error
- %SecondsDNS%>nul
- if %errorlevel%==1 call:error
- if %WifiOn%==1 goto:wifiset
- goto:end
- exit
- :wifiset
- echo Wireless Detected! Tweaking Up for Wireless Network..
- echo.
- netsh int ip set dns "Wireless Network Connection" static %MainDNS% primary>nul
- if %errorlevel%==1 call:error
- %WifiSecond%>nul
- if %errorlevel%==1 call:error
- :end
- echo Complete Change DNS for your computer..
- echo.
- echo First DNS Server = %MainDNS%
- echo.
- echo %SecondResult%
- echo.
- pause
- exit
- :error
- echo.
- echo ---------------------------------------------------------------------
- echo Error Was Detected, it seem you must have administrator privilege...
- echo ---------------------------------------------------------------------
- echo.
- pause
- exit
- goto:eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement