Prevent Two Clients Opening

Hi,

I did a search but cannot see anything related at first glance, I am sure this has been asked before …

We have a single client vision running on a touch screen with the taskbar hidden - often operators cannot see the taskbar and will try to open a 2nd ‘client’ which fails to login as the underlying client is already running.

Is there a way to prevent a 2nd launch of a project on the local PC ? And better yet, maximize the running project if the user try’s … ?

Thanks

Tim

try this on your client start up script
reqIP = is the IP of your client
design = if its a designer.

[code]
sessions = system.util.getSessionInfo(None,‘project name’)
if len(sessions) > 0:
sessionsfnd = 0
for session in sessions:
design = session[3]
address = session[2]
project = session[1]

if design == False and address == reqIP and project == “project name”:

		if design == False and address == host and project == "project name":
			sessionsfnd += 1
	if sessionsfnd > 1:
	  system.gui.confirm('There is already a client open for this application.  You cannot open more than one client at a time.', 'Client already open.',0)
	  system.util.exit(1)[/code]

Hi Ella,

I have finally had a chance to look at this - unfortunately the client start up script does not appear to run until the client is logged on. Unfortunately this script cannot run as the 2nd client is stuck at the log-in screen.

Any way we could run the script prior to log on ?

Thanks

Tim

No, the scripts will only run after login. Typically this situation is solved by setting the project to auto-login to a harmless guest account. Then offer your own window / menu entries to login as another user via system.security.switchUser().

Unfortunately our issue is with a Single Client installation. I wish to prevent a 2nd client opening.

The project is set to auto login to ‘view-only’ user account.

If the running client is minimized and the user then opens another client via the desktop shortcut, the second client opens up to the login page. Whilst an error is displayed when they try to log-in - it is not apparent to them what they have done (they are not computer people) - and therefore not apparent what they need to do - (close the 2nd client, maximize the running one).

We cannot do as you suggest above as any 2nd client will fail to login on a single client license - it remains stuck at the login screen - it is difficult to do anything on a touch-only computer as no close window control is available.

What I would like to achieve - if when on a single client (license) system, if a user tries to open a second client on the local PC, close the second client and maximize the running one.

Maybe with a batch file (.bat). I think you can check if the client is opened and only if it’s not you proceed to open or execute the direct access.

Here you can see something like that, ie, check if a process is opened.
stackoverflow.com/questions/1622 … tch-script

Yes this only works when you are already logged in to the application. We set an automatic logged in our system and created a new login capability within the application.

After not finding an easy way to do this in these forums, I did this and it works for me.
I have several projects that use serial devices and can’t have two of the same client open on the same computer because of that. You would think the operator would notice the application is already open, but yea…anyway.

hostname = system.net.getHostName()
client_host = []

sessions = system.util.getSessionInfo()
for session in sessions:
	if session[3] == 0:
		client_host.append([str(session[2]), str(session[1])])

duplicate = [x for n, x in enumerate(client_host) if x in client_host[:n]]

if len(duplicate) > 0 and hostname == duplicate[0][0]:
	if system.gui.confirm("<html><center><font size=24>You have opened a duplicate client application.<br>\
						First close the original client before opening a new one.<br> \
						Errors may occur with two of the same clients are open.<br>\
						Click YES to open another client, NO to close this client</font>","Client Error",0) == 0:
		system.util.exit()
	else:
		pass	
1 Like

Thank you very much, it is what I was looking for.