<?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 Python Script not executing as sheduled in a .bat file in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620692#M4196</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a script that runs well and as scheduled on a pc. It cant however be executed when scheduled on the server. It starts of and indicates it is complete within 2 seconds&lt;/P&gt;&lt;P&gt;Looked at all options discussed in this forum. Not able to resolve issue though. Last I tried to use is&amp;nbsp; &lt;A class="link-titled" href="https://support.esri.com/en/technical-article/000015230" title="https://support.esri.com/en/technical-article/000015230"&gt;ESRI Support- Scheduling Tasks&lt;/A&gt;&amp;nbsp;and cant seem to understand what the highlighted below is and where it needs to be put in the task scheduler.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="469780" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/469780_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;Would highly appreciate help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Oct 2019 05:24:45 GMT</pubDate>
    <dc:creator>wwnde</dc:creator>
    <dc:date>2019-10-30T05:24:45Z</dc:date>
    <item>
      <title>Python Script not executing as sheduled in a .bat file</title>
      <link>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620692#M4196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a script that runs well and as scheduled on a pc. It cant however be executed when scheduled on the server. It starts of and indicates it is complete within 2 seconds&lt;/P&gt;&lt;P&gt;Looked at all options discussed in this forum. Not able to resolve issue though. Last I tried to use is&amp;nbsp; &lt;A class="link-titled" href="https://support.esri.com/en/technical-article/000015230" title="https://support.esri.com/en/technical-article/000015230"&gt;ESRI Support- Scheduling Tasks&lt;/A&gt;&amp;nbsp;and cant seem to understand what the highlighted below is and where it needs to be put in the task scheduler.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="469780" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/469780_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;Would highly appreciate help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2019 05:24:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620692#M4196</guid>
      <dc:creator>wwnde</dc:creator>
      <dc:date>2019-10-30T05:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not executing as sheduled in a .bat file</title>
      <link>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620693#M4197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you layers in are an sde database you might need to include the full path of the layer in your script.&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;From&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;Database Connections\Geodatabase_blah_blah.sde&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;To&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;C:\Users\blah\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\Geodatabase_blah_blah.sde\featuredataset\feature class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2019 20:21:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620693#M4197</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2019-10-30T20:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not executing as sheduled in a .bat file</title>
      <link>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620694#M4198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This script downloads a feature service from ArcGIS online and saves it to&lt;/P&gt;&lt;P&gt;a local server. So not an SDE database.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2019 03:23:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620694#M4198</guid>
      <dc:creator>wwnde</dc:creator>
      <dc:date>2019-10-31T03:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not executing as sheduled in a .bat file</title>
      <link>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620695#M4199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would check to make sure you have the full UNC path to the server.&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;\\\\server\\folder\\folder\\&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;And you might consider using, scheduler has to have the full server path. At least that is the case for me.&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;pyodbc.connect&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;import pyodbc&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;conn = pyodbc.connect('Driver={SQL Server};' 'Server=server_name;' 'Database=db_name;' 'Trusted_Connection=yes;')&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2019 17:41:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620695#M4199</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2019-10-31T17:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not executing as sheduled in a .bat file</title>
      <link>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620696#M4200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is this your first attempt at running a python script from a bat file?&amp;nbsp; If so, maybe you want to start with a simpler script than downloading a feature service from AGOL to a local server as there might be multiple issues with a more complex script.&amp;nbsp; Once you get the simple script to execute as expected, than add the more complex code.&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;Does you server have access to the internet?&amp;nbsp; Due to security issues at my org, internet access is no longer allowed by default for servers.&amp;nbsp; Not sure this applies to you, but something to check with your IT staff.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2019 19:12:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620696#M4200</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2019-10-31T19:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not executing as sheduled in a .bat file</title>
      <link>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620697#M4201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just run it as a python file not as a .bat file?&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="360" src="https://community.esri.com/legacyfs/online/471120_pastedImage_1.png" width="333" /&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;Optionally, you can execute the flavor of python .exe you want in the Program/script window, and call the .py file as an argument...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2019 19:43:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620697#M4201</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2019-10-31T19:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not executing as sheduled in a .bat file</title>
      <link>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620698#M4202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The server has internet connection. Multiple other python 2 scripts running well. Issue was new script runs on python 3, I changed to redirect the exe file to 3 and that is causing issues.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Nov 2019 04:03:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620698#M4202</guid>
      <dc:creator>wwnde</dc:creator>
      <dc:date>2019-11-01T04:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script not executing as sheduled in a .bat file</title>
      <link>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620699#M4203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;   &lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Optionally, you can execute the flavor of python .exe you want in the Program/script window, and call the .py file as an argument...&lt;/SPAN&gt;&lt;/P&gt; &lt;/BLOCKQUOTE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;Quoted suggestion seems to work. I ran the &lt;A href="https://www.esri.com/arcgis-blog/products/product/analytics/scheduling-a-python-script-or-model-to-run-at-a-prescribed-time/" rel="nofollow noopener noreferrer" target="_blank"&gt;ESRI's&lt;/A&gt;&amp;nbsp;given code below&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; sys
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; platform
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; imp

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Python EXE : "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;executable&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Architecture : "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; platform&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;architecture&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Path to arcpy : "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; imp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;find_module&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"arcpy"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;and it pointed me to the following exe file&lt;IMG __jive_id="471103" alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/471103_Capture.PNG" /&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;P&gt;When changed to:\python.exe, it&amp;nbsp;all went fine. I too think, it was executing in cd&amp;nbsp;and not in the background (within task scheduler when logged off the server)&amp;nbsp;because I had input mapped directory paths&amp;nbsp; as opposed to the full directory paths.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:29:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/python-script-not-executing-as-sheduled-in-a-bat/m-p/620699#M4203</guid>
      <dc:creator>wwnde</dc:creator>
      <dc:date>2021-12-12T02:29:09Z</dc:date>
    </item>
  </channel>
</rss>

