I have a task in Task Scheduler (Windows Server 2016 Standard) that runs a simple .bat file calling python.exe and my python file. One of the first things my .py file does is use arcpy.da.Walk to search through a file geodatabase for certain feature classes, appending their full paths to a list.

This function (and the entire script) runs fine either in VS Code (debug or not), and by running my .bat directly from File Explorer. It logs a populated list and moves on. However, when I run this .bat file as a task in Task Scheduler, and check the log file, the list of feature classes is empty. It doesn't seem to be recognizing the location Walk is trying to search, so the directory is empty. There is no exception thrown or anything, so I'm unaware of any further debugging I can do.

I've tried the following:

  • Checked permissions
  • Set the task to run with the highest privileges
  • Set the task to run whether or not the user is logged in
  • Tried changing the "Start In" argument to my project folder where the FGDB is, and even tried setting it to the FGDB itself

Might anyone know why arcpy.da.Walk wouldn't work via Task Scheduler, but otherwise runs fine?


# Data Sources
sde_conn       = r'F:\BatchJobs\DB_Connections\ecch-gis@[email protected]'
parcel_history = os.path.join(sde_conn, "bd_TaxParcelHistory")
parcels_gdb    = r'S:\GIS\DATA Production\Data\SanGIS\Parcel\Parcels\Parcels.gdb'
buffer_1k      = r'F:\BatchJobs\ParcelHistory\ParcelHistory.gdb\TaxParcels_Buffer1000'
lm_parcel_path = ''

def main(argv=None):
    # Start the process
    logger.info("==== RDW_DataProcessing.py started ====")
    arcpy.env.overwriteOutput = True
    arcpy.env.workspace = parcels_gdb
    ## Get a list of all TaxParcels_<date> FCs in Parcels.gdb. These
    ##  are the ones clipped to the SDE 2x3Boundary
    logger.info("Finding all TaxParcels_<date> Feature Classes in FGDB")
    fcs_to_compare = []

        parcels_walk = arcpy.da.Walk(parcels_gdb, datatype='FeatureClass')
        for dirpath, dirnames, filenames in parcels_walk:
            for filename in filenames:
                if filename.find("TaxParcels_") > -1:
                    filepath = os.path.join(dirpath, filename)
        lm_parcel_path = fcs_to_compare[-2]
    except Exception as e:

Batch File

C:\Users\GISAutomation\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\python.exe F:\BatchJobs\ParcelHistory\ParcelHistory.py
  • I did actually just change it to "Run only when user is logged in" and this did actually fix the problem. However, this use is not often logged in, but is the go-to to run tasks on this server, so how would I go about circumventing this and getting the function to work correctly when the user isn't logged in?
    – Jack C
    Commented Mar 29, 2023 at 22:22
  • 5
    Edit your post to include the full content of the .bat file and the full content of the script (at least up to the point where it fails). It's difficult to diagnose something we can't see. There are many reasons why this can occur. Including all the relevant information in your question post can help to narrow down which of the reasons might be applicable. However, my first guess would be that perhaps the data is on a network drive referenced by a mapped drive letter, and not by a UNC address. Drive letters are not available when the user is not logged in. So use UNC instead. Commented Mar 30, 2023 at 0:43
  • 2
    Have you set your credentials, or credentials for an administrator account, for the task superuser.com/questions/347751/… ? It's possible that Task Scheduler user lacks permission to access the required path. You could also redirect the stderr output of the batch file to a text file to trap any error messages that might arise. Commented Mar 30, 2023 at 1:37
  • 1
    You definitely need to use a UNC path to your network drive (i.e. \\server_address\share_name\path\to\filegdb) not a mapped drive letter. And make sure you set the task to run as a user who has access to that network share and you store the password. If you don't store the password or you run as the system user, the task won't have access to the network share.
    – user2856
    Commented Mar 30, 2023 at 4:01
  • Since it was closed I can't add the answer, but y'all got it right. I totally missed this (and had actually used the full UNC path for files in another python project). Changed to the UNC path, and it finds it fine.
    – Jack C
    Commented Mar 31, 2023 at 21:15

1 Answer 1


Those in the comments got it right; a simple thing I completely overlooked. Used the full UNC path and it finds the directory and contents.

I'd even done this correctly for previous projects, but spaced on the need for UNC paths this time around.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.