Is there anyway, in a program, to detect if a program is being run from inside a remote desktop session or if the program is being run normal in .NET 2.0? What I\'m trying t
Just a note to say that using GetSystemMetrics(SystemMetric.SM_REMOTESESSION) on its own has stopped being reliable for Windows 8 / Server 2012 onwards if the session is using RemoteFX virtualisation of the GPU.
The "official" method of detecting RDS is described by Microsoft here: Detecting the Remote Desktop Services environment (Last updated 31 May 18).
It consists of using the SystemMetrics call and a registry check at
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\GlassSessionId
The code samples in that article are C++ only, but given that it's just a registry lookup, I don't think folks will find it too tricksty to replicate in other languages.
I'd like to hope that at least some of the .Net built in functions mentioned upthread are following this in full, but :
SystemParameters.IsRemoteSession is noted here as "Maps to SM_REMOTESESSION. See GetSystemMetrics", and
SystemParameters.IsRemotelyControlled is noted here as the same,
so I'm not optimistic.
I'll try to do some detailed checks shortly and post the results.