How do I find out what user, if any, is currently logged on to some remote Windows XP machine interactively? .NET code would be great or any command-line utility that I can call from code. SysInternals psloggedon, as suggested on SuperUser, almost works, but it doesn't tell me which session is interactive.
+1
A:
I think you should be able to use the Remote Desktop Services API. WTSOpenServer + WTSEnumerateSessions + WTSQuerySessionInformation. Of course this won't work if the Terminal Services service isn't running, but I don't know of another way to get this information.
Luke
2010-07-12 14:09:02
Hmm, I get an "Access denied" error when calling `WTSOpenServer`, even though I'm an admin on the remote machine and psloggedon works fine.
Evgeny
2010-07-13 00:47:03