How-To log off a user from remote computer

If you work in IT, I’m sure you’ve run across a time that you needed to log off a user from a remote computers – even if it’s yourself (especially when it’s time to change your password).  Personally, I have to change my network password every 30 days, and there are times that I may be logged into any of 150 computers.  I try to remember to use the log off button, but sometimes, I have idle sessions on computers.

This being said, I needed a way to log off any session I was logged into, in a list of computers I knew I might be logged into.  My first thought was to use PSLOGGEDON.exe (from Sysinternals) which is a fantastic tool, but I don’t want to search the entire domain, plus I might be logged in to multiple domains.

So, I found a nice little utility built right into windows – quser.exe

image

Quser.exe can be used to show what user is logged in to a remote computer, as well as the localhost.  Use quser.exe /SERVER:servername to query a remote system.

image

If you want to specify just one user account instead of finding all users logged in, user this syntax:  quser.exe user6 /SERVER:servername

image

Now to log off this user, or session, you can use another built-in utility in Windows – Logoff.exe

Logoff.exe can either log off a session ID, or SessionName remotely – not by username (username works locally though).   The syntax is similar to quser.exe:

LOGOFF [sessionname | sessionid] [/SERVER:servername]

So to log off user6 from the example above, I can use either the session name (rdp-rcp#443 – or I can use the ID – 2 – I’ll go with the ID

logoff 2 /SERVER:server1

image

That was easy!  Now, to check to see if I’m logged any of the 150 servers I manage, I create a quick bat file using excel (more on that here) and now I can run it at any time, and see what remote systems I’m logged into, and log my session off if needed.

This is a really simple way to do this, but if you have another way to do it, please post below!  I’d love to see how you handle this problem!

Related posts:

  1. Command Line – Terminal Server tip
  2. Script: Who’s Logged on to remote PC
  3. TechNet Plus Direct single user subscription for $249
  4. Windows 7 Slow Remote Desktop (RDP) fix
  5. Windows 7 Remote Server Admin Tools Beta released (RSAT)
This entry was posted in How To, Microsoft, Remote Access, Scripts, Windows. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>