We will do this in Windows 7 but you can do it in all Windows versions.
This post will use the hosts file and two tasks. The host file is stored in %SystemRoot%\system32\drivers\etc\ and its function is mapping host names and IP addresses. Before DNS or WINS act the local host do this mapping so is the ideal place for controlling access to Web Pages.
So let start:
Press WinKey + R, type %SystemRoot%\system32\drivers\etc\ and press Enter. You will see something like this:
Copy and paste the file twice so you will see this:
Create a new folder named c:\hosts. Move the two copies of the host file and rename it to host.tmp1 and host.tmp2.
Press WinKey + R, type notepad and press Enter, drag and drop host.tmp1 to the open window:
Add the following line to the file 127.0.0.1 www.facebook.com and save it.
Now, when your browser looks for facebook.com it will be redirected to your local machine, making the connection impossible.
The idea behind is using the host file that blocks Facebook whenever you want. We also have to create 2 files, that are going to copy the 2 versions of the host file.
For that reason we open a new notepad, use WinKey + R, type notepad and press Enter.
Type the following line:
xcopy /Y hosts.tmp1 hosts
and save it to “1.bat”, don’t forget to use the quotes:
Repeat the same with host.tmp2 and create a file named 2.bat. The command line is xcopy /Y hosts.tmp2 hosts. Now we have the files that are going to copy the versions of host file when we want. Copy these 4 files into %SystemRoot%\system32\drivers\etc\ so you finally have these:
We are going to use the Task Scheduler to execute the bat files.
Type Winkey + R type taskschd.msc /s and press Enter. On the right pane click create basic task. Name it as Restrict Access. Select Daily. Now enter the time you are going to restrict the access to facebook.com. In our case 8:00 pm. Select Start a program and look for 1.bat. You have to type the folder the task is going to start %SystemRoot%\system32\drivers\etc\:
Click on “Open the properties dialog for this task when I click Finish“ and press finish. Select the following options:
Repeat the same for 2.bat, but in this case use the time you want to start using the Web Page, for example 5:00 pm.
There you have it, access to websites blocked at certain times.
If you’re not into scripting or doing things as manually as this, be sure to check out the User Accounts and Parental Controls Series (written for Vista but also works for Windows 7.)