How To Log Someone Off Of Their Computer Using CMD

Logging Someone Off Of Computer With Command Prompt

There may be times in which it’s more convenient to log a person off of their computer over your local network via the command line. The command you will need to use is fairly simple.

query session logoff 123 /server:ComputerName

Let’s break down the command and how to use it. First thing is that you’ll need to know the computer name and the computer has to reside on your local network. Once you’ve got the computer name there is a command you need to run in order to get some relavent information.

query session /server:ComputerName

You should replace “ComputerName” with the name of the computer the person is logged into. After running the above command you should have some results that look similar to the following.

SESSIONNAME USERNAME ID STATE TYPE DEVICE
            billy     2  Disc

The only thing in the above output you’ll need to make note of is going to be the ID number. Using the information we’ve gathered, if for example we wanted to log off “billy” from a computer named “dellpc” we would run the following command:

logoff 2 /server:dellpc

Leave a Reply