Follow these best practices when using start session scripts.

When to Use Start Session Scripts

Use start session scripts only if you need to configure desktop policies before a session starts.

As a best practice, use the Horizon Agent CommandsToRunOnConnect and CommandsToRunOnReconnect group policy settings to run command scripts after a desktop session is connected or reconnected. Running scripts within a desktop session, rather than using start session scripts, satisfies most use cases.

For more information, see “Running Commands on Horizon Desktops” in the Configuring Remote Desktop Features in Horizon 7 document.

Managing Start Session Timeouts

Make sure your start session scripts run quickly.

If you set the WaitScriptsOnStartSession value in the Windows registry, your start session script must finish running before Horizon Agent can respond to the StartSession message that Horizon Connection Server sends. A long-running script is likely to cause the StartSession request to time out.

If a timeout occurs and the pool uses floating assignments, Connection Server tries to connect the user to another virtual machine. If a timeout occurs and no virtual machine is available, Connection Server rejects the user's connection request.

As a best practice, set a hard timeout for the script host operation so that a specific error can be returned if a script runs too long.

Making Start Session Scripts Accessible

The path where you configure your start session scripts must be accessible only to the SYSTEM account and to local administrators. Set the ACL for the base key to be accessible to these accounts only.

As a best practice, place start session scripts in the View_Agent_install_path\scripts directory, for example:

%ProgramFiles%\VMware\VMware View\Agent\scripts\sample.vbs

By default, this directory is accessible only by the SYSTEM and administrator accounts.