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 to do is, I create a timeclock application which will clock a person in and out and keep track. But this particular person, I suspect, is remoting into their computer at work, from home, and clocking in and out.
Any ideas how I can solve this issue (and taking away remote desktop access is not an option)? My idea is, if there is a way to detect remote desktop sessions, I will simply implement this into the progam and prevent them from clocking in remotely.
Identifies the presence of remote desktop software at the user-end while using the online service. This innovative solution is a response to the growing popularity of the remote desktop attacks method and social engineering attacks among cybercriminals.
To view this remote desktop activity log, go to the Event Viewer. Under Applications and Services Logs -> Microsoft -> Windows -> Terminal-Services-RemoteConnectionManager > Operational.
The easiest way to determine who has access to a particular Windows machine is to go into computer management (compmgmt. msc) and look in Local Users and Groups. Check the Administrators group and the Remote Desktop Users group to see who belongs to these.
No, they cannot.
allegedly,
System.Windows.Forms.SystemInformation.TerminalServerSession
will be true for a remote desktop session (or VNC session)
but i'd test it to be sure ;-)
If you don't want to add a reference to System.Windows.Forms.dll just for this (as suggested above), then you can also call the underlying system call directly via PInvoke, like this:
int result = GetSystemMetrics(SystemMetric.SM_REMOTESESSION);
bool isRemoteSession = (result != 0);
The SystemMetric enumeration can be found at PInvoke.net - SystemMetric (but you can just use the value of 0x1000); while the signature for GetSystemMetrics at PInvoke.net - GetSystemMetrics.
I tested this with RDP and VNC - works with the former (admin/console mode also), does not detect the latter.
For Windows Store apps, you can use this:
Windows.System.RemoteDesktop.InteractiveSession.IsRemote
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With