This section of the tutorial illustrates how the python script will be deployed at start-up so that we don’t need to open the terminal all the time to run the script.
Steps for Script Deployment on Windows
If we want to script deployment on Windows, we have to follow these steps:
Changing the Hosts File Path on Windows
Lets first change our hosts file path from “/etc/hosts” to “C:\System32\drivers\etc\hosts” as the hosts file is stored at this location on windows.
Opening Windows Task Scheduler
If we want to schedule the tasks on the windows, we need to open the task scheduler as shown in the below image.

Creating a New Task
Click on Create Task.. given in the right pane of the application.
The following window will open.

Configuring Task Properties
Configure the properties and give the name and other required properties for your script. Do check the Checkbox as “Run with highest privileges“.

Setting the Startup Trigger
Go to Triggers and create a new trigger as shown in the below image.
Select the “At startup” option from the drop-down list so that the script can run at start-up.

Adding Script Action
Now, go to Actions and create a new action by clicking on new.

The following window will open. Select the “Start a program” action from the drop-down list and browse the path to the script, i.e. blocker.py (in my case it is E:\blocker.py) and click OK.

Configuring Task Conditions
Now, click on Conditions and deselect the 2nd option which says “Start the task only if the computer is on AC power.“

Final Task Settings
Now, go to settings and click OK as shown in the following image.

Verifying the Scheduled Task
Now, we got our task Website-blocker scheduled at system start-up. We can check this in the task list as shown in the following image.

Restarting and Testing the Script
Now, we need to restart our system to make the script active on system start-up.
Restart the system now, and try to access the blocked website www.facebook.com as we are in working hours now.
It will show the display which looks like following.

Conclusion
Hence, we have got our script working fine on system start-up and block the access to www.facebook.com (or any website you want) automatically.
Leave a Reply