Skip to content

Instantly share code, notes, and snippets.

@Sebastian-Nielsen
Created March 5, 2018 16:55
Show Gist options
  • Save Sebastian-Nielsen/5480aa6c0775e7a4604ee34bdd17416c to your computer and use it in GitHub Desktop.
Save Sebastian-Nielsen/5480aa6c0775e7a4604ee34bdd17416c to your computer and use it in GitHub Desktop.
@echo
title Spotify-noad
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
REM --> Adding lines to hosts file.
:ADD
SET NEWLINE=^& echo.
ECHO # Spotify exemptions
FIND /C /I "pubads.g.doubleclick.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 pubads.g.doubleclick.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "securepubads.g.doubleclick.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 securepubads.g.doubleclick.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "pubads.g.doubleclick.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 pubads.g.doubleclick.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "adclick.g.doublecklick.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 adclick.g.doublecklick.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "adeventtracker.spotify.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 adeventtracker.spotify.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "ads-fa.spotify.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 ads-fa.spotify.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "analytics.spotify.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 analytics.spotify.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "audio2.spotify.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 audio2.spotify.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "b.scorecardresearch.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 b.scorecardresearch.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "bounceexchange.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 bounceexchange.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "bs.serving-sys.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 bs.serving-sys.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "content.bitsontherun.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 content.bitsontherun.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "core.insightexpressai.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 core.insightexpressai.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "crashdump.spotify.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 crashdump.spotify.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "d2gi7ultltnc2u.cloudfront.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 d2gi7ultltnc2u.cloudfront.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "d3rt1990lpmkn.cloudfront.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 d3rt1990lpmkn.cloudfront.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "desktop.spotify.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 desktop.spotify.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "doubleclick.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 doubleclick.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "ds.serving-sys.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 ds.serving-sys.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "googleadservices.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 googleadservices.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "googleads.g.doubleclick.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 googleads.g.doubleclick.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "gtssl2-ocsp.geotrust.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 gtssl2-ocsp.geotrust.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "js.moatads.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 js.moatads.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "log.spotify.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 log.spotify.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "media-match.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 media-match.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "open.spotify.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 open.spotify.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "pagead46.l.doubleclick.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 pagead46.l.doubleclick.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "pagead2.googlesyndication.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 pagead2.googlesyndication.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "partner.googleadservices.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 partner.googleadservices.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "pubads.g.doubleclick.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 pubads.g.doubleclick.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "redirector.gvt1.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 redirector.gvt1.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "s0.2mdn.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 s0.2mdn.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "securepubads.g.doubleclick.net" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 securepubads.g.doubleclick.net>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "spclient.wg.spotify.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 spclient.wg.spotify.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "tpc.googlesyndication.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 tpc.googlesyndication.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "v.jwpcdn.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 v.jwpcdn.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "video-ad-stats.googlesyndication.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 video-ad-stats.googlesyndication.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "weblb-wg.gslb.spotify.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 weblb-wg.gslb.spotify.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "www.googleadservices.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 www.googleadservices.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "www.googletagservices.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 www.googletagservices.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "www.omaze.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 www.omaze.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I "omaze.com" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^0.0.0.0 omaze.com>>%WINDIR%\System32\drivers\etc\hosts
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment