I’m sure many of you out there like ArcGIS and all that it can do for you! Well, maybe you have it in Citrix. Maybe you have custom SearchOptions.cfg’s. Maybe you have style sheets. Maybe you even like to have viewer and professional license versions available to all your users. Well….. In the long long ago, batch was the thing to power all things like this. What if. Just what if I told you, that powershell works too!? How awesome would that be?! You can upgrade your script from batch and stroll down PoSH street! How about see below and you too, for the low low price of free, can enjoy this method too!

# This is to launch ESRI ArcGIS in Citrix. This is using PowerShell version 5.1.17763.1971, on Server 2019 hosts, with Citrix UPM, and with ArcGIS 10.8.1 and with Seach Options. You can comment out
# the Search Options if you are not using them.

# This sets the $username variable which will be used to map drives.
$UserName = [Environment]::UserName

# This section is to set the locations for _master if hosting on profile server (You can use whereever the _master location is as long as permissions are set and it is accessible
# from the network the Citrix hosting VDA's are located.You can use other drive letters, just make the change to the variables below and the section on removing drives and remapping.# This is location of "SearchOptions.cfg" files.

# This is location of "SearchOptions.cfg" files.
$Master= "\\profileserver.fdqn\GIS\_master" 

# Location of ArcCatalog.gx, GxDBFactCache.dat, and GxObjFactCache.dat files.
$Desk= "\\profileserver.fdqn\GIS\_desk" 

# Location of ArcMap Toolbox and styles.
$Desk1= "\\profileserver.fdqn\GIS\_desk1"

# Location of drives for GISDATA.
$QDest = "\\licenseserver.fqdn\GISDATADRIVE"
$SDest = "\\licenseserver.fqdn\GISDATADRIVE"
$NDest = "\\nas.fqdn\dfs\sharename"

# This tests to see if the location for the Search Options have previously been created for the user, and creating them if it is not present.
If (!(Test-Path "\\profileserver.fqdn\CITRIXUPM\$UserName\UPM_Profile\AppData\Local\ESRI\Desktop10.8\ArcCatalog\SearchIndex\Configs\searchoptions.cfg")) {
   Write-Host  "Please wait while your Search Options are created..."
   robocopy $Master "C:\Users\$UserName\AppData\Local\ESRI\Desktop10.8\ArcCatalog\SearchIndex\Configs" /e /S
   }

# This tests to see if the ArcCatalog options have previously been created, and create them if not.
If (!(Test-Path "\\profileserver.fqdn\CITRIXUPM\$UserName\UPM_Profile\AppData\Local\ESRI\Desktop10.8\")){
    Write-Host "Please wait while your ArcCatalog Options are created..."
    robocopy $Desk "C:\Users\$UserName\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog\" /e /S /Y
    }

# This tests to see if the ArcCatalog options have previously been created, and create them if not.
If (!(Test-Path "\\profileserver.fqdn\CITRIXUPM\$UserName\UPM_Profile\AppData\Local\ESRI\Desktop10.8\")){
    Write-Host "Please wait while your ArcCatalog Options are created..."
    robocopy $Desk1 "C:\Users\$UserName\AppData\Roaming\ESRI\Desktop10.8\" /e /S /Y
}

# This removes any mapped drives that might previously have been mapped.
Remove-PSDrive Q,S,N –Force -Verbose

# This maps the drives to the locations for ArcGIS data and files.
New-PSDrive -Name Q -PSProvider FileSystem –Root "$QDest"
New-PSDrive -Name S -PSProvider FileSystem –Root "$SDest"
New-PSDrive -Name N -PSProvider FileSystem –Root "$NDest"

# Sets the Class version to "Professional" license use. You can use "ESRI_SOFTWARE_CLASS=Viewer" as well to do the basic license.
set ESRI_SOFTWARE_CLASS=Professional

# This sets the location of the executable for the ArcGIS files and starts the process.
$dir = 'C:\Program Files (x86)\ArcGis\Desktop10.8\bin'
Start-Process $dir\ArcMap.exe

Now this above will get the script for you. But… You have to publish it as well! So, how about them settings!? This is the screenshot of the settings to use to publish it. You will need to go back and change the icon if you want to have it show the ArcGIS icon instead of the powershell icon. For the copy / pasters out there:

Publishing Citrix app settings:

Path to the executable file: C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe

Command line arguments: -ExecutionPolicy Bypass c:\appscripts\ArcMapAdv-PS.ps1

Working directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\

So there you have it! A way to launch ArcGIS in Citrix with powershell instead of batch!

Leave a Comment

Your email address will not be published. Required fields are marked *