Running Python script through Task Scheduler?


  1. Posts : 43
    Windows 7
       #1

    Running Python script through Task Scheduler?


    Hello,

    This is my first try at running a Python (3.12.0) script through Windows 10's Task Scheduler… and it didn't work (as pretty much expected).

    It's a simple script that 1) fetches a web page from the Net, 2) parses it to find something, and 3) sends an email through my ISP's SMTP server. The script works when launched manually.

    First, I simply fed it the full path to the script: No email.

    Next, I right-clicked on it, told TS to use the following app to run the script… still no email.
    Code:
    "C:\Users\joe\AppData\Local\Programs\Python\Python312\python.exe"
    Does someone know/have a guess at what's wrong?

    Thank you.

    Running Python script through Task Scheduler?-task.scheduler.python.png
      My Computer


  2. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #2

    How do you run it manually?
    Is its file type associated with its file extension?
    I know nothing about Python.

    I don't know what Python script files are called.
    Perhaps it's Whatever.py

    I don't know where it is.
    Perhaps it's in C:\Users\joe\MyScripts\

    I don't know where your python executable is.
    Perhaps it is in the path that you said but I'm surprised it's not in C:\Program files or C:\Program files (x86)
    If you have added Python's executable to your Path then you could just use python instead of whatever the full path is.

    Enter in the TS task definition:-
    - Program
    Code:
    "C:\Users\joe\AppData\Local\Programs\Python\Python312\python.exe"
    - Arguments
    Code:
    "C:\Users\joe\MyScripts\Whatever.py"

    Denis
      My Computer


  3. Posts : 43
    Windows 7
    Thread Starter
       #3

    It looks too complicated on Windows. I'll move it to a Linux host.

    Thank you.
      My Computer


  4. Posts : 776
    Windows 7
       #4

    AppData\Local is an app alias for Python on Windows. Don't use that in a script, instead call "C:\Windows\py.exe"
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 07:12.
Find Us




Windows 10 Forums