0

Additional Data: Error Value: 2147942401

Goal: Set up a Task to run nightly that either reads a Python script and runs it, or runs the batch file that reads the script. The python script is a geodatabase maintenance script that runs a bunch of clean up and writes a log to location to a drive. I would like to have this run during off working hours due to obvious reasons of locking staff out of accessing data and synchronizing of databases.

The python file has all pertinent paths coded in the format: r"\\Server\drivename\path\to\item"

The Batch file is as follows: 'Run_BasicGDBMaintenance_Script.bat'

"\\<machine>.<domain>.local\C$\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" "\\<machine>.<domain>.localhost\Users\<username>\OneDrive - <City One Drive Name>\Desktop\NightlyScript\BasicGDBMaintenance.py"
   

The python script will run, the .bat file will run, it will run in cmd, and the task scheduler will run as 'Run only when user is logged on'.

I have followed as much as I could understand from https://stackoverflow.com/questions/48343993/batch-file-from-scheduled-task-returns-code-2147942401 As well as the fixes in https://stackoverflow.com/questions/13618945/why-windows-7-task-scheduler-task-fails-with-error-2147942667

Highest privileges is on

Added my user to 'Log on as a batch job' & 'Log on as a service' in the Local Security Policy settings

I have 'Full Control' over the C:
Tried changing the Delay Timer in Task Scheduler > Triggers Have it configured for Windows 10

Action: Task Scheduler Actions Page

Program/Script: "\\<machine>.<domain>.local\Users\<username>\OneDrive - <City One Drive Name>\Desktop\NightlyScript\Run_BasicGDBMaintenance_Script.bat"

Start in: \\<machine>.<domain>.local\Users\<username>\OneDrive - <City One Drive Name>\Desktop\NightlyScript\

3
  • 2
    Do you write your py scripts so they log errors and traceback to a text file on the server? We set our tasks up as 'Run whether user is logged on or not', highest privileges is off, password is saved and all scripts are sitting on the task scheduling server/PC with mapped paths (not UNC). Make sure the user you specify is an actual user with privileges/access to read/write any paths/datasets used in the script and if using Enterprise GDB connection files, store those with the scripts or in an actual path, not the ArcMap style "Database Connections\some_connection.sde" syntax. Commented May 5, 2022 at 22:29
  • Yes, the logs are currently being written to our GIS data server. In my python code, database connections are written as r"\\<server>\\<drivename>\\path\\to\\sdeconnection\\enterprisegdb.sde", and log path is as such: r"\\server\\drivename\\path\\to\\log\\GDB Maintenance Log\\" Commented May 9, 2022 at 14:15
  • @user2856 Interestingly, when switching the settings to Not Store the password, and uncheck run with highest privileges, that seems to have fixed the error. My task scheduler has now successfully ran at a test time. Thank you. Commented May 9, 2022 at 14:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.