There are multiple ways to log off the current user on a Windows system using the command line.  The version of the commands below will depend on the Windows version, the interface you are using to log off the user (e.g. Remote Command Prompt, RMM, Local Command Prompt) etc..

 

The command to force the current user to log off  immediately using the command line in Windows is:

shutdown /l /f /t 00

Sometimes you will need to use a “-” instead of a “/”

shutdown -l -f -t 00

If you’d like to log off the session giving the current user the chance to save any work you would just exclude the “/f”

shutdown /l

or

shutdown -l

On some remote management systems you can’t issue the shutdown command.  In these cases what you need to do is find out the current user’s active session number by issuing the following command:

query user

Query User

You will then be able to see the current user’s Id and issue the logoff command instead:

logoff 1

Where 1 is the ID of the user you are logging off after performing the query user command.

The following command has been tested on Windows XP, Windows 7, Windows 8, Windows 8.1, Windows 10.  Your mileage may vary on other version of windows.