Advertisement
aveyo

dota2bandwidthsaver

Apr 5th, 2016
5,200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.21 KB | None | 0 0
  1. :: dota2bandwidthsaver by aveyo v1.0 - run as administrator!         undo script @ pastebin.com/TAfRprCd
  2. @ECHO OFF &SETLOCAL ENABLEDELAYEDEXPANSION
  3.  
  4. :: CHOOSE HOW MUCH TO BLOCK HERE
  5. SET "domains=www.dota2.com cdn.dota2.com media.steampowered.com images.akamai.steamusercontent.com"
  6. :: www.dota2.com = blog and shop stuff
  7. :: cdn.akamai.steamstatic.com = steam avatars etc.
  8. :: cdn.dota2.com media.steampowered.com = shop stuff, localized stuff, steam profile stuff etc.
  9. :: images.akamai.steamusercontent.com = custom games preview images, steam profile stuff
  10.  
  11. ECHO. &ECHO   PLEASE WAIT...
  12. :: kill dota2 & steam
  13. TASKKILL /F /IM dota2.exe >nul 2>&1
  14. TASKKILL /F /IM steam.exe >nul 2>&1
  15. CALL :DETECT_STEAM_PATH
  16. :: clear cache
  17. IF DEFINED STEAMPATH RD /S /Q "%STEAMPATH%\appcache\httpcache" >nul 2>&1
  18. RD /S /Q "%USERPROFILE%\AppData\Local\Steam" >nul 2>&1
  19. :: blacklist cdn
  20. CALL :BLACK_LIST
  21. :: end
  22. ENDLOCAL
  23. EXIT /B
  24.  
  25. :DETECT_STEAM_PATH
  26. :: search in filetypes/default_path/registry and save it in %STEAMPATH% var
  27. FOR /F USEBACKQ^ TOKENS^=2^ DELIMS^=^" %%A IN (`FTYPE steam 2^>nul`) DO SET "STEAMPATH=%%~dpA"
  28. IF EXIST "%STEAMPATH%\Steam.exe" GOTO :eof
  29. SET "STEAMPATH=C:\Program Files (x86)\Steam\"
  30. IF EXIST "%STEAMPATH%\Steam.exe" GOTO :eof
  31. :: Valve why do you use Linux paths under Windows?!
  32. FOR /F "tokens=2* delims=_" %%A IN (`REG QUERY "HKCU\SOFTWARE\Valve\Steam" 2^>nul ^| FIND /I "SteamPath"`) DO SET "STEAMPATH=%%~A"
  33. SET "STEAMPATH=%STEAMPATH:~6%"
  34. SET "STEAMPATH=%STEAMPATH:/=\%"
  35. SET "STEAMPATH=%STEAMPATH:\\=\%"
  36. IF EXIST "%STEAMPATH%\Steam.exe" GOTO :eof
  37. SET "STEAMPATH="
  38. GOTO :eof
  39. ::END.DETECT_STEAM_PATH
  40.  
  41. :BLACK_LIST
  42. SET "h=%WINDIR%\System32\drivers\etc\hosts"
  43. IF NOT EXIST "%h%" EXIT /B
  44. :: stop if already added
  45. FINDSTR "%domains%" "%h%" >nul 2>&1
  46. IF "%ERRORLEVEL%"=="0" EXIT /B
  47. :: get rights and add entries
  48. TAKEOWN /F "%h%" >nul 2>&1
  49. ICACLS "%h%" /reset /T /Q >nul 2>&1
  50. ATTRIB -R "%h%" >nul 2>&1
  51. COPY /Y "%h%" "%h%.d2bws"
  52. (ECHO. &ECHO # dota2bandwidthsaver) >> "%h%"
  53. FOR %%A IN (%domains%) DO ECHO 0.0.0.0 %%A >> "%h%"
  54. ATTRIB +R "%h%" >nul 2>&1
  55. :: reset network stack
  56. NBTSTAT -R >nul 2>&1
  57. IPCONFIG /flushdns >nul 2>&1
  58. NET STOP dnscache >nul 2>&1
  59. NET START dnscache >nul 2>&1
  60.  
  61. GOTO :eof
  62. ::END.BLACK_LIST
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement