Help system.util.sendRequest to run .exe in Gateway

I am trying to have a project script run a .exe on the gateway and then return the results to the client project script. If running the .exe in a similar manner on the client, it works just fine. Here I need the .exe to run on the gateway. The .exe is on the gateway C drive with GatewayLocalDir pointing to it.

Here is the Gateway Message Handler:

def handleMessage(payload):
    import subprocess
    try:
        path = payload["path"]
        process = subprocess.Popen([path], stdout=subprocess.PIPE)
        output, _ = process.communicate(timeout=10)
        return output
    except Exception as e:
        return str(e)

Here is a snippet of the project’s script:

try:
    import base64
    from java.io import ByteArrayInputStream
    from javax.imageio import ImageIO

    payload = {"path": GatewayLocalDir}
    result = system.util.sendRequest("Gateway", "runLabelGenHandler", payload)
                
    image_bytes = base64.b64decode(result)
    input_stream = ByteArrayInputStream(image_bytes)
    return ImageIO.read(input_stream)

In the end, it’s not returning an image and failing the try. Please help

The most likely cause is that the Ignition gateway service is not running as a user with access to that location, or cannot run the executable for some other permissions related reason.

You can have the Ignition service run as a particular user, or you can grant the LOCAL_SYSTEM virtual user explicit access to the folder/executable you're trying to invoke.

1 Like

When granting Everyone Read/Write access to the .exe, it still seems to not be returning an image as it should. Do you know if LOCAL SYSTEM explicitly needs to be added? Thank you