<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Call python script for codesys from powershell and read return value</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/814da99840/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/814da99840/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/814da99840/</id><updated>2020-07-30T17:29:20.959000Z</updated><subtitle>Recent posts to Call python script for codesys from powershell and read return value</subtitle><entry><title>Call python script for codesys from powershell and read return value</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/814da99840/?limit=25#106a" rel="alternate"/><published>2020-07-30T17:29:20.959000Z</published><updated>2020-07-30T17:29:20.959000Z</updated><author><name>srigan1986</name><uri>https://forge.codesys.com/u/srigan1986/</uri></author><id>https://forge.codesys.com54d7aad2d03b8d672d10894f61a062b7c62435e2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello All&lt;/p&gt;
&lt;p&gt;I need some help. I am creating a deployment tool which works in Windows and the goal is to generate deliverables for a variety of platforms. I want to run the powershell script to call the python scripts prepared with Codesys script engine API. I used start-process cmdlet like&lt;/p&gt;
&lt;p&gt;$ImportResult = Start-Process -FilePath "path of CoDeSys.exe" -ArgumentList '--Profile="our codesys profile"', '--runscript="Testme.py"'&lt;/p&gt;
&lt;p&gt;I need the return value from this execution to make further decisions down the sequence.&lt;/p&gt;
&lt;p&gt;I see nothing when I print the $ImportResult.&lt;/p&gt;
&lt;p&gt;The code of Testme.py is:&lt;/p&gt;
&lt;p&gt;from &lt;strong&gt;future&lt;/strong&gt; import print_function&lt;br/&gt;
import os&lt;br/&gt;
import sys&lt;/p&gt;
&lt;p&gt;print("Hi Codesys ! I am being tested ")&lt;br/&gt;
sys.exit(1)&lt;/p&gt;
&lt;p&gt;I guess the python might return 1 but not Codesys.exe ....Here the Codesys window does not close.&lt;br/&gt;
I tried with --noUI as well...Here as well I dont read the return value. $Lastexitcode also did not help&lt;/p&gt;
&lt;p&gt;I would be glad to see a powershell script reading the exitcode of the  python script which does a set of actions in codesys.&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>