10

Time to time I can't login to my Windows Server 2003 because there are to many open sessions. Is it possible to close them remotely(without physical contact in server room)?

yura
  • 231
  • 1
  • 2
  • 7

6 Answers6

11

You can do it using the qwinsta and rwinsta command line tool:

qwinsta /server:SERVERNAME

You will get a list of the Remote Sessions in the command window. Make sure the account you're logged in on your client computer has admin rights on the server. You can also use the server's IP address instead of the server's name.

You need the session ID of the RDP session in order to disconnect a user. This command shows you all sessions

rwinsta /server:SERVERNAME SESSIONID
splattne
  • 28,508
  • 20
  • 98
  • 148
  • It shows error `Error opening Terminal server IP Error [5]:Access is denied.` when i try to execute `qwinsta /SERVER:IP` – yura Oct 07 '11 at 12:15
  • @yura You'll have to use it with a user which has admin rights on the server. If you have to servers you could connect as admin to one server and try it from there. – splattne Oct 07 '11 at 12:43
  • But how can I connect to server then? If it print to many session are open? I was think that i should write this command from my local windows machine, but on this machine user of course different from admin on server... – yura Oct 07 '11 at 14:33
  • @yura Then use a `runas` to do it as a user which does have those admin rights. – Shane Madden Oct 07 '11 at 15:14
  • In terminal services the admin session will have an ID of '0'. There can only ever be one of these, if someone was to log in with the same credentials they would steal your session. If you run command prompt and then `runas /user:SERVER\USERNAME /password:PASSWORD` you should be able to run the commands listed above perfectly. – Stephen Murby Jul 10 '12 at 09:34
3

You can connect to server with command mstsc -v:IP /admin. It is works even when there are to many open sessions.

yura
  • 231
  • 1
  • 2
  • 7
3

I used PsTools:

psshutdown -o -f \\servername

  • -o logs off the console session
  • -f forces open apps to close
northben
  • 382
  • 1
  • 4
  • 13
0

I think you can connect as administrator and disconnect all the other sessions.

If the above if true this might be automated through a script(that connects as admin and performs the desired actions).

Hope it helps :)

Dragos
  • 369
  • 1
  • 2
  • 11
  • We always use same user which already belongs to administrator group. And now we can't login to Server with this administrator user... Are we talking about same administrator user? – yura Oct 07 '11 at 11:22
0

Open up the Terminal Services Management console on a domain member computer and connect to the system in question.

This will list all sessions on the remote machine, which you can then reset (kill), or log off individually.

adaptr
  • 16,576
  • 23
  • 34
0

If you have the proper administrative tools set up, there is a tool you can use to manage remote sessions. Hit your start key and type Remote Desktop Services Manager into the search box. It should find an entry of the same name that you can run. If you don't see that entry, try connecting to a Windows Server system and looking there.

When the window opens, there will be an area on the left side that says, "Remote Desktop Services Manager", with a computer (probably your computer) listed underneath. Right click on the Remote Desktop Services Manager option and choose "Connect to Computer". A window will open where you can choose "Another Computer" and enter the computer name that you are unable to reach. Now the name of the locked computer will show in the list. Click on it, the section to the right will show information about that computer, including a tab that will show any open sessions. From here, you can right-click on a session and choose to disconnect, logoff, or reset it. Do that, and you will be able to connect to the computer via remote desktop again.

Joel Coel
  • 12,932
  • 14
  • 62
  • 100