Bill Robertson's Blog

October 2008 - Posts

How to log remote user off...remotely

You're about to leave for the day, but you need to push one more thing to the data center.  You pop open trusty Remote Desktops and connect to your environment.  Then this message hits you in the face like a wet, smelly dog tail.

remotedesktopexceeed-thumb1

"Connect to console"?  Nope that doesn't help.  Normally, you holler across your team and tell whoever isn't on the servers, to log off; however it's late and everyone else is gone.  Or if someone is already on the server, ask them to use taskmgr to find your least favorite person and force them out of the server.  (Does anyone else get a power rush out of that?)

logoffremote

The above only works when you have access to the server.  When you don't, you can log people off remotely.

There are two commands that are included in at least Windows Server 2003 and beyond:

  • quser.exe - used for querying users logged on to a server
  • logoff.exe - used for logging user off a server

Using just quser.exe will give you the list of users that are logged onto the current machine.  You can also query a remote machine using the /server:<machinename>.  This will give a list of users.  The import things to notice are the ID and the State.  There are two states that I use when deciding who to kick off: Active and Disc.

I always try to kick off Disc before active.  (There's no additional explanation)

After you pinpointed the user to bounce, look at the ID column because that's what the logoff.exe command needs.

The screen shot below shows how to query the users on WEB01 and then log off the disconnected session, named Session ID 2.

logoffcommandline

With nearly all dos commands, passing "/?" as the only parameter will give you additional information about these commands.

More Posts