9

I need to get the local Computer Name for a desktop computer running our software application through a Citrix session. When I query My.Computer.Name I get the name of the server.

How can I get the name of the actual physical computer that the session is running on, and is there there an event I can monitor for when someone switches a session from one computer to another?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Molloch
  • 2,261
  • 4
  • 29
  • 48
  • I don't have a Citrix server ready, but IIRC there should be a variable on the server environment. – Kobi Jul 25 '10 at 12:53

1 Answers1

13

Found a server variable as Kobi suggested above:

%CLIENTNAME%

it is only populated in Terminal Services or Citrix, expanding it on you local PC will return %CLIENTNAME%. However, on a citrix or RDP server it works great. The .net code I am using is:

TSHostName = Environment.ExpandEnvironmentVariables("%CLIENTNAME%")

Molloch
  • 2,261
  • 4
  • 29
  • 48
  • Well, at least you spelled the name right `:)`. You can accept your own answer, by the way, by clicking on the check mark next to it. – Kobi Jul 25 '10 at 15:43
  • Sorry mate. Fixed it! New to stockoverflow, thanks for your help. – Molloch Jul 28 '10 at 14:10