The Windows host file redirects URLs to IP addresses. It can however, be edited so that if you try to go to a URL, you are sent to a different IP address, in this case, you are harmlessly sent to your local IP (127.0.0.1).
If you want to block a website outright, ie you never want to see facebook again, you could simply edit your hosts file by adding the line
127.0.0.1 www.facebook.com
However, I am not that hard on myself, so instead I have created a batch file, that switches my host file. By running that batch file at 6:30 AM and 9:30 AM, I can limit my access to facebook and other time wasting sites to the morning.
- Open your hosts file with notepad (most likely located in C:\WINDOWS\system32\drivers\etc ) and save it as "hosts1." when saving, make sure to save with a period after hosts1 so that it does not automatically save as a .txt file, this will be the host file that doesn't block sites (ie what I use in the morning).
- Also save the file as "hosts2."
- While in hosts2 add lines to the bottom of the host file in the form
127.0.0.1 www.someurl.com
, blocking whatever urls you like. The lines in my hosts1 file are displayed below:
- Save hosts1 and close
- Open Notepad and paste the following into it:
- Open Notepad and paste the following into it:
copy host1 hosts :chrome taskkill /im chrome.exe if errorlevel 128 goto :firefox start chrome.exe :firefox taskkill /im firefox.exe if errorlevel 128 goto :eof start firefox.exe
Save the file as "block.BAT" in the same folder as your host file.
- Create 2 scheduled tasks, The first task should be set at the beginning of the time that you wish to allow yourself to procrastinate, and should target allow.BAT, and the second one should be set for the time that you wish to stop procrastinating and should target block.BAT.
127.0.0.1 localhost 127.0.0.1 www.facebook.com 127.0.0.1 www.textsfromlastnight.com 127.0.0.1 www.megavideo.com 127.0.0.1 www.myspace.com
copy host2 hosts :chrome taskkill /im chrome.exe if errorlevel 128 goto :firefox start chrome.exe :firefox taskkill /im firefox.exe if errorlevel 128 goto :eof start firefox.exe
Save the file as "allow.BAT" in the same folder as your host file. Make sure that when you save, "Save as type: All Files" is selected so it saves as a Batch file and not as a text file..
If for some reason, the host file is letting you procrastinate when it shouldn't, and stopping you from procrastinating when you want to, manually run the hostswitcher.BAT file by double clicking it. This could happen if you shut down your computer during the time you normally block the sites and start it at a time that you normally allow access or vice-versa.