Q:

Web blocker for Windows, to avoid procrastination?

Can you recommend me a web blocker for Windows 7? I want it to avoid procrastination surfing for the web, but at the same time I need to block only some websites, not all and for some hours. For example, I want to be able to visit Stack Overflow, but I want to not be able to visit Reddit.
It can't be a browser addon because I run virtual machines inside Windows 7, and I want this VMs to be also blocked.

A:

You can use  Hosts-Switch to switch between  different hosts files:

gratis
Windows
allows switching between different hosts files with a shortcut.

A:

You could use a proxy server, such as squid.

Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and
  more. It reduces bandwidth and improves response times by caching and
  reusing frequently-requested web pages. Squid has extensive access
  controls and makes a great server accelerator. It runs on most
  available operating systems, including Windows and is licensed under
  the GNU GPL.

See How to block website using SQUID server, for information on how to do this. Reproducing the answer below:

You have to do some changes in squid.conf and here are the steps:

open this file /etc/squid3/squid.conf 
add these lines:
acl bad_url dstdomain "/etc/squid3/bad-sites.squid"
http_access deny bad_url

then go to /etc/squid3/bad-sites.conf and add domains with this format 
.google.com
.msn.com
.app.facebook.com

A:

A lot of the answers here are referencing the almighty hosts file, and indeed, that is your best bet. Here's an automated solution provided by some smart guys over at StackOverflow that utilizes no third party software. You can bundle this up into a batch file and run as a Windows task that unblocks at certain times and completely forget about it. 
This approach has several upsides:

Simple
Free (no downloads required)
Easy to schedule times with Windows Task Scheduler
OS level blocking of websites
Enough of a hassle to undo that you will probably stop yourself before you go through with it.

Here's the code for the batch files:
code for blockfacebook.bat
echo 0.0.0.0 www.facebook.com >> c:\windows\system32\drivers\etc\hosts

code for unblockfacebook.bat
@echo off
    setlocal enableextensions disabledelayedexpansion

    set "file=c:\windows\system32\drivers\etc\hosts"

    for /f "tokens=* delims=0123456789" %%a in (
        'findstr /n /i /v /c:"facebook" "%file%" ^& type nul ^> "%file%"'
    ) do (
        set "line=%%a"
        setlocal enabledelayedexpansion
        >>"%file%" echo(!line:~1!
        endlocal
    )

    endlocal

Just copy paste these into Notepad and save with the .bat extension and double click on them to test.
Scheduling a task:
from Microsoft's website:

You must be logged on as an administrator to perform these steps. If
  you aren't logged on as an administrator, you can only change settings
  that apply to your user account.
If you use a specific program on a regular basis, you can use the Task
  Scheduler wizard to create a task that opens the program for you
  automatically according to the schedule you choose. For example, if
  you use a financial program on a certain day each month, you can
  schedule a task that opens the program automatically to avoid the risk
  of forgetting to open it yourself.

Open Task Scheduler by clicking the Start button Picture of the Start button, clicking Control Panel, clicking System and Security,
  clicking Administrative Tools, and then double-clicking Task
  Scheduler.‌  Administrator permission required If you're prompted for
  an administrator password or confirmation, type the password or
  provide confirmation.
Click the Action menu, and then click Create Basic Task.
Type a name for the task and an optional description, and then click Next.
Do one of the following:

To select a schedule based on the calendar, click Daily, Weekly, Monthly, or One time, click Next; specify the schedule you want to
  use, and then click Next.
To select a schedule based on common recurring events, click When the computer starts or When I log on, and then click Next.
To select a schedule based on specific events, click When a specific event is logged, click Next; specify the event log and other
  information using the drop-down lists, and then click Next.
To schedule a program to start automatically, click Start a program, and then click Next.

Click Browse to find the program you want to start, and then click Next.
Click Finish.

