Script Deployment on WindowsThis 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. Click on Create Task.. given in the right pane of the application. The following window will open. Configure the properties and give the name and other required properties for your script. Do check the Checkbox as “Run with highest privileges“. 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. 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. Now, click on Conditions and deselect the 2nd option which says “Start the task only if the computer is on AC power.“ Now, go to settings and click OK as shown in the following image. 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. 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. 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. |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/263078.html