Script Deployment on Windows

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.

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.

To schedule the tasks on the windows, we need to open the task scheduler as shown in the below image.

Script Deployment on Windows

Click on Create Task.. given in the right pane of the application.

The following window will open.

Script Deployment on Windows

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

Script Deployment on Windows

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.

Script Deployment on Windows

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

Script Deployment on Windows

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.

Script Deployment on Windows

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

Script Deployment on Windows

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

Script Deployment on Windows

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.

Script Deployment on Windows

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.

Script Deployment on Windows

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.

Next TopicNumPy Tutorial




Latest Courses