Click here to Skip to main content
14,604,663 members
Rate this:
Please Sign up or sign in to vote.
See more:
i need to write an application or web service, that checks if users RDP-TCP session is idle, and if its idle - close another application.

but i cannot figure out where to find the idle-time -> "windows task manager" does not show an idle time, but "remote desktop services manager" does.

so my question is

does anybody know where i can find out if the logged on users are idle or not?
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

to rudely answer my own question -> cmd + "query user {username}" the output is
Username - Sessionname - ID - State - Idle Time - Logon Time
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

If the RDP session get's locked on idle then you can check using following logic.
How to mute the system volume after system lock[^]
   
Comments
alekcarlsen 1-Nov-12 5:32am
   
that is quite interresting - thank you for sharing
Rate this:
Please Sign up or sign in to vote.

Solution 3

I actually found another solution, that works quite well - using Cassia

ITerminalServicesManager manager = new TerminalServicesManager();
            using (ITerminalServer server = manager.GetLocalServer())
            {
                server.Open();
                foreach (ITerminalServicesSession session in                    server.GetSessions())
                { 
                    NTAccount account = session.UserAccount;
                    if (session.IdleTime > minutes && account != null && account.ToString().Contains("admin") == false)
                    {

                        listBox1.Items.Add(session.UserAccount + " " + DateTime.Now.ToString());
                        session.Disconnect();
                        Settings.Default.amount++;
                        Settings.Default.Save();
                        label1.Text = "Accounts disconnected: " + Settings.Default.amount.ToString();
                    }
                    else { }
                }
            
            }
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100