I am wondering how to limit the number of instances that can be opened on a computer? I am asking because we had a computer that someone had opened 5 instances of the same project. This can cause some large problems for us in data collection. I have not noticed a setting for this type of thing while programming. So I was wondering if anyone had any information or ways of doing this? Maybe a startup script or something?
Yes, use system.util.getSessionInfo() in a startup script. Loop through the dataset looking for IP addresses that match this client, and if they have a different clientID, you know there’s another instance running on that computer.
At that point, you can open a warning window, and use system.util.invokeLater() to call system.util.exit() after a suitable delay.
Also, you could set your application’s main window to not open automatically – open it from the startup script after verifying that the client is alone on that machine.
Put this script in your client start up script area. Modify as needed.
[code]# Check to see if there is already an Ignition client open on this PC. Trying to cut down on multiple clients open on one machine.
projName = system.util.getProjectName()
hostName = system.tag.read("[System]Client/Network/Hostname").value
sessionInfo = system.util.getSessionInfo()
rowIndex = 0
clientCount = 0
for row in sessionInfo:
if sessionInfo[rowIndex] == projName and sessionInfo[rowIndex] == hostName:
clientCount += 1
if clientCount > 1:
if system.gui.confirm(“There is already a client open on this PC, do you want to close this client?”, “Client Already Running”):
rowIndex += 1[/code]