hosts file batch switcher
This is a simple batch (.bat) file to switch between a default ("empty") hosts file and one that contains your definitions to block ad-sites. You should probably be blocking at the browser level, but if you are on Win32 and use a hosts file...
copy hosts hosts.1
copy hosts.2 hosts
copy hosts.1 hosts.2 Rename the file to (whatever).bat and place it in the \WINDOWS\system32\drivers\etc directory. It can be run via a shortcut, by double clicking, or the command line. Hell, if you needed to have a scheduled process run with the alternate hosts file, you could even schedule this to run before and after the process via the “at” command, or the windows task scheduler.
You can determine which hosts file is loaded based on the filesize of the hosts file. If it’s 1K, it’s the default/”empty,” larger, it’s your ad-blocking hosts file.
I don’t know much about batch files, so there may be a way to improve this to allow you to recognize which one is loaded without the use of filesizes. Please feel free to add a comment if you know a superior method than this.
From
Hi, I wrote some instructions for doing something pretty similar. I use scheduled tasks to automatically switch my hosts file, so that I can only see time-wasting sites at certain times of day.
Check it out at
http://letsfuckindoit.blogspot.com/2010/01/blocking-websites-during-working-hours.html
From
Hi, I wrote some instructions for doing something pretty similar. I use scheduled tasks to automatically switch my hosts file, so that I can only see time-wasting sites at certain times of day.
Check it out at
http://letsfuckindoit.blogspot.com/2010/01/blocking-websites-during-working-hours.html