Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Somebody could provide me a tip on how could I make a script file (.cmd) which logs off the current user AND all other open sessions with same username?

E.g.: I'm logged into three TS sessions with username "JOHN". I wish to run a script (from my current session, without administrative privileges) which would logoff my current session and also the other two.


share|improve this question

You should read this page. It has the full command line syntax for Terminal services

share|improve this answer

Just type logoff /? in your command prompt for the syntax. Than you can at least loff of your current session.

I think you need to have local admin permissions to log someone else off. Not sure how it is for another session from you. You can try if the task manager is enough for you (just hit CTRL+ALT+End and you get the Ctrl+ALT+DEL menu for your remote system; choose Task Manager). The task manager has a users tab that you can use to kick users out. It definitely works if you are a local admin. Be careful you can also kick your current session. ;)

share|improve this answer
Thanks! But unfortunately, this would logoff only the CURRENT session. Not the other two. BTW: It should not require administrative privileges simply because it is not someone else. It's me. Same credentials. – Junior Dec 23 '09 at 19:45
Logoff also takes a session ID. or session name. So you should be able to kick other people off. With task manager you can kick off everyone (if you are an admin). – Peter Schuetze Dec 23 '09 at 19:51

Download TSLogoff from and run

tslogoff username /server:*

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.