Windows Tip: How To Remotely Logoff Users via Command Line Tools


Here is a message I got the other day that prevented me from logging into a server remotely.

The Terminal Server has exceeded the maximum number of connections.

Windows Servers allow the maximum of two concurrent remote sessions at any given time unless you have Terminal Services enabled. For any Windows Server 2008 or later, it seems to be ok because you will have the option kicking any active users right at the login screen but for any Server 2003, exceeding that will give you the above message and will just stop you right there. In order to get in that server remotely, you can use the following tip to remotely log off any active or disconnected sessions first and try logging in again.

First of all, use the command line QUser, short for Query Users, to get a list of login sessions on the remote computer.

QUser /server:ComputerName

Replace the ComputerName with the actual remote computer name.

Command Line QUser - Windows Tip: How To Remotely Logoff Users via Command Line Tools

To remotely log off any users on the list, use the command line Logoff with the remote session ID you collected from QUser command.

Logoff sessionID /server:ComputerName

Command Line logoff - Windows Tip: How To Remotely Logoff Users via Command Line Tools

Don’t be scared off by the switch name “server”. It works not only on Windows Server 2003 and above but also Windows desktop platforms as well. If you want to log a remote user off a Windows 10 or Windows 7 computer, simply run the same commands described above, as long as you know the remote computer name and have the user account that has the local admin rights on the remote computer.


  1. shutdown /r /m \\servername /r /t 10

    On my reply I had the second “r” as an “f” which would shut to remote system down and not reboot it. I’m pretty sure you wanted a solution that did not involve a reboot but it is the quickest way to log off all users with a single command..

  2. How will you log off all users on the machine except for administrators? Could you share tips on how to use an exception for administrators?

  3. Nailed it! I had a 2012 server that was hung on a black screen with only a cursor. Through our management software I was able to check out open sessions and kill (logoff) the hung admin session. I was then able to log in without issue. Perfect!


Please enter your comment!
Please enter your name here