<?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 Stopping/Starting ArcGIS services using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376772#M29744</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to find a way to start and stop a service in python so I can automate some updates. I have found the the agssom.exe script in Arcscripts. I place it in c:\windows\system32. The code I am using in my pytho script is below. The script runs with out any errors, but the service doesn't stop. Am I missing a step or does anybody have a better way of doing this? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are running ArcGIS 10 with python 2.6.5&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PathToAGSSOM = r"C:\\windows\\system32\\ArcSOM.exe"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;server = "VULCAN"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;command = "-x" # use -x for stop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;service = "Narcotics"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# use AGSSOM.exe to start map service from command line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;commandLine = PathToAGSSOM + " " + server + " " + command + " " + service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;os.system(commandLine)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print "Finished"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 May 2012 13:28:58 GMT</pubDate>
    <dc:creator>JustinNettleton</dc:creator>
    <dc:date>2012-05-16T13:28:58Z</dc:date>
    <item>
      <title>Stopping/Starting ArcGIS services using Python</title>
      <link>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376772#M29744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to find a way to start and stop a service in python so I can automate some updates. I have found the the agssom.exe script in Arcscripts. I place it in c:\windows\system32. The code I am using in my pytho script is below. The script runs with out any errors, but the service doesn't stop. Am I missing a step or does anybody have a better way of doing this? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are running ArcGIS 10 with python 2.6.5&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PathToAGSSOM = r"C:\\windows\\system32\\ArcSOM.exe"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;server = "VULCAN"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;command = "-x" # use -x for stop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;service = "Narcotics"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# use AGSSOM.exe to start map service from command line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;commandLine = PathToAGSSOM + " " + server + " " + command + " " + service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;os.system(commandLine)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print "Finished"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 13:28:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376772#M29744</guid>
      <dc:creator>JustinNettleton</dc:creator>
      <dc:date>2012-05-16T13:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping/Starting ArcGIS services using Python</title>
      <link>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376773#M29745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Justin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will not need the full path of the executable since it's copied to the System32 directory.&amp;nbsp; Also, a couple other notes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-the exe is 'AGSSOM.exe', you had 'ArcSOM.exe'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-when specifying 'r' before a path, you will just need to use one '\' between directories&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try the following instead:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os

# variables
server = "VULCAN"
command = "-x" # use -x for stop
service = "Narcotics"

# use AGSSOM.exe to start map service from command line
commandLine = "agssom " + server + " " + command + " " + service
os.system(commandLine)

print "Finished"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, be sure that 'C:\Windows\System32' is referenced in your PATH environment variable.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:24:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376773#M29745</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T17:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping/Starting ArcGIS services using Python</title>
      <link>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376774#M29746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the response. I used the code you provided and again it ran, but the service did not stop. I am not sure what your last line means. "Also, be sure that 'C:\Windows\System32' is referenced in your PATH environment variable. " Not a real advanced programmer, can you tell me where I would need to check/set this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 14:16:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376774#M29746</guid>
      <dc:creator>JustinNettleton</dc:creator>
      <dc:date>2012-05-16T14:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping/Starting ArcGIS services using Python</title>
      <link>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376775#M29747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Right-click on 'My Computer' &amp;gt; Properties &amp;gt; Advanced System Settings &amp;gt; Advanced tab.&amp;nbsp; You should see an 'Environment Variables...' button there.&amp;nbsp; Click this and then you will see 'Path' under System Variables.&amp;nbsp; 'C:\Windows\System32' should be listed here.&amp;nbsp; You can test this by simply typing 'agssom' within a command prompt.&amp;nbsp; If usage variables are returned, then you are good to go.&amp;nbsp; Also, be sure you are refreshing the GIS Server connection in the Catalog window to see that the service has been stopped.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 14:34:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376775#M29747</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-05-16T14:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Stopping/Starting ArcGIS services using Python</title>
      <link>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376776#M29748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, that did the trick.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 14:46:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stopping-starting-arcgis-services-using-python/m-p/376776#M29748</guid>
      <dc:creator>JustinNettleton</dc:creator>
      <dc:date>2012-05-16T14:46:52Z</dc:date>
    </item>
  </channel>
</rss>

