Category filter

Script to block websites on Windows

Website blacklisting is a defense mechanism that prevents users from accessing harmful and unwanted web URLs. The browser prompts a blocked access notification when the users access the blacklisted websites. Depending on the enterprise requirements, those websites that are unnecessary for the users can be blacklisted. While there are various ways of filtering web content, executing custom scripts is one of the easiest methods of performing it remotely.


The sample scripts provided below are adapted from third-party open-source sites.

Block websites

The host file inside the system’s C drive must be edited to block websites. Execute the following script to modify the host file and specify the websites to be blocked:

Enter the websites to be blocked as string inputs and separate them using commas. For instance, in the script given above, “”, “” and “” are the URLs to be blocked.

Unblock websites

Execute the following script to unblock the previously blocked websites and restore the host file to its default state:


  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.
  • Sample Script Repository