Click here to Skip to main content
15,870,165 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

to rudely answer my own question -> cmd + "query user {username}" the output is
Username - Sessionname - ID - State - Idle Time - Logon Time
 
Share this answer
 
I actually found another solution, that works quite well - using Cassia

C#
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 { }
                }
            
            }
 
Share this answer
 
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[^]
 
Share this answer
 
Comments
alekcarlsen 1-Nov-12 5:32am    
that is quite interresting - thank you for sharing

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900