One of the changes we do not like in new XenApp 7.5 is missing option to limit the number of application instances allowed to run on the server or limit only one instance of application for each user. In XenApp 6.5 I used this option very often and I was requested by one of my clients to find a workaround for that.
The simplest and in my opinion only available method is to use external script or batch file to run published application. The logical structure of this script should be the following:
Step 1 – check if special file or registry key exist in agreed location in user profile.
Step 2a – if file/reg key exist display custom message to inform user that only one instance is allowed.
Step 2b – if file/reg key not exist, copy/create a file/reg key to the agreed location and run application executable
Step 3 – when application is closed delete file/reg key from user profile.
I prepared an initial version of VBS script and you can download it from here. Please note I’m not a scripting master and I’m open for any comments and modifications if you feel that this script can be optimized.
‘/// Created by: Andrzej Golebiowski
‘/// Created on: 2014-07-22
‘/// Purpose: Limit number of application instances to 1
Const HKEY_CURRENT_USER = &H80000001
‘/// Declare variable for application
AppName = “Notepad”
‘/// Check if appliacation the Run key exist
strComputer = “.”
Set objRegistry = GetObject(“winmgmts:\\” & strComputer & “\root\default:StdRegProv”)
strKeyPath = “Software\Citrix24\” & AppName & “\”
strValueName = “Run”
dwValue = 1
‘/// Execute application or display message to the user
If IsNull(strValue) Then
‘/// Create applicaton Run key
objRegistry.CreateKey HKEY_CURRENT_USER, strKeyPath
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue
‘/// Run application
Set objShell = WScript.CreateObject( “WScript.Shell” )
Set objShell = Nothing
‘/// Delete applicaton Run key
objRegistry.DeleteKey HKEY_CURRENT_USER, strKeyPath
‘/// Display message
Wscript.Echo “You already have an instance of this application open and are not allowed to run more than one instance. Please close open application instance or contact your System Administrator.”
‘/// Script end