I have a C# standalone Windows Forms application. It connects to a back office system that requires the workstation name as part of the identification process. I’m using Environment.MachineName to get this. However the customer using this application will occasionally run it under a Citrix environment and, when they do, they want it to reference the remote machine name, not the machine it is installed on. I have never coded anything like this before, and am unfamiliar with Citrix (so I’m off to a flying start). How do I get the remote machine name? Any ideas hugely appreciated.
Big thanks in advance.
On a Citrix systems there’s an Environment Variable called
CLIENTNAMEthat has the name of the machine that the user is connecting to Citrix from. It’s just a regular Windows environment variable so you can useEnvironment.GetEnvironmentVariableto read it.You could do something quick and dirty like this:
For something a little more robust, a Citrix environment also has a
SESSIONNAMEvariable that identifies the Citrix session. The presence of these two variables together is probably a better test for running in a Citrix session.So you could do something like this: