[GIS] Running Python script in Task Scheduler– Script will not run

arcgis-10.1arcpywindows

I have a script which I wish to run on a regular monthly basis without me needing to open and run the it. I have referred to every web page I can find on Windows Task Scheduler and followed their instructions. However, running the script from Task Scheduler will only open the script in Python and not run it.

In the Task Scheduler Run Window, I have tried entering both the path to the script alone and the path to the script with the path to my Python program. I've also tried entering the path to my Python program as the script with my script as an argument as suggested in this blog post. My script is hard-coded, so I don't think I need to add any arguments.

Am I missing something obvious?


I was experiencing issues because I was using the path to the Python program and not the Python command line. I.e., I was using "C:\Python27\ArcGIS10.1\Lib\site-packages\pythonwin\Pythonwin.exe" when I needed to be using "C:\Python27\ArcGIS10.1\python.exe".

Best Answer

I use the following settings to "Start a program" in the task scheduler. I find it best to use the full path to the Python executable to be safe.

Program/script: Full path to Python.exe, C:\Python27\ArcGIS10.2\python.exe

Arguments: Name of script, script.py

Start in: Location of script.py, something like C:\path\to\script

Also, if you pass in arguments to your script, include those with the arguments section, separated by spaces, script.py arg1 arg2 argn

Related Question