System.util.execute

Let’s back up a moment. From the top of the post, xion8x8 is trying to run batch file. Is there, in fact, a gui that needs to be spawned?

He hasn’t specified what the batch file is doing. It seems to be working, you just cannot see the gui.

Dear All,

Please find attached file for the test.txt (batch file is not allowed, so i upload .txt). it just print a sentence on command prompt and pause, then press any key to exit and close the command prompt.

to recap, the script is running on button actionperformed event, it able to call up command prompt, print the sentence in the batch file and pause. Press key will close the command prompt. Same script in Tag event script but command prompt is not showing up.

Thank you.
Test.txt (63 Bytes)

Commands in the batch file is working but all GUI will not be appeared but they are executed. Tested by running command to create files and copy files and etc.

Thanks for the help

2 posts were split to a new topic: System.util.execute question

Hello all,

I have been working on something like this to run a OPC-UA application which must be run as an administrator from a gateway script. There is a GUI associated with the application - but the clients would not see that since they are not logged into the server.

I am at the point where I can run this using subprocess in the script console if I am logged in on the server, but I am getting errors in my wrapper log “Cannot start service from the command line or a debugger” when I try to run the same call in the gateway script.

Some things I have tried that also only work in the client scope:
Changing the Ignition Service to login as admin account instead of local system

Using a batch file to launch the application I don’t get any error and my wrapper shows
C:\Program Files\Inductive Automation\Ignition>start C:“Program Files”\Advosol\uaPLUS.Net4.exe

My code is in tag change script which works when called from client:

path = "C:\\Users\\admin\\opc_batch_file.bat"
import subprocess as sp
sp.call([path], shell=True)

I have a ticket open for this but I want to see how others have dealt with this - Is there an IT workaround for what I am trying to do? Specifically the goal is for Ignition to call the OPC-UA application for the on the backup gateway in a redundant system when the primary fails based on the OPC-UA connected gateway tag status.

AFAIK Windows does not allow services to spawn programs with or interact with a GUI.

edit: this SO post says you can change a setting that let’s it launch but you won’t actually see it?

Thanks Kevin,

I did try to allow desktop applications checkbox, I didn’t see any sign that the application was running though.
I realized that running a client on the server computer with a startup script solves my issue of getting the OPC program to run. BUT… Now I have to figure out how to get the client to start up.

Using the Client Launcher I have a batch file that contains the following
start C:\Users\admin\AppData\Roaming"Inductive Automation"“Client Launcher”\clientlauncher.exe scope=C project=name windowmode=window

The batch file launches the client which launches the OPC-UA application.

Now I had a new idea:
If I run the client on startup then use a client timer script to check the value of a gateway tag then I can use that to trigger my subprocess call then reset the trigger tag.
If I move the batch file to run, shell:common startup I see a connect error while my gateway is starting. How would I add a delay or is this even necessary? If it takes a long time to start the gateway, would the client launcher give up?
I tested this setup and it appears to work, but is there a better way? version 7.9.11

How about using task scheduler to launch clients if they aren’t running? for instance if someone logged in to server and closes it, could you run a scheduled check and run the batch file that way instead of once on startup?