AppV5 - Prelaunch Script for Citrix XenApp 6.5 applications with varying environments

08 Jul 2015

We utilize a lot of pre-launch scripts for our AppV5 applications that we use in our Citrix XenApp 6.5 environment. They become a necessity very quickly as AppV5 stores the executable down a very long path. Citrix XenApp 6.5 has a maximum launch string of 160 characters and this maximum prevents a lot of applications from working if they require parameters to be passed to them. An example looks like this:

``` shell "C:\ProgramData\Microsoft\AppV\Client\Integration\D8E3DB68-4E48-4409-8E95-4354CC6E664B\Root\VFS\ProgramFilesX64\dlc11.2\bin\prowin32.exe" -p \\wsfsc01pharm\CentricityPharmacy\rx\v92\cfg\cfgstart.p -param S,%CLIENTNAME%,crh1214%env%,CITRIX,rxpv91cal,10920 -wy ```
This launch path is too long for XenApp 6.5. The string will be truncated and the program will fail to launch properly. We have several environments that work with the same package files so we set them as variables. To get this package to launch properly we create a prelaunch script that looks like so:
```shell :============================================================================ : AHS BDM Pharmacy prelaunch script : By Trentent Tye : 2015-05-08 : : This script will take 2 parameters. The location (CAL, EDM, ACB)and the environment : -T for test, -P for Prod and -N for training. If no parameter is passed it will assume production. : : eg, AHS-BDMPHARMACY EDM N @ECHO OFF SET ENV=%2 SET FILE=%RANDOM% IF /I [%1] == [CAL] ( ECHO Launching BDM... > "%TEMP%\%FILE%.CMD" ECHO @ECHO OFF >> "%TEMP%\%FILE%.CMD" ECHO START "" "c:\Program Files\DLC11.2\bin\prowin32.exe" -p \\wsfsc01pharm\CentricityPharmacy\rx\v92\cfg\cfgstart.p -param S,%CLIENTNAME%,crh1214%env%,CITRIX,rxpv91cal,10920 -wy ) IF /I [%1] == [EDM] ( ECHO Launching BDM... > "%TEMP%\%FILE%.CMD" ECHO @ECHO OFF >> "%TEMP%\%FILE%.CMD" ECHO START "" "c:\Program Files\DLC11.2\bin\prowin32.exe" -p \\chfs\apps\centricitypharmacy\rx\v92\cfg\cfgstart.p -param S,%CLIENTNAME%,ahe1271%env%,citrix,rx11gproddb,11920 -wy ) IF /I [%1] == [ACB] ( ECHO Launching BDM... > "%TEMP%\%FILE%.CMD" ECHO @ECHO OFF >> "%TEMP%\%FILE%.CMD" ECHO START "" "c:\Program Files\DLC11.2\bin\prowin32.exe" -p \\nafsprog\pharmapp\rx\v92\cfg\cfgstart.p -param S,%CLIENTNAME%,acb1240%env%,citrix,acbrxpv92,10920 -wy ) :RELAUNCH cmd.exe /c "%TEMP%\%FILE%.CMD" /appvve:d8e3db68-4e48-4409-8e95-4354cc6e664b_c2342321-21e9-4e1f-ac2e-adf679020d55 ```
At this point we set our application to point to this CMD file.
And the application will launch with the shorter string with the ability for us to change the environment and location quickly and easily.