Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list of Windows sessions?

Tags:

c#

windows

I am trying to find a way to get a list of Windows sessions? I need the same information as the one displayed in the Task Manager on the User tab. I need to know if the user is active or not and if s/he is logged on in the Remote Desktop session.

Any idea on how to do that with C# / Windows XP Pro?

like image 246
Martin Avatar asked Jul 06 '09 17:07

Martin


People also ask

How do I view Windows Server sessions?

First option — use command line to query user /server:SERVERNAME (or quser.exe - same thing). This shows User name, Session name, Session Id, Session state, Idle Time and Logon Time for all logged in users. Second option — use command line to query session /server:SERVERNAME .

How do I check my computer sessions?

You can also use net sessions or net sess to run net session. Use net session to view the computer names and user names of users on a server, to see if users have files open, and to see how long each user's session has been idle. To display one user's session, use **\\**ComputerName with the command.


1 Answers

As a starting point you can get a list of users logged on by running the command

qwinsta

From the command prompt.

This will give output like

C:\WINDOWS\system32>qwinsta
SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>console           me                       0  Active  wdcon
rdp-tcp                                 65536  Listen  rdpwd

and will list any remote sessions.

like image 88
pjp Avatar answered Oct 12 '22 00:10

pjp