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
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.
Hi,
I’m trying to force log off (on an admin account), after certain time, using the net user on cmd line. (I’m using windows 10).
but even though it shows correctly the right times set to log off, and that it’s ‘completed successfully’, it still doesn’t actually log off! And I would like it to do so, and not to be able to log back on, until ‘screen time’ is allowed back on again.
Please let me know how I can get this to work.
have tried clean up, but hasn’t helped.
Thank you!