Search code examples
pythonscheduled-tasks

Running a python script through Windows Scheduler not working


I am trying to automate a python script through the Windows Task Scheduler but its not working. At the end of my python script. two CSV files should be created but they arent.

I tried the following: 1. Copied the address of my python.exe to Program/Script.

C:\Program Files\Python35\python.exe

  1. In the Add arguments, i put the name of my file

Historical Aggregation.py

  1. In the Start in (optional), i put the path of my python script

C:\Users\myname\PycharmProjects\Project1

Am I missing something


Solution

  • To simplify, we can create a really short .bat file, that will only receive the necessary command to run your python script.

    To do so, try this:

    Create a executePy.bat file in the same folder than your Python file (C:\Users\myname\PycharmProjects\Project1), with content:

    @echo off
    "C:\Program Files\Python35\python.exe" "Historical Aggregation.py"
    

    Then, on your task scheduler, simply schedule a test with Program/Script:

    "C:\Users\myname\PycharmProjects\Project1\executePy.bat"
    

    Leave Add Arguments and Start In in blank. Now, your task should be ready to run.