<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python Script not running through Task Scheduler on Windows Server 2008 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164247#M12582</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just wanted to give an update - I was able to get the script to run! Turned out, the problem had to deal with the quotations in the Action settings. The argument (script.py) did require quotations, but the program/script (python.exe) and the start in folder did not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for the help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-jenna&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 May 2012 15:50:11 GMT</pubDate>
    <dc:creator>JennaBernabe1</dc:creator>
    <dc:date>2012-05-21T15:50:11Z</dc:date>
    <item>
      <title>Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164240#M12575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a python script I am trying to schedule on a server that's operating on Windows Server 2008.&amp;nbsp; I'm able to get the script to run manually from that server, but when I create a task to start it, there are no results. On the task scheduler window, the task shows that it's running, but there are no outputs or any other indication that it's actually running.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since the script runs fine when I manually start it, I'm assuming that the problem is within a setting on Task Scheduler or the server itself.&amp;nbsp; I'm a novice working with scripts and task scheduler, so there might be something I'm overlooking..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any insight to this problem is appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 14:11:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164240#M12575</guid>
      <dc:creator>JennaBernabe1</dc:creator>
      <dc:date>2012-05-17T14:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164241#M12576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jenna,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A quick google search threw up this &lt;/SPAN&gt;&lt;A href="http://stackoverflow.com/questions/2725754/schedule-python-script-windows-7"&gt;thread&lt;/A&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 14:38:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164241#M12576</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2012-05-17T14:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164242#M12577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a few simple suggestions to start with.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.) Under the General tab, make sure you check Run with highest privileges&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2.) Under the Actions tab, make sure you put the path to the python script (or bat file that calls the python script) in the Start in box.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this will solve your problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 14:41:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164242#M12577</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-05-17T14:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164243#M12578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks so much for the link to the thread and the suggestions!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I made sure that the highest privileges was checked, and the path to the python script is in the "Start In" box.&amp;nbsp; I also tried calling the python.exe as the program with the actual script as the argument, but with no luck.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 15:37:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164243#M12578</guid>
      <dc:creator>JennaBernabe1</dc:creator>
      <dc:date>2012-05-17T15:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164244#M12579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You might also want to create an Environmental Variable called PYTHONPATH that points to the directory where you python.exe file is located.&amp;nbsp; Unless I added this Environmental Variable on my Windows Server 2008, I had to include the full path to the .py file and not just the name of the .py file itself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also always call my .py files from a bat file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 15:55:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164244#M12579</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-05-17T15:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164245#M12580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the suggestion Michael. I'm not familiar with creating Environmental Variables - but I do call out the full file path names in scheduler. Would creating the environmental variable make a difference if the file paths are listed in scheduler?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My coworker tried running it as a batch program and is getting the same issue where scheduler says it's running, but the script doesn't actually run.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 May 2012 13:32:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164245#M12580</guid>
      <dc:creator>JennaBernabe1</dc:creator>
      <dc:date>2012-05-18T13:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164246#M12581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post the bat file that your co-worker tried to run?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 May 2012 14:53:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164246#M12581</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-05-18T14:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164247#M12582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just wanted to give an update - I was able to get the script to run! Turned out, the problem had to deal with the quotations in the Action settings. The argument (script.py) did require quotations, but the program/script (python.exe) and the start in folder did not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for the help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-jenna&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 May 2012 15:50:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164247#M12582</guid>
      <dc:creator>JennaBernabe1</dc:creator>
      <dc:date>2012-05-21T15:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164248#M12583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having the same problems and I cannot, for the life of me, get the script to run. I created the script in ModelBuilder and it works fine. I port it to Python and it works fine. But Task Scheduler will not run it... not on a schedule and not by clicking the task and hitting RUN.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 17:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164248#M12583</guid>
      <dc:creator>BrianO_keefe</dc:creator>
      <dc:date>2014-05-19T17:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164249#M12584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Brian:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you provide a screenshot of the Edit Action page you have setup in Task Scheduler?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also do you have the Task set to 1.) Run whether is logged on or not&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2.) Run with highest privileges (even if the user is an Administrator on the server)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2014 18:03:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164249#M12584</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2014-05-19T18:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164250#M12585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had the same problem - built a model that works fine, exported to python script which ran fine - but could not seem to get it to run as scheduled task and pulled my hair out for two days before I got it to work on my machine. There were many posts offering various solutions and I tried all of them to no avail. I tried running the script through a batch file, I tried changing the "start in" location, I tried running cmd as the program with various options in the arguments list. I guess all of these things were worth trying as they did seem to solve the problem for some people, but not others - namely me!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This finally worked for me (in addition to a fifth of whiskey):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used this snippet to be sure I had the correct path to python.exe, as there are several instances of the file on my machine:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14164306980616470" jivemacro_uid="_14164306980616470"&gt;
&lt;P&gt;import sys&lt;/P&gt;
&lt;P&gt;import platform&lt;/P&gt;
&lt;P&gt;import imp&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;print("Python EXE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : " + sys.executable)&lt;/P&gt;
&lt;P&gt;print("Architecture&amp;nbsp;&amp;nbsp; : " + platform.architecture()[0])&lt;/P&gt;
&lt;P&gt;print("Path to arcpy&amp;nbsp; : " + imp.find_module("arcpy")[1])&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;raw_input("\n\nPress ENTER to quit")&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created a basic task with task scheduler.&lt;/P&gt;&lt;P&gt;Then under the "task actions" tab, I used the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;Program/Script&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;My full path to python.exe:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;C:\Python27\ArcGIS10.3\python.exe&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;Add Arguments:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The full path to my script - in my case:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;C:\Users\wwbill22\Documents\ArcGIS\PyScripts\runModel.py&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(note that you will need to enclose in double quotes if your path contains spaces).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, my task runs as scheduled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I should note that under general task properties I have NOT checked "Run with Highest Privileges" NOR have I selected "Run whether user is logged on or not"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I try to use either of those options I get the familiar 0x1 error. Which is unfortunate, but I can live with leaving the user logged on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also found out as I researched this issue that I did not have to export the model to a python script to schedule it as a task. Since my model was saved in a toolbox, I could simply write a script to import the toolbox and call the model directly. This has the added value of not having to update my script if I decide to edit my model tool in the future. Didn't have a bearing on my task scheduler issue but I thought it was interesting nonetheless.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the script I used to achieve that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14164314308392589 jive_text_macro" jivemacro_uid="_14164314308392589"&gt;
&lt;P&gt;import arcpy&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Import custom toolbox&lt;/P&gt;
&lt;P&gt;arcpy.ImportToolbox("L:/GIS/Toolboxes/Collin_Tools.tbx")&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Run tool in the custom toolbox.&amp;nbsp; The tool is identified by&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp; the tool name and the toolbox alias.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Model3_collintools()&lt;/P&gt;
&lt;P&gt;except arcpy.ExecuteError:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(arcpy.GetMessages(2))&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps someone else out!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 21:14:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164250#M12585</guid>
      <dc:creator>collindegueurce</dc:creator>
      <dc:date>2014-11-19T21:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164251#M12586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This was my same issue, I put quotes on the script.py and it worked, Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 18:25:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164251#M12586</guid>
      <dc:creator>KurtRadamaker</dc:creator>
      <dc:date>2017-08-04T18:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164252#M12587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK I finally got it to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was having similar kind of problem and spent an entire day trying several different approaches mentioned in this thread and other non-gis forum. None of the solutions worked for me. I had written a script which ran fine when I ran it as a scheduled task when I was logged in. However, it would always fail when set to run whether the user is logged on or not. I was getting 0X1 error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My script is set to output current date and time in the beginning when it runs along with other python messages after various arcpy functions get executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I realized that despite being logged off, the script would still print the current date and stop working from that point on before arcpy functions were being called(There were no error messages being output on the logfile except the date). I then realized that it is not that the task scheduler is not finding the file as seemed to be the case with lot of people with that&amp;nbsp;0X1 error code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also have other python scripts that had been running fine as scheduled tasks without having to be logged on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case, I found out that it is the arccatalog generated path that the script was referring to ran into permissions issue when being executed. So I ended up creating copy of database and arcgis online connections in Arccatalog to a local folder in my hard drive and pointed my variables to that location instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;Changed code that works.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;arcpy.env.workspace = "C:\\GIS_Data\\sdeconn\\dbconn.sde"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;mytable = "GISData.dbo.my_tbl"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;World_GeocodeServer = "C:\\GIS_Data\\sdeconn\\arcgis_geocode.ags\\World.GeocodeServer"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;output_table = "GISData.DBO.Batch_Geocode"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;geographytable = "GISData.dbo.GEOGRAPHY"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Previous code that did not work&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;mytable = "Database Connections\\dbconn.sde\\GISData.dbo.my_tbl"&lt;BR /&gt;World_GeocodeServer = "GIS Servers\\arcgis_geocode\\World.GeocodeServer"&lt;BR /&gt;output_table = "Database Connections\\dbconn.sde\\GISData.DBO.Batch_Geocode"&lt;BR /&gt;geographytable = "Database Connections\\dbconn.sde\\GISData.dbo.GEOGRAPHY"&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the task scheduler side, I just created a basic task and pointed it to my script. Left the start in and argument values blank. The login info I provided is an administrator account for the server. I am on Windows server 2012 but the task is running as Windows Vista/Windows Server 2008(default setting on my system)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="396839" alt="Task Scheduler Settings" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/396839_Task_Scheduler.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Everything works now without having to be logged on. Hope this will be helpful to someone.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Feb 2018 20:30:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164252#M12587</guid>
      <dc:creator>Anish_Adhikari</dc:creator>
      <dc:date>2018-02-16T20:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164253#M12588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;for future reference: this issue will also occur if you're accessing files from network dives.&lt;/P&gt;&lt;P&gt;be sure to use UNC paths not the mapped network drive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.lifewire.com/unc-universal-naming-convention-818230" title="https://www.lifewire.com/unc-universal-naming-convention-818230"&gt;The Definition of Universal Naming Convention (UNC)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Feb 2018 21:53:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164253#M12588</guid>
      <dc:creator>Lake_Worth_BeachAdmin</dc:creator>
      <dc:date>2018-02-16T21:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164254#M12589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This made my day, after an hour search. I wasnt inputting the path to python.exe, only path to the file I wanted to run inside the program/script section.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2018 22:52:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164254#M12589</guid>
      <dc:creator>AlexLife</dc:creator>
      <dc:date>2018-03-28T22:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164255#M12590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Additional tidbit- When logged on as myself,&amp;nbsp;my script ran fine&amp;nbsp;without the&amp;nbsp;"database.DBO." prefix on the table&amp;nbsp;names. The task-scheduler account, however, would throw errors if this prefix wasn't&amp;nbsp;included when&amp;nbsp;accessing the SDE tables from the script. Probably won't help anyone, but I wasted a few hours before this finally occurred to me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Sep 2018 22:55:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/164255#M12590</guid>
      <dc:creator>MikeHelten</dc:creator>
      <dc:date>2018-09-17T22:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/1022105#M59736</link>
      <description>&lt;P&gt;If your scheduled task completes successfully (code 0x0), but nothing seems to happen as the result of your code, the cause may be how you are using relative paths in your script. Yes, you may have enter fully qualified paths to python.exe and your script (and maybe filled the "start in" item too) when configuring the scheduled task BUT the scheduled task itself starts from C:\win32 and certain relative path syntax that work in an IDE (e.g., IDLE, pyCharm, etc.) will not work as a scheduled task. For example, a script containing a relative path of /pathToItem&amp;nbsp;works just fine in IDLE. However, if you print out the path (to a txt file) that is created from when executed from Task Scheduler you can see that the script is actually looking for the resource in&amp;nbsp;C:\win32\pathToItem. Obviously, this isn't going to work. Changing the relative path to&amp;nbsp;./pathToItem is a simple fix that may allow your script to truly execute successfully from Task Scheduler.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 14:45:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/1022105#M59736</guid>
      <dc:creator>bspivey</dc:creator>
      <dc:date>2021-02-01T14:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/1147075#M63854</link>
      <description>&lt;P&gt;Adding this as it might help.&amp;nbsp; I had about 5 Python scripts working under Task Scheduler for over a year and then, nothing.&amp;nbsp; They were being run from MS batch files that identified the location of Python and the script file with nothing else in them, and if I ran that batch file they would work.&amp;nbsp; The Task Scheduler tasks were starting, and then stopping after 5 seconds or thereabouts, but no errors or strange logs anywhere.&amp;nbsp; I had logging in my Python files that weren't being hit, so something was stopping it early on.&amp;nbsp; Finally decided to dummy down my Python file until they did work through the Task Scheduler and found that the library 'pyodbc' that I used to call SQL Server was not loading.&amp;nbsp; Still trying to figure out why that library isn't being opened in Task Scheduler but I at least I found something that was causing the problem.&amp;nbsp; I will update if I find out more.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 17:22:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/1147075#M63854</guid>
      <dc:creator>JeffreyWilkerson</dc:creator>
      <dc:date>2022-02-23T17:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not running through Task Scheduler on Windows Server 2008</title>
      <link>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/1187920#M64861</link>
      <description>&lt;P&gt;After I posted the last reply I continued to have issues.&amp;nbsp; I would fix the code, get it set up to run in Task Scheduler and then after 2 to 4 days the Tasks would stop running.&amp;nbsp; The Task Scheduler code was not returning a code of 0, which indicates the task ran without error, but I couldn't track down any of the errors on the internet.&amp;nbsp; I found some code on the internet (not sure where and I apologize to whomever I'm not crediting it with) that was for a MS batch file to run until the code became 0, but the task started and ran the the script a number of times (21 in my case) without ever achieving a code of 0.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;SET log_file=d:\Projects\Ridership\Logs\RailLog%date%_%time%.txt

ECHO ######################################################################### &amp;gt;&amp;gt; %log_file%
ECHO Batch start %date% Time: %time% &amp;gt;&amp;gt; %log_file%

SET /A _counter=1
SET /A _max_tries=21
SET /A _wait_seconds=2

:LOOP

IF %_counter%==%_max_tries% (
ECHO GOTO END - max tries of [%_max_tries%] reached. &amp;gt;&amp;gt; %log_file%
GOTO :END
)

ECHO Attempt: [%_counter%] &amp;gt;&amp;gt; %log_file%

ECHO Error level before python: [%errorlevel%] &amp;gt;&amp;gt; %log_file%

:: Use the python exe to run our batch script.
:: Use full path to both python exe and python script.
"d:\python3\envs\arcgispro2_8-py3\pythonw.exe" d:\Projects\Ridership\DilaxDailyRailDownload.py

ECHO Error level after python: [%errorlevel%] &amp;gt;&amp;gt; %log_file%

:: Check the python return code. If success then exit Else pause and try again.
IF %errorlevel%==0 (
ECHO GOTO END - success &amp;gt;&amp;gt; %log_file%
GOTO :END
)
ELSE (
ECHO Wait for some time. &amp;gt;&amp;gt; %log_file%
TIMEOUT %_wait_seconds% &amp;gt; NUL
)

ECHO After pause %date% Time: %time% &amp;gt;&amp;gt; %log_file%

:: Increment the counter.
SET /A _counter=%_counter%+1

GOTO :LOOP

:END
ECHO Batch end %date% Time: %time% &amp;gt;&amp;gt; %log_file%&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I feel like I tried everything. Making sure the paths worked, changing the location of the ArcGIS Pro Python library to something more general, checking the validity of the System account used to run the code, and anything else I could find.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In final desperation I decided to go back to the ArcGIS 2.7 Python, as it seems like all of this started after I chose to upgrade it all to Pro and Python 3.x.&amp;nbsp; After uninstalling Pro and all of the Python libraries associated with it, and reinstalling ArcGIS Desktop 10.8.2 with Python 2.7 (and making some minor changes to the Python files to reflect running them in 2.7), everything started to work again and I haven't had any issues with the Task Scheduler for over a month now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I firmly believe that the problem lies in using the ArcGIS Pro Python as the tool to run the code through Task Scheduler.&amp;nbsp; I don't think it's in the libraries, but it must have something to do with the licensing of arcpy through Pro.&amp;nbsp; That's the only thing that seems like it would explain why it works sometimes, and then just quits working, and with error codes that Microsoft doesn't understand.&amp;nbsp; When the problem first started occurring, it seemed like I could log into ArcGIS Pro and then things would work.&amp;nbsp; In fact, an Esri tech working with me on a remote session also verified that seemed like what was happening, but then, after a while, that didn't even resolve the situation.&lt;/P&gt;&lt;P&gt;At this point, I'm happy.&amp;nbsp; I can sleep at night.&amp;nbsp; I don't go to work and spend 8+ hours chasing ghosts that just end up with nothing to show for it.&amp;nbsp; Yet, I know that I will eventually have to move away from 2.7 as Desktop will someday be deprecated. My only thought at this point is to generate a stand alone license for Pro (not use ArcGIS Online for its licensing) and set up Python 3.x on the server using that.&amp;nbsp; But until I 'have' to move away from 2.7, I'm content. May you someday achieve peace on this subject as well.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 17:22:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-not-running-through-task-scheduler/m-p/1187920#M64861</guid>
      <dc:creator>JeffreyWilkerson</dc:creator>
      <dc:date>2022-06-29T17:22:49Z</dc:date>
    </item>
  </channel>
</rss>

