Starting a UI application from agent's script on Windows

Overview

Resilio Connect Agent runs as a service on Windows. This grants Agent ability to run even if no users are currently logged in. On the other hand, Windows OS has to run Agent process in a different session. As a result, all the UI applications launched by Agent inherit agent's session and are not visible to the end user despite the fact they have UI.

To launch a UI app by Agent, admin needs to explicitly push the application to currently active user session. This article describes how to do it with a Powershell script prepared by Resilio, Inc.

Getting the script to endpoint machine

Download script start-process-under-logged-on-user.ps1 from our public Git repository. Place it to a certain location on all your endpoint machines which require to launch UI apps, for example C:\Scripts\ folder. This can be done with a Distribution job or by any other means.

Launching your application with the script

The startup depends on how you start the script - using the built-in powershell script of the Management Console or launching with standard Windows command prompt.

Optional parameters

WorkDir <path> Allows to set current working directory for the application

Wait Forces script to wait while started application exits. When not set, the script exits immediately, leaving UI process running.

Possible caveats

No active user sessions Which usually means no user is looking into the machine. The script will fail.

Several users are working on same computer in different sessions Usually can happen on Server platforms, supporting multiple users working simultaneously. The script will pick the user with lowest session ID (i.e. logged in earlier) to push app's UI there.