# Vision - Execute batch file which itself executes a Python script

**URL:** <https://forum.inductiveautomation.com/t/vision-execute-batch-file-which-itself-executes-a-python-script/98332>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [November 7, 2024, 10:15am UTC](https://forum.inductiveautomation.com/t/vision-execute-batch-file-which-itself-executes-a-python-script/98332 "2024-11-07T10:15:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hec\_O](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@Hec\_O](https://forum.inductiveautomation.com/u/Hec_O)\
**Post date:** [November 7, 2024, 10:15am UTC](https://forum.inductiveautomation.com/t/vision-execute-batch-file-which-itself-executes-a-python-script/98332/1 "2024-11-07T10:15:27Z")

</div>

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](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](http://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?

---

<div class="post-metadata">

**Author:** ![Benjamin\_Furlani](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/benjamin_furlani/32/66084_2.png) [@Benjamin\_Furlani](https://forum.inductiveautomation.com/u/Benjamin_Furlani)\
**Post date:** [November 7, 2024, 2:33pm UTC](https://forum.inductiveautomation.com/t/vision-execute-batch-file-which-itself-executes-a-python-script/98332/2 "2024-11-07T14:33:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 7, 2024, 2:35pm UTC](https://forum.inductiveautomation.com/t/vision-execute-batch-file-which-itself-executes-a-python-script/98332/3 "2024-11-07T14:35:43Z")

</div>

Welcome to the forum, Hec\_O. Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![Hec\_O](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@Hec\_O](https://forum.inductiveautomation.com/u/Hec_O)\
**Post date:** [November 7, 2024, 3:42pm UTC](https://forum.inductiveautomation.com/t/vision-execute-batch-file-which-itself-executes-a-python-script/98332/4 "2024-11-07T15:42:18Z")

</div>

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](http://google.com)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 7, 2024, 3:48pm UTC](https://forum.inductiveautomation.com/t/vision-execute-batch-file-which-itself-executes-a-python-script/98332/5 "2024-11-07T15:48:18Z")

</div>

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](https://forum.inductiveautomation.com/search?q=ProcessBuilder%20order%3Alatest) 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.)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 7, 2024, 3:57pm UTC](https://forum.inductiveautomation.com/t/vision-execute-batch-file-which-itself-executes-a-python-script/98332/6 "2024-11-07T15:57:41Z")

</div>

> [@Hec\_O](#):
>
> `python C:/U/h2ot/Desktop/XMLRPC_04112024.py %*`

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

---

<div class="post-metadata">

**Author:** ![Hec\_O](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@Hec\_O](https://forum.inductiveautomation.com/u/Hec_O)\
**Post date:** [November 8, 2024, 11:40am UTC](https://forum.inductiveautomation.com/t/vision-execute-batch-file-which-itself-executes-a-python-script/98332/7 "2024-11-08T11:40:14Z")

</div>

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'.
