<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Execute Client Program with ST</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f80f902624/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f80f902624/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/f80f902624/</id><updated>2021-05-19T09:15:16.214000Z</updated><subtitle>Recent posts to Execute Client Program with ST</subtitle><entry><title>Execute Client Program with ST</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f80f902624/?limit=25#2309" rel="alternate"/><published>2021-05-19T09:15:16.214000Z</published><updated>2021-05-19T09:15:16.214000Z</updated><author><name>alien</name><uri>https://forge.codesys.com/u/alien/</uri></author><id>https://forge.codesys.comcbb079997a1a3ccb69bb5767521ae5d8677c7345</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi &lt;a class="user-mention" href="/u/eschwellinger/"&gt;@eschwellinger&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;I hope you read my message! I am in S.O.S situation indeed . .&lt;br/&gt;
Actually, I have a big problem may be you can help me :&lt;br/&gt;
I am working on Windows 10 x64 and I need to execute a batch file in CodeSyS for some purpose &lt;br/&gt;
but SysProcess Execute Command is not working ! I have done these steps carefully:&lt;br/&gt;
1 - &lt;br/&gt;
CODESYSControl.cfg&lt;br/&gt;
&lt;span&gt;[SysProcess]&lt;/span&gt;&lt;br/&gt;
Command=AllowAll&lt;br/&gt;
&lt;span&gt;[SysFile]&lt;/span&gt;&lt;br/&gt;
Windows.WorkingDirectory=C:\ProgramData\CODESYS\CODESYSControlWinV3x64\801BFF8C&lt;/p&gt;
&lt;p&gt;2 - Create a Py file &lt;br/&gt;
3- call Py file in batch file and test the bat.file to be sure if it works fine.&lt;br/&gt;
4- Create a POU file in codesys&lt;/p&gt;
&lt;p&gt;Command     : STRING(200):='C:\Users\tsw08\Desktop\Bat.bat';&lt;/p&gt;
&lt;p&gt;IF fbTimer1.Q  THEN&lt;br/&gt;
        //Reset it and flash again&lt;br/&gt;
        counter2 := counter2 +1;&lt;br/&gt;
        fbTimer1(IN:= FALSE);&lt;br/&gt;
        Test_2 := SysProcessExecuteCommand(pszComand:= Command , pResult:= ADR(dutResult));&lt;br/&gt;
END_IF&lt;/p&gt;
&lt;p&gt;This is my bat.file &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="nv"&gt;@echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;off&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;"C:\Users\tsw08\Desktop\"&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;and this is my Python script :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;codimport&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Hello,CodeSys'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'log.txt'&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Execute Client Program with ST</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f80f902624/?limit=25#ed1c" rel="alternate"/><published>2020-02-27T14:01:46.230000Z</published><updated>2020-02-27T14:01:46.230000Z</updated><author><name>BrotherMaestro</name><uri>https://forge.codesys.com/u/brothermaestro/</uri></author><id>https://forge.codesys.comdcc7be52542ad092a640185deb2da82b215a5a86</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you kindly for your response! &lt;br/&gt;
This was the obvious flaw in my program that I failed to understand. &lt;/p&gt;
&lt;p&gt;In hindsight it makes perfect sense that to perform commands you &lt;br/&gt;
need to be logged into a device.... &lt;/p&gt;
&lt;p&gt;Everything is working now. Thank you again.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Execute Client Program with ST</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f80f902624/?limit=25#3525" rel="alternate"/><published>2020-02-27T14:01:45.408000Z</published><updated>2020-02-27T14:01:45.408000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.com244cdb02d284e95f0f50b957b037aaa9d9c086d2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
why not using the installed Control Win runtime?&lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
Edwin&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Control Win.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=3274"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Execute Client Program with ST</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/f80f902624/?limit=25#8112" rel="alternate"/><published>2020-02-27T14:01:45.090000Z</published><updated>2020-02-27T14:01:45.090000Z</updated><author><name>BrotherMaestro</name><uri>https://forge.codesys.com/u/brothermaestro/</uri></author><id>https://forge.codesys.comf08a59a750e0ab8d9da039164a8b32689651d6c5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello Team. &lt;/p&gt;
&lt;p&gt;I've spent the day reading through the forums to seek a solution to my problem. &lt;br/&gt;
Perhaps I have missed something obvious which is why a solution eludes me... &lt;/p&gt;
&lt;p&gt;I'm trying to run an executable file through my program POU. &lt;br/&gt;
This is what I've done so far.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;CODESYSControl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cfg&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;SysProcess&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Command&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;AllowAll&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;SysFile&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Windows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WorkingDirectory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nl"&gt;C&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;ProgramData&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;CODESYS&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;CODESYSControlWinV3x64&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="mi"&gt;801&lt;/span&gt;&lt;span class="n"&gt;BFF8C&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;AND &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;command1&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;STRING&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'C:\OpenGL\GUIproject\Release\GUIproject.exe'&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;xExecuteSysP&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="nv"&gt;xExecuteSysP&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;FALSE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;SysProcess&lt;/span&gt;.&lt;span class="nv"&gt;SysProcess&lt;/span&gt; &lt;span class="nv"&gt;Execute&lt;/span&gt; &lt;span class="nv"&gt;Command&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;pszComand&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;command1&lt;/span&gt;,  &lt;span class="nv"&gt;pResult&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="ss"&gt;))&lt;/span&gt;&lt;span class="c1"&gt;;*)&lt;/span&gt;
   &lt;span class="nv"&gt;SysProcess&lt;/span&gt;.&lt;span class="nv"&gt;SysProcessCreate&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pszApplication&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;command2&lt;/span&gt;, &lt;span class="nv"&gt;pszCommandLine&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;command1&lt;/span&gt;, &lt;span class="nv"&gt;ulHide&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;, &lt;span class="nv"&gt;pResult&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;PS: I made a button to launch the executable through the visualization and that works, so the file and the path are fine. I get no compile errors either and the rest of the program seems to run fine. &lt;br/&gt;
I'm working on Windows 7, in a simulation as I do not have access to a device just yet.&lt;br/&gt;
Note: The commented solution did not work either.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>