Run Python Script From Task Scheduler in Windows 10: A Beginner Guide – Python Tutorial

By | April 8, 2020

If you plan to make a python script be started at specified time every day in windows, the best solution is to use task scheduler. In this tutorial, we will tell you how to create a scheduled task to run a python script.

Create a python script you plan to run at specified time every day

As a test, we have created a python script, which is named to task_scheduler_test.py

The code in this file is:

import time
print("hello")
time.sleep(15)

The absolute path of this python script is: E:\workspace-nlp\Example\task_scheduler_test.py

Check the absolute path of your python.exe

To run python script in windows 10, you should know the absolute path of python.exe. As to us, the path of python.exe is: C:\Users\fly165\.conda\envs\py3.6\python.exe

Open window 10 command window

You can press win + R to  open command window and enter compmgmt.msc.

open compmgmt.msc with windows command window

Then you can open windows computer management to create a scheldued task.

Create a basic task

You can start to create a basic scheldued task like below:

open computer management application to create a basic scheduled task

Input task name and task description

In this tutorial, we will use name: Python Task Scheduler Test. You can modify it to your own.

create a python task scheduler

Select to run this task daily

You can do this like this.

run python script daily in windows 10

Set time when runs task

You can choose a time to run python script daily.

set time to run python script daily in windows 10

Then start to run an application

start to run python script daily in windows 10

Set python.exe path adn python script for this task

You should add the absolute path of python.exe and task_scheduler_test.py as this:

Add python scription in windows task sheduler

Then click finish button.

Finish to add python scription in windows task sheduler

You will find Python Task Scheduler Test has been add to windows task scheduler successfully.

Add python scription in windows task sheduler successfully

 

Leave a Reply

Your email address will not be published. Required fields are marked *