Error trying to get Ignition to run a batch file at specified time based on Tag Values

I have a new simple project that is only meant to do one thing, on 2 pm every Friday run a batch file. It was giving me issues doing it strictly in the tags, so I tried bringing the logic over to a button for testing and it works fine. Any idea why?

This is the script attached to the button -

if system.tag.read("DayOfWeek").value==5 and system.tag.read("HourOfDay").value==14:
	system.util.execute(["C:\NAS_Backup_BatFiles\Bay1_Cust_Backup.bat"])

And similarly for inside the HourOfDay Tag Event valueChanged -

if system.tag.read("[~]DayOfWeek").value==5 and system.tag.read("[~]HourOfDay").value==14:
	system.util.execute(["C:\NAS_Backup_BatFiles\Bay1_Cust_Backup.bat"])

I know this must be a syntax thing. What is going wrong here?

Try using the full tag path name (e.g.: “[default]DayOfWeek”)

I’ve gotten into the habit of always using a full path, since it’s bitten me once or thrice.

You may also consider using a gateway tag event script. I’ve nothing against tag scripts, but I seem to have better luck with the event scripts…

I also remember there are occasions where you need to import system. I just can’t remember specifically where…

1 Like