I am trying to trigger a batch file 5 pm everyday. It works while using a button that has the same exact script run when it is pressed, but not for a tag value change. I have set up logs and I know the script IS running except for the line that actually executes the batch.
The script in my on value change -
import system
myLogger = system.util.getLogger("DevLogger")
myLogger.info("In hour Change")
if system.tag.read("DayOfWeek").value==2 and system.tag.read("HourOfDay").value==8:
myLogger.info("In if statement")
system.util.execute(["C:\NAS_Backup_BatFiles\Bay1_Cust_Backup.bat"])
I get the log statements of in hour change and in if statement, but my batch file is not running. It does run with this same logic when inside a button. Any ideas why?
We tested our client with the button that does successfully trigger this on the same computer that is hosting the gateway if that matters. How can I check who the service user is for the gateway/make changes to correct this?
On windows, the Ignition gateway is typically run as an unprivileged âserviceâ user.
Using the âservicesâ tool in Windows, you can alter the properties of the âIgnitionâ service, and choose to login as a different user with privileges.
This does mean that, from that point onwards, anyone who can execute code on the gateway (so anyone with designer access) can execute code as that user.
That is insufficient. The gateway is a background service, and runs under its own account. Generally, you will find the relevant settings under "My Computer" ==> "Manage" ==> "Services".
I went to services => Ignition => Properties => Log On, switched it from Local System Account to âThis Accountâ and put in the administrator username and password for the computer. I am still getting the same issue. I donât see the batch file attempt to open on the computer that is hosting the gateway. I still see log statements confirming I get into the if statement.
Hi, I am using Ignition 8.0.15 and I am facing the same issue here. I created a button to trigger system.util.execute([âC:\Users\Administrator\Desktop\test.batâ]) and it did run successfully. However when I use the same script in Gateway Event (Tag Change), it doesnât work, and thereâs no error log in the gateway.
Is there anything I missed out?
Hi,
Iâm struggling with same problem. Trying to execute a batch file that is stored on ignition server from the gateway.
We are now doing it by a scheduled task on windows, but we had some issues with that and want to integrate it all in ignition.
Did you find a solution? A valid approach would also be to execute this file from a timer object, not the best solution but it would work for me.
I created a shortcut in the same folder as the script itself. In the shortcutâs properties, I clicked on Advanced and checked the box for âRun as administratorâ. My script then called the shortcut in lieu of the script.