Block Ads on Surface! :D

Search This thread

C-Lang

Senior Member
Nov 25, 2012
158
40
Redlands, CA
Ok, so disclaimer: this isn't the same as Ad Block, some ads will slip through, and there will probably be IE error messages popping up.

However, if you despise adverts and are ready to give feedback, this does block many ads.
So, what we're doing is editing Windows' built-in hosts file to block these addresses at the source.

First, download the hosts file attached here.
Then, browse to "C:\Windows\System32\drivers\etc" and rename "hosts" to "hosts.old"
Then copy and paste the file you downloaded into the folder, making sure there is no file extension (go to View>show/hide file extensions)

Next, open CMD as admin (start>cmd>right click>run as admin)
Type "net stop dnscache" and hit enter.
After a couple minutes that'll finish.
Type "sc config dnscache start= disabled"

Reboot your Surface (or other device)

You're now (mostly) ad-free! Let me know what you think, and what effects this has on page load speed. (negligible to me, but I'm on a high-speed, slow connections would most benefit.) :good:
 

Attachments

  • Hostsfile.zip
    2.5 MB · Views: 1,216
Last edited:

GoodDayToDie

Inactive Recognized Developer
Jan 20, 2011
6,066
2,933
Seattle
HOSTS-file ad blocking is nothing new, but it is a nice trick. However, there are a few problems with the way you suggested doing this:

1) the HOSTS file on Win8 and WRT is protected by Windows Defender, and attempts to modify the mapping for a number of known domains (some of which, annoyingly, are advertising domains) will fail. You will want to add \Windows\System32\drivers\etc\HOSTS to the Excluded Files in Defender.

2) Neither disabling DNS caching nor restarting are needed. Just run the following command: "ipconfig /flushdns" (no quotes). This will wipe the current DNS cache. Disabling the caching entirely will actually degrade performance, as your browser (for example) will need to do a DNS lookup every single time it wants to open a connection to a server, which could be dozens of times per click. Windows will use the HOSTS file just fine while the DNS cache is active. I'm not even *sure* you need to flush it, but it won't hurt.

By the way, for web browsing, a somewhat "nicer" approach to ad-blocking is to use the built-in IE feature of Tracking Protection Lists. You can "get a Tracking Protection List online" and then add EasyList (who also make the most popular block list for AdBlock Plus/AdBlock Edge). Most people don't realize that IE effectively has a built-in ad blocker, and has for a few releases now... Of course, that won't help with ads outside of the browser.
 
Last edited:
  • Like
Reactions: waraukaeru

C-Lang

Senior Member
Nov 25, 2012
158
40
Redlands, CA
HOSTS-file ad blocking is nothing new, but it is a nice trick. However, there are a few problems with the way you suggested doing this:

1) the HOSTS file on Win8 and WRT is protected by Windows Defender, and attempts to modify the mapping for a number of known domains (some of which, annoyingly, are advertising domains) will fail. You will want to add \Windows\System32\drivers\etc\HOSTS to the Excluded Files in Defender.

2) Neither disabling DNS caching nor restarting are needed. Just run the following command: "ipconfig /flushdns" (no quotes). This will wipe the current DNS cache. Disabling the caching entirely will actually degrade performance, as your browser (for example) will need to do a DNS lookup every single time it wants to open a connection to a server, which could be dozens of times per click. Windows will use the HOSTS file just fine while the DNS cache is active. I'm not even *sure* you need to flush it, but it won't hurt.

By the way, for web browsing, a somewhat "nicer" approach to ad-blocking is to use the built-in IE feature of Tracking Protection Lists. You can "get a Tracking Protection List online" and then add EasyList (who also make the most popular block list for AdBlock Plus/AdBlock Edge). Most people don't realize that IE effectively has a built-in ad blocker, and has for a few releases now... Of course, that won't help with ads outside of the browser.

Ah, very interesting. Thanks for the feedback. :)
 
  • Like
Reactions: waraukaeru

nazoraios

Senior Member
Jun 8, 2013
85
46
Good tip...

I used the same method as I do on the desktop, I go to :
http://winhelp2002.mvps.org/hosts.htm

Scroll down to folder icon and where it says download, tap and hold or right click and save to local disk.
Then extract and right click or tap and hold the mvps.bat file and run as admin and your done.

It makes a backup of your original hosts file as HOST.MVP.

I have never noticed windows defender 'undoing' this unless it just removes a few entries within it.
 

waraukaeru

Member
Mar 22, 2012
24
1
Good tip...

I used the same method as I do on the desktop, I go to :
http://winhelp2002.mvps.org/hosts.htm

Scroll down to folder icon and where it says download, tap and hold or right click and save to local disk.
Then extract and right click or tap and hold the mvps.bat file and run as admin and your done.

It makes a backup of your original hosts file as HOST.MVP.

I have never noticed windows defender 'undoing' this unless it just removes a few entries within it.

In MVPS's specific instructions for Windows 8 they tell you to make an exception in Windows Defender because it will block it.
 

nazoraios

Senior Member
Jun 8, 2013
85
46
In MVPS's specific instructions for Windows 8 they tell you to make an exception in Windows Defender because it will block it.

Yes.. interesting. My ad blocking worked fine but i bet they did unblock a series of domains that they deem 'necessary' for windows8.

Thanks for the windows defender tip... i'll have to start using that as well.
 

waraukaeru

Member
Mar 22, 2012
24
1
Hey, I have a couple questions for all of you awesome ad-blocking folk. I'm using the MVPS hosts file on my Surface 2 and it seems to be blocking some of the ad content for me when I have tracking protection turned off or when tracking protection is ineffective. So, I assume it is set up properly. When you find an unblocked ad, (for instance, my ad blocking efforts seem effective against the images on Facebook but not the text ads) what is your process for determining the domain/host for the ad and blocking it? Do you always go and edit your hosts file, or do you add the domain to you restricted list in Internet Explorer? Or add it to your custom Tracking Protection list?

My other question is: have any of you have determined the common hosts for the banner ads in Windows Store apps? I noticed the MVPS hosts file doesn't seem to be blocking these hosts.
 
Last edited:

nazoraios

Senior Member
Jun 8, 2013
85
46
Well since your talking about a web page I would say download fiddler (on an x86 box) and run it in the background while you use your web page. It acts as a proxy so all requests go through it. Then once you find the domains you can add them to HOSTS file.

If you x86 box is Windows 8/8.1 it's a little trickier, you need to use fiddler's 'Windows 8 Config' button to add exceptions to the apps your trying to monitor. I think if you are running IE11 (in protected mode only?) you need to add exceptions for win_ie_ac_??? entries. To monitor apps you can try enabling them all or find your app.

If your talking about on device (RT) you might try running netstat -f in the background but that may only work with desktop IE not running in Enhanced Protected Mode.... if its too much data to read you could redirect to a file to skim through later like netstat -f > temp.txt

Hey, I have a couple questions for all of you awesome ad-blocking folk. I'm using the MVPS hosts file on my Surface 2 and it seems to be blocking some of the ad content for me when I have tracking protection turned off or when tracking protection is ineffective. So, I assume it is set up properly. When you find an unblocked ad, (for instance, my ad blocking efforts seem effective against the images on Facebook but not the text ads) what is your process for determining the domain/host for the ad and blocking it? Do you always go and edit your hosts file, or do you add the domain to you restricted list in Internet Explorer? Or add it to your custom Tracking Protection list?

My other question is: have any of you have determined the common hosts for the banner ads in Windows Store apps? I noticed the MVPS hosts file doesn't seem to be blocking these hosts.
 

waraukaeru

Member
Mar 22, 2012
24
1
Well since your talking about a web page I would say download fiddler (on an x86 box) and run it in the background while you use your web page. It acts as a proxy so all requests go through it. Then once you find the domains you can add them to HOSTS file.

If you x86 box is Windows 8/8.1 it's a little trickier, you need to use fiddler's 'Windows 8 Config' button to add exceptions to the apps your trying to monitor. I think if you are running IE11 (in protected mode only?) you need to add exceptions for win_ie_ac_??? entries. To monitor apps you can try enabling them all or find your app.

If your talking about on device (RT) you might try running netstat -f in the background but that may only work with desktop IE not running in Enhanced Protected Mode.... if its too much data to read you could redirect to a file to skim through later like netstat -f > temp.txt

Those are some great ideas; I'm going to try them out. They're all fairly labor intensive... I wonder... do you go to those lengths to block ads? It matters that much to me. Looking at how much work that will be though, I am missing the ease of using Adblock Plus and Ghostery plugins in Firefox.
 

nazoraios

Senior Member
Jun 8, 2013
85
46
I usually go through those measures to determine which domains to 'unblock' so that I can get a site working with my ad blocking.

I forgot the most obvious method for web stuff, hit F12 in IE, go to network tab, start capturing traffic, load page you want to minitor, and examine results.


Those are some great ideas; I'm going to try them out. They're all fairly labor intensive... I wonder... do you go to those lengths to block ads? It matters that much to me. Looking at how much work that will be though, I am missing the ease of using Adblock Plus and Ghostery plugins in Firefox.
 

Jon4248

Senior Member
Sep 7, 2012
153
71
Ok, so disclaimer: this isn't the same as Ad Block, some ads will slip through, and there will probably be IE error messages popping up.

However, if you despise adverts and are ready to give feedback, this does block many ads.
So, what we're doing is editing Windows' built-in hosts file to block these addresses at the source.

First, download the hosts file attached here.
Then, browse to "C:\Windows\System32\drivers\etc" and rename "hosts" to "hosts.old"
Then copy and paste the file you downloaded into the folder, making sure there is no file extension (go to View>show/hide file extensions)

Next, open CMD as admin (start>cmd>right click>run as admin)
Type "net stop dnscache" and hit enter.
After a couple minutes that'll finish.
Type "sc config dnscache start= disabled"

Reboot your Surface (or other device)

You're now (mostly) ad-free! Let me know what you think, and what effects this has on page load speed. (negligible to me, but I'm on a high-speed, slow connections would most benefit.) :good:

Why not just enable some tracking protection lists under Internet Explorer add-ons? It seems to block most, if not all ads for me, even on torrent sites and to me, this seems much easier than a host file.

I enabled the following lists: EasyList Standard, EasyPrivacy.

http://www.iegallery.com/en-us/trackingprotectionlists

:)
 

TRSHD

Senior Member
Mar 27, 2012
103
12
Montreal
Anyone else finding themselves unable to have the ads blocked through hostfile blacklisting? Running 8.1, followed the instructions, all ads keep appearing in Metro apps...
 

kitor

Senior Member
Apr 11, 2007
170
30
kitor.pl
On 8.1 Windows Defender does not allow changes in this file - you must remove it from protected files or disable defender (well, IMO it's nonsense on ARM).
 
  • Like
Reactions: TRSHD

GoodDayToDie

Inactive Recognized Developer
Jan 20, 2011
6,066
2,933
Seattle
No, Win32 is case-insensitive. It's traditional on Windows to use upper-case, but it doesn't matter.

NTFS is actually capable of behaving in a case-sensitive manner, but Win32 is explicitly case-insensitive. This leads to weirdness if you don't use the Win32 subsystem and create a file whose name differs from another only by case, then try to open them using a Win32 program like Notepad...
 
  • Like
Reactions: TRSHD

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    Ok, so disclaimer: this isn't the same as Ad Block, some ads will slip through, and there will probably be IE error messages popping up.

    However, if you despise adverts and are ready to give feedback, this does block many ads.
    So, what we're doing is editing Windows' built-in hosts file to block these addresses at the source.

    First, download the hosts file attached here.
    Then, browse to "C:\Windows\System32\drivers\etc" and rename "hosts" to "hosts.old"
    Then copy and paste the file you downloaded into the folder, making sure there is no file extension (go to View>show/hide file extensions)

    Next, open CMD as admin (start>cmd>right click>run as admin)
    Type "net stop dnscache" and hit enter.
    After a couple minutes that'll finish.
    Type "sc config dnscache start= disabled"

    Reboot your Surface (or other device)

    You're now (mostly) ad-free! Let me know what you think, and what effects this has on page load speed. (negligible to me, but I'm on a high-speed, slow connections would most benefit.) :good:
    2
    Good tip...

    I used the same method as I do on the desktop, I go to :
    http://winhelp2002.mvps.org/hosts.htm

    Scroll down to folder icon and where it says download, tap and hold or right click and save to local disk.
    Then extract and right click or tap and hold the mvps.bat file and run as admin and your done.

    It makes a backup of your original hosts file as HOST.MVP.

    I have never noticed windows defender 'undoing' this unless it just removes a few entries within it.
    1
    HOSTS-file ad blocking is nothing new, but it is a nice trick. However, there are a few problems with the way you suggested doing this:

    1) the HOSTS file on Win8 and WRT is protected by Windows Defender, and attempts to modify the mapping for a number of known domains (some of which, annoyingly, are advertising domains) will fail. You will want to add \Windows\System32\drivers\etc\HOSTS to the Excluded Files in Defender.

    2) Neither disabling DNS caching nor restarting are needed. Just run the following command: "ipconfig /flushdns" (no quotes). This will wipe the current DNS cache. Disabling the caching entirely will actually degrade performance, as your browser (for example) will need to do a DNS lookup every single time it wants to open a connection to a server, which could be dozens of times per click. Windows will use the HOSTS file just fine while the DNS cache is active. I'm not even *sure* you need to flush it, but it won't hurt.

    By the way, for web browsing, a somewhat "nicer" approach to ad-blocking is to use the built-in IE feature of Tracking Protection Lists. You can "get a Tracking Protection List online" and then add EasyList (who also make the most popular block list for AdBlock Plus/AdBlock Edge). Most people don't realize that IE effectively has a built-in ad blocker, and has for a few releases now... Of course, that won't help with ads outside of the browser.
    1
    HOSTS-file ad blocking is nothing new, but it is a nice trick. However, there are a few problems with the way you suggested doing this:

    1) the HOSTS file on Win8 and WRT is protected by Windows Defender, and attempts to modify the mapping for a number of known domains (some of which, annoyingly, are advertising domains) will fail. You will want to add \Windows\System32\drivers\etc\HOSTS to the Excluded Files in Defender.

    2) Neither disabling DNS caching nor restarting are needed. Just run the following command: "ipconfig /flushdns" (no quotes). This will wipe the current DNS cache. Disabling the caching entirely will actually degrade performance, as your browser (for example) will need to do a DNS lookup every single time it wants to open a connection to a server, which could be dozens of times per click. Windows will use the HOSTS file just fine while the DNS cache is active. I'm not even *sure* you need to flush it, but it won't hurt.

    By the way, for web browsing, a somewhat "nicer" approach to ad-blocking is to use the built-in IE feature of Tracking Protection Lists. You can "get a Tracking Protection List online" and then add EasyList (who also make the most popular block list for AdBlock Plus/AdBlock Edge). Most people don't realize that IE effectively has a built-in ad blocker, and has for a few releases now... Of course, that won't help with ads outside of the browser.

    Ah, very interesting. Thanks for the feedback. :)
    1
    On 8.1 Windows Defender does not allow changes in this file - you must remove it from protected files or disable defender (well, IMO it's nonsense on ARM).