# System.util.execute

**URL:** <https://forum.inductiveautomation.com/t/system-util-execute/10056>\
**Category:** Ignition\
**Created:** [May 25, 2015, 10:55am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056 "2015-05-25T10:55:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![xion8x8](https://avatars.discourse-cdn.com/v4/letter/x/cc9497/32.png) [@xion8x8](https://forum.inductiveautomation.com/u/xion8x8)\
**Post date:** [May 25, 2015, 10:55am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/1 "2015-05-25T10:55:10Z")

</div>

I wanted to use system.util.execute to run a batch file in my computer. I am able to run the script below on a button actionPerformed event and it runs the batch file

system.util.execute([“C:\windows\system32\cmd.exe”,"/C",“start”,“C:\Users\WengFai\Desktop\Test.bat”])

When I use the exact same script in Tag Event scripts, it is not working at all and does not give any errors. I have added some codes in the Tag event scripts to make sure the event is fired (write a value to another tag). Besides that, is the “system.gui.messageBox” not working in tag event scripts too?

Anyone can help?

Thank you.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [May 25, 2015, 2:41pm UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/2 "2015-05-25T14:41:51Z")

</div>

Hello,

Tag Event scripts do not run on your computer, they run on the computer where Ignition is installed. Tag Event scripts do not run in a client, they run in the Ignition Gateway.

Your system.util.execute call in the Tag Event script will attempt to execute the bat file on the Ignition server, not on your local computer. Any errors will show up in the wrapper.log file.

A call to “system.gui.messageBox” in a Tag Event script will never work because Tag Event scripts run in the Ignition Gateway where there is no GUI.

Perhaps you could use a Client Tag Change script to do what you are trying to do.

Best,

---

<div class="post-metadata">

**Author:** ![xion8x8](https://avatars.discourse-cdn.com/v4/letter/x/cc9497/32.png) [@xion8x8](https://forum.inductiveautomation.com/u/xion8x8)\
**Post date:** [May 26, 2015, 12:39am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/3 "2015-05-26T00:39:56Z")

</div>

Hi nmudge,

Thanks for the info. My computer is the Ignition Gateway. I am testing it in Designer too. Any ideas?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [May 26, 2015, 12:59am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/4 "2015-05-26T00:59:25Z")

</div>

Check the wrapper.log file for any errors.

---

<div class="post-metadata">

**Author:** ![xion8x8](https://avatars.discourse-cdn.com/v4/letter/x/cc9497/32.png) [@xion8x8](https://forum.inductiveautomation.com/u/xion8x8)\
**Post date:** [May 27, 2015, 12:50am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/5 "2015-05-27T00:50:12Z")

</div>

There are no errors in wrapper.log nor console log.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 27, 2015, 9:32am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/6 "2015-05-27T09:32:58Z")

</div>

Hi!

The backslash is used to escape characters that would have a special meaning (\n for newline, for example).  
So, if you need an actual backslash, you would need to use two: \.

Try using something like this:

```auto
system.util.execute(["C:\\windows\\system32\\cmd.exe","/C","start","C:\\Users\\WengFai\\Desktop\\Test.bat"])
```

---

<div class="post-metadata">

**Author:** ![xion8x8](https://avatars.discourse-cdn.com/v4/letter/x/cc9497/32.png) [@xion8x8](https://forum.inductiveautomation.com/u/xion8x8)\
**Post date:** [June 18, 2015, 3:22am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/7 "2015-06-18T03:22:03Z")

</div>

Hi,

Tried to use the code given, not working.

The same code is working in button actionPerformed but not working in tag event scripts.

what are the problem? out of idea

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 18, 2015, 9:02am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/8 "2015-06-18T09:02:49Z")

</div>

Can you post the script?

---

<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:** [June 18, 2015, 12:23pm UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/9 "2015-06-18T12:23:15Z")

</div>

You also have to make sure the user that the gateway service runs as has permissions to the directory where you’ve put the script. The gateway doesn’t run as a regular user unless you override the service settings. Consider putting the script in a new folder under Ignition’s program folder.

---

<div class="post-metadata">

**Author:** ![xion8x8](https://avatars.discourse-cdn.com/v4/letter/x/cc9497/32.png) [@xion8x8](https://forum.inductiveautomation.com/u/xion8x8)\
**Post date:** [June 19, 2015, 6:28am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/10 "2015-06-19T06:28:23Z")

</div>

both scripts below is not working:

```auto
system.util.execute(["C:\\windows\\system32\\cmd.exe","/C","start","C:\\Users\\WengFai\\Desktop\\Test.bat"])
```

```auto
system.util.execute(["C:\\windows\\system32\\cmd.exe","/C","start","C:\\Program Files\\Inductive Automation\\Ignition\\batchfile\\Test.bat"])
```

I am running as administrator and have access on all directory. Tried to put the script in a new folder under Ignition’s program folder but not working too. Anyone tried to run batch file using tag event script?

Thank you.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 22, 2015, 12:37pm UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/11 "2015-06-22T12:37:08Z")

</div>

I can start digging a little deeper into this, but I need one more bit of info.

Which Windwos OS are you using?

---

<div class="post-metadata">

**Author:** ![xion8x8](https://avatars.discourse-cdn.com/v4/letter/x/cc9497/32.png) [@xion8x8](https://forum.inductiveautomation.com/u/xion8x8)\
**Post date:** [June 23, 2015, 12:11am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/12 "2015-06-23T00:11:44Z")

</div>

windows 7 professional 64-bit

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 23, 2015, 11:12am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/13 "2015-06-23T11:12:35Z")

</div>

No issues here. Runs as Tag Script, or Gateway Event Script, From my Desktop or from the root (C:). One thing that I did notice was that the cmd and Console hosts persisted, even though everything had run. I suspect that the shell never terminates, even with the “/C” switch.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e706cfa45c53874354741072bb224451ea5a508e.png)  

I also tried using subprocess with no issues, and no persistent processes hanging on.

`from subprocess import Popen, call
call(['C:\\test.bat'], shell=True)`

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [June 29, 2015, 5:15pm UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/14 "2015-06-29T17:15:51Z")

</div>

I am marking this topic as unsolved because I do not believe that it is solved. The OP emailed technical support about this issue. I have a question for Jordan on this. I have been trying to get the script to work, with limited success. I believe the OP issue has something to do with permissions and how the Ignition service is allowed to interact with the desktop. I was able to get the script to work if I allowed the service to interact with the desktop, but it was very clunky and I received a message box from the OS that I had to interact with before the script in the batch file would run. So my question is:

Jordan, did you make any changes to the OS or how the service runs?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 29, 2015, 5:28pm UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/15 "2015-06-29T17:28:43Z")

</div>

Thanks for opening it back up, Greg.

I'll also add what we have PM'ed over the past couple of days...

[quote="xion8x8"][Subject: system.util.execute](https://inductiveautomation.com:443/forum/viewtopic.php?p=51323#p51323)

[quote="JordanCClark"]No issues here. Runs as Tag Script, or Gateway Event Script, From my Desktop or from the root (C:). One thing that I did notice was that the cmd and Console hosts persisted, even though everything had run. I suspect that the shell never terminates, even with the "/C" switch.  
[attachment=0]2015-06-23\_6-56-06.png[/attachment]

I also tried using subprocess with no issues, and no persistent processes hanging on.

`from subprocess import Popen, call
call(['C:\\test.bat'], shell=True)`[/quote]

Hi Jordan,

The code given is not running for my computer, it hangs the whole Ignition designer forever. any idea?

I have accidentally locked my topic by clicking the "solved" button but actually it is not solved yet.

Thank you.[/quote]

Sorry for the late reply.

Hmm. Let's do a little housekeeping...

This will (hopefully) give you a fresh start. The only thing is that any shortcuts created by Ignition will likely get deleted.

remove any cached webstart apps:  
javaws.exe -uninstall

Delete ignition user folder:  
C:\Users{userName}.ignition

When you restart the designer a fresh copy of the jython libraries will get downloaded. Perhaps that may do the trick.

> [@Greg.Simpson](#):
>
> Jordan, did you make any changes to the OS or how the service runs?

Nope. Granted, I am an administrator, but no permissions were changed for Ignition.

---

<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:** [June 29, 2015, 8:44pm UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/16 "2015-06-29T20:44:48Z")

</div>

If I recall correctly, with UAC enabled, services running with ‘interact with the desktop’ are actually interacting with a virtual gui that corresponds to an remote desktop “/console” or “/admin” connection. Microsoft has been trying to kill off gui-visible services for ages …  
My Windows7 VM is use for Rockwell Software has UAC turned off so RSLinx Classic can interact with the desktop. That’s became a requirement for RSLinx Classic when Vista came out.

---

<div class="post-metadata">

**Author:** ![xion8x8](https://avatars.discourse-cdn.com/v4/letter/x/cc9497/32.png) [@xion8x8](https://forum.inductiveautomation.com/u/xion8x8)\
**Post date:** [June 30, 2015, 1:11am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/17 "2015-06-30T01:11:37Z")

</div>

I have followed the steps from Jordan but no luck and it is not working to me. Do i need JDK or JRE will do?

UAC had been disabled in my computer.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 30, 2015, 2:03am UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/18 "2015-06-30T02:03:11Z")

</div>

I only use JRE.

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [June 30, 2015, 6:49pm UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/19 "2015-06-30T18:49:04Z")

</div>

My thought is that this is a permissions issue. I was able to execute a batch file from a tag event script if I allowed the Ignition service to interact with the desktop. However, I was prompted to view a message before it would run in its own window. It would not be very desirable to run it in this way. I have admin permission on my workstation, but that doesn’t mean that IT hasn’t put something in place to prevent services from executing something.

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [June 30, 2015, 7:56pm UTC](https://forum.inductiveautomation.com/t/system-util-execute/10056/20 "2015-06-30T19:56:11Z")

</div>

Ok, some more to add on this. I don’t think there is going to be anything on the Ignition side of things that can be done. As of right now I am not able to find a solution to this. I am going to speak with my IT department and see if there is anything they can add. What I am seeing is this. The script runs the batch file from the tag event script. However, it starts a new process that I can see in Task Manager, but it runs the process in the background. So its running, just no GUI. This would be some sort of an issue with the OS or permissions. I will get back to you once I have more.

[Next page](https://forum.inductiveautomation.com/t/system-util-execute/10056.md?page=2)
