Skip to main content
Version: 8.1

Location Based Vision Startup Scripts

Inductive University

Custom Security

Watch the video

Client Startup Scripts​

Security can be created on a Vision Client using a Startup Script that checks certain user information and then customizes the level of access within the project based on that information. We can pull user information from places like System Tags for Vision Clients or Session Properties for Perspective Sessions. Using that information, the script can then customize which windows or views the user sees, provide some additional information to the user, or even prevent the user from accessing the project completely. An additional example is located here.

Location Based Vision Client Restrictions​

Each Client has access to distinct hostname and IP addresses. These can be used in Client startup scripts that evaluate the Client's information and compares it to a list of acceptable host names or IP addresses. This information can come from a database or a set of Tags. In this example, we will prevent access to the client if the user is logging in from an incorrect location.

  1. On the Project tab, choose Client Events.

  2. Select the Startup icon.

  3. Add the following script:

    # Prevent access if user is not logging in from the correct location

    # Grab the hostname that the user is logging in from
    hostname = system.tag.readBlocking(["[System]Client/Network/Hostname"])[0].value

    if hostname != "Machine A Computer":
    # If the user logs in on a computer that is not called Machine A Computer,
    # inform them that the project can only be accessed from the Machine A computer,
    # and then log them out.
    system.gui.messageBox("This project can only be accessed from the 'Machine A Computer'.")
    system.util.exit(1)

  4. Click OK to save the script.

  5. Save your project and launch the client. You will get a popup that informs you that the project must be launched using the Machine A Computer.

Location Based Startup Display​

Another common use for startup scripts on Vision Clients is to open a specific window depending on the location of the log in. In this example, if the user logs in on Machine A Computer, then the Machine A Details window will be displayed. If they log in on a different computer, the Overview window is displayed.

  1. On the Project tab, choose Client Events.

  2. Select the Startup icon.

  3. Add the following script:

    # Open a window based on location

    # Grab the hostname that the user is logging in from
    hostname = system.tag.readBlocking(["[System]Client/Network/Hostname"])[0].value

    if hostname == "Machine A Computer":
    # If the user logs in on a computer that is called Machine A Computer,
    # then open the Machine A details window.
    system.nav.openWindow("Machine A Details")
    else:
    # Otherwise, open the overview
    system.nav.openWindow("Overview")

  4. Click OK to save the script.

    note

    Any windows that are set to Open on Startup will still open in addition to the window specified in the startup script. You should disable any main windows from opening on startup if using this method.

  5. Save your project.