Vision - Execute batch file which itself executes a Python script

Hi,

I am running a batch file from an ignition vision button using the scripting functionality of the button. The code of the button is very simple.

a = "C:\U\h2ot\Desktop\batch.bat"
system.util.execute([a])

The batch file itself runs a python 3 script also located on my desktop. The batch file code is also very simple.

echo off
title Execute Python Script
echo Script executed
python C:/U/h2ot/Desktop/XMLRPC_04112024.py %*
start "iexplore.exe" http://www.google.com
pause

The python 3 file sends xmlrpc commands to another device. When I run the python 3 file from my command prompt, it works. The other device receives the command and does some verifiable action. However, from the ignition button the batch file runs (i can confirm because I put a simple validation in the batch file which opens a browser and redirects to google.com) however, the xmlrpc commands are not being successfully sent to the device. So, the python 3 script isn't actually being executed within the batch file when triggered from ignition. How do I get the python 3 script inside the batch file to actually run from an ignition button?

Two questions:
1.) Have you added any logging to the python3 script to see if there are any errors?
2.) When you are running the script from your command prompt are you running it as an elevated user?

Welcome to the forum, Hec_O. Please see Wiki - how to post code on this forum.

1.No
2.Sorry, let me clarify.. When I run the batch file from the command prompt, the python3 file gets executed... but when the batch file is run from ignition, the python3 file doesnt run, only the command to open the browser and go to google.com

You will need to not use system.util.execute(), as it is "fire and forget"--there's no opportunity for troubleshooting.

Try using Java's ProcessBuilder instead, so you can collect and examine both standard and error output.

The fact that the browser opens suggests that the python is trying and failing. (Batch files do not stop on error.)

Does the command line interpreter accept / or should they be \? I can't remember.

I solved my own question.

For those who may be interested: I closed the designer and opened it again, this time selecting 'run as administrator'.