Advertisement
zilexa

DNS Switch.cmd

Apr 14th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :: Save as DNSswitch.cmd and put it on your desktop. This will toggle switching between default/dynamic DNS from your Internet Provider
  2. :: OR the ones you fill in below.
  3. @ECHO off
  4.  
  5. :: CHANGE THE ADDRESSES! FIGURE OUT THE FASTEST DNS FOR YOU BY RUNNING THE NAMEBENCH TOOL!
  6. :: (GOOGLE IT, DOWNLOAD IT, RUN IT AND WAIT FOR ITS RECOMMMENDATIONS)
  7. SET PrimaryDNS=193.67.79.39
  8. SET SecondaryDNS=208.67.222.222
  9.  
  10. :: Create the notification message; Closed internet, intranet enabled
  11.   echo set WshShell = WScript.CreateObject("WScript.Shell") > %tmp%\tmp0.vbs
  12.   echo WScript.Quit (WshShell.Popup( "LIMITED internet with FULL INTRANET" ,2 ,"Click OK", 0)) >> %tmp%\tmp0.vbs
  13.  
  14. :: Create the notification message; Fast, open internet enabled, intranet disabled
  15.   echo set WshShell = WScript.CreateObject("WScript.Shell") > %tmp%\tmp1.vbs
  16.   echo WScript.Quit (WshShell.Popup( "OPEN internet with LIMITED INTRANET" ,2 ,"Click OK", 0)) >> %tmp%\tmp1.vbs
  17.  
  18. :: Switch from automatic DNS via your network's DHCPserver to Manual or vice versa for all network adapters (wifi and cable)
  19. netsh interface ip show config | findstr /i "%PrimaryDNS%"
  20. if  %ERRORLEVEL% EQU 1 (
  21.   for /f "skip=2 tokens=3*" %%i in ('netsh interface show interface') do (
  22.   netsh int ip set dns "%%j" static "%PrimaryDNS%" primary >nul 2>&1
  23.   netsh int ip add dns "%%j" "%SecondaryDNS%" index=2 >nul 2>&1
  24.   net use /DELETE M:
  25.   net use /DELETE N:
  26.   net use /DELETE O:
  27.   net use /PERSISTENT:YES M: \\10.81.152.36\omgData
  28.   net use /PERSISTENT:YES N: \\10.81.152.195\phddata
  29.   net use /PERSISTENT:YES O: \\10.81.152.195\omddata
  30.   )
  31.   ) else (
  32.   for /f "skip=2 tokens=3*" %%i in ('netsh interface show interface') do (
  33.   netsh int ip set dns "%%j" dhcp >nul 2>&1
  34.  )
  35. )
  36.  
  37. :: Display a notification of the change that has been made
  38. netsh interface ip show config | findstr /i "%PrimaryDNS%"  
  39. if  %ERRORLEVEL% EQU 1 (
  40.   cscript /nologo %tmp%\tmp0.vbs
  41.   ) else (
  42.   cscript /nologo %tmp%\tmp1.vbs
  43. )
  44.  
  45. :: Flush DNS
  46. ipconfig /flushdns
  47.  
  48. :: Cleanup the notification message files
  49. DEL /F /S /Q /A %tmp%\tmp0.vbs
  50. DEL /F /S /Q /A %tmp%\tmp1.vbs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement