2 Replies Latest reply on Oct 29, 2019 4:38 AM by mchadwick19

    How to programmatically detect a session is running on Horizon View session ?

    nikobarli Lurker

      We need to detect if our program is running on a Horizon View session (there is some behaviors that are need to be turned off).

       

      Is there any reliable way (API) to do that ?

        • 1. Re: How to programmatically detect a session is running on Horizon View session ?
          nburton935 Enthusiast

          You can query the registry key HKCU > Volatile Environment to see if any of the ViewClient keys exist. Those keys also provide helpful information in case you need to do any scripting. For example, you can query HKCU > Volatile Environment > ViewClient_Machine_Name to get the physical machine name that the Horizon session is connected from.

          • 2. Re: How to programmatically detect a session is running on Horizon View session ?
            mchadwick19 Hot Shot

            If you are connecting to sessions solely on VM's you could also check if there are specific HKLM keys under SOFTWARE\VMware Inc.\Installer\Features_HorizonAgent\

             

            If any keys like Core, NGVC, SVIAgent, BlastUDP are the value "Local" this means the Horizon Agent is installed on the system.

             

            As for an API method - are you able to manage the software from a central location and perform event-driven actions? For example when a user attempts to launch the software maybe it polls a license server or central config server. Upon the user checking in it triggers a script to check if it's a View session. The script would be something like:

             

            $viewCreds = Get-Credential   #This can be done in whatever way you see fit

            $hvServer = Connect-HVserver -server $viewServer -Credential $viewCreds

            $viewUser = <Username> # This is probably passed in as part of the execution of this script

             

            $hvServices = $hvServer.ExtensionData

            $queryService = New-Object VMware.Hv.QueryServiceService

            $defn = New-Object VMware.Hv.QueryDefinition

            $defn.QueryEntityType = 'SessionLocalSummaryView'

            $qFilter = New-Object VMware.Hv.QueryFilterContains -Property @{'memberName'='namesData.userName';'value'=$viewUser}

            $defn.filter = $qFilter

            $queryResults = $queryService.QueryService_Create($hvServices, $defn)

            $sessionId = $queryResults.Results.Id

             

            If $sessionId has a non-null value, there is an active session.