Some antivirus software including Microsoft Security Essentials (Windows Defender) will not allow users to modify the hosts file for the security reasons. That means if you want to face with this problem, you have to disable the antivirus software temporarily or exclude files from the protected host. But for some other reason, you cannot disable antivirus software, or exclude from your hosts file so what can be done next?
Using a Command Prompt
First, open the Command Prompt window by the highest authority by typing “cmd” into the search box in the Windows > Right-click on the “Command Prompt”> Click on the “Run as administrator” (or by the simplest way you can press Windows + X and then click on Command Prompt (Admin).
|Click on the “Run as administrator”|
On the “Command Prompt” window, type “cd drivers’ then press Enter, type ”cd etc” and press Enter to access the hosts file location.
|“Command Prompt” window|
Please make sure you are in the right directory “C: Windows System32 Drivers etc”> then type “notepad hosts” to open the hosts file in Notepad.
|Type “notepad hosts” to open the hosts file in Notepad.|
Then you proceed to change the hosts file contents (below is an example, if I want to block facebook on the computer, I can enter the IP address and type facebook.com) > Then go to Menu File > select Save and i have changed the Windows hosts file successfully.
|Block facebook on the computer|
Important note: If you do not open the notepad by “Run as Administrator”, you cannot save the hosts file.