ArcGIS Pro 3.0.1: How to run a python script by Windows “task scheduler”?
In the screenshot below, I wanted to run a python script that performs the buffer for a given feature class. I fill the “buffer.py” script in the “add argument” box but couldn’t figure out what to stick in the “Program/scrip” box
Clip_1142.jpg
Clip_1143.jpg
Clip_1144.jpg
The script (.py file) goes in the "program/script" box. You don't need any arguments!
Did you ever do this with ArcMap based python scripts? If so, the only difference should be the path to python for ArcGIS Pro.
It appears that sticking the python file in the "program/script" box doesn’t generate the expected feature class in the destination geodatabase (C:\Z7\Q.gdb)
What could be the issue here?
Clip_1155.jpg
Clip_1153.jpg
Clip_1154.jpg
Try copying and pasting the following into notepad:
"c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" "c:\Z7\Buffer.py"
And saving with a .bat extension. Then pointing task scheduler to that
The .bat file appears not to work as per the screenshots below
Clip_30.jpg
Clip_31.jpg
Clip_27.jpg
Can you provide a screenshot of your bat file code?
Sure. Here you go
Clip_1180.jpg
I don't see anywhere that creates the C:\\Z7\\Q.gdb\\L1 feature class?
I see where you try to use it as an input feature class, but by the lack of arrow next to the Q.gdb, that would suggest the FGDB is empty (is there an existing L1 feature class in the Q.gdb?).
If not, the buffer tool can't use a non-existent dataset as an input.
R_
All what I wanted here is to run the buffer tool by windows task scheduler. The python script is extracted from the model. It runs successfully thought the Pro as per the screenshots below.
------------------
# -*- coding: utf-8 -*-
"""
Generated by ArcGIS ModelBuilder on : 2022-08-31 11:41:53
"""
import arcpy
def Model(): # Buffer
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = True
# Model Environment settings
with arcpy.EnvManager(scratchWorkspace=r"C:\Z7\Q.gdb"):
L1 = "L1"
# Process: Buffer (Buffer) (analysis)
L1_Buffer = "C:\\Z7\\Q.gdb\\L1_Buffer"
arcpy.analysis.Buffer(in_features=L1, out_feature_class=L1_Buffer, buffer_distance_or_field="5 Meters", line_side="FULL", line_end_type="ROUND", dissolve_option="NONE", dissolve_field=[], method="PLANAR")
if __name__ == '__main__':
# Global Environment settings
with arcpy.EnvManager(workspace=r"C:\Users\jamal2\AppData\Local\Temp\ArcGISProTemp13328\3aee01c4-83fc-49dc-a1a9-1160767de7fc\Default.gdb"):
Model()
-------------------------
Why the script fails to run from the windows task scheduler?
Clip_1181.jpg
Clip_1182.jpg
Clip_1183.jpg