Is anyone able to run a script through Windows Task scheduler using ArcGIS Pro? As a test I have an extremely simple script (just copying a feature) that runs fine within ArcGIS Pro.
import arcpy
arcpy.management.CopyFeatures("C:\CityScripts\ScheduledTasks\SafewatchCameras\Data\General.gdb\SafewatchCameras", "C:\CityScripts\ScheduledTasks\SafewatchCameras\Data\General.gdb\SafewatchCamerastemp2", None, None, None, None)
I setup the Task Scheduler as recommended by the ArcGIS Pro help and while the Task completes successfully nothing happens with the script.
Put in a call to ESRI tech support but they said it was a Windows issue and therefore couldn't work on it.
Scott
I just upgraded from Windows 7 to Windows 10 and found that the path I got from the Run Standalone Scriptshelp page that ran propy.bat in Task Scheduler under Windows 7 does not work under Windows 10.
"c:\Program Files\ArcGIS\Pro\bin\Python\scripts\propy.bat" works for me in Windows 7, but not in Windows 10.
c:\Progra~1\ArcGIS\Pro\bin\Python\scripts\propy.bat works for both Windows 7 and Windows 10.
So Scott from City of Greenville was correct that the path from the help page didn't work, at least under Windows 10.
I think the OP was trying to run python scripts on Windows Server.
The following thread shows a solution for Pro, but it does require having the ability to upgrade to Windows Server 2016.
We just migrated to a Windows 2019 server and c:\Program Files\ArcGIS\Pro\bin\Python\scripts\propy.bat kept failing immediately. I tried your suggestion of c:\Progra~1\ and it worked. Thanks!
How about calling python.exe from it's installed location? For me it would be:
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe would be the Program/script
and the py file would be the Add arguments.
Is the task configured to "Run with highest privileges"?
Same error.
This is how we (successfully) run all of our ArcMap based python scripts though.
Here is another threads related to this issue:
Python 3.x Scheduled Task Fails
It provides insight on the problem, but I'm not sure it has been resolved.
Yeah this is definitely related. When I select "Run only when user is logged on" it'll run. I wonder if it's OS as your first question alluded to? It seemed in that thread that people who were running Windows 2016 didn't have an issue.
Also, separately, what a rabbit hole. How is this not something that Tech Support doesn't want to jump into and solve and/or direct people to the appropriate resources?
Do you have Windows Server 2012 or Windows Server 2012 R2?
The big question is, does the script run when using the account that will run it in task scheduler (right click run as)? Ever since I moved all my task scheduler stuff to Pro, nothing but a nightmare of scripts randomly failing, etc. I currently have one bug open related to pro py running as a scheduled task. Same scripts have worked fine in Arcmap for years. So it's not a windows issue. Also, has your IT person set this task up for you? There are a lot of permissions flaming hoops you have to jump through to get a scheduled task to run, and most users login does not allow it to run if you're logged off.
It does appear to be an operating system issue as I ran it on another serving that's running Windows 2016 and it was successful. Seemingly everything else was the same (admin rights, etc.) I sent a message to our IT dept for some clarity as I'm not sure if there might be something specific to us or if it's specific to Windows 2012.