How to Kill a TS session remotely

Check / reset terminal services sessions:

qwinsta = Query WINdows STAtion
rwinsta = Reset WINdows STAtion

Run a command prompt window as a user with administrative rights to the non-accessible machine.

Command line syntax:

qwinsta /server:ServerIP
rwinsta /server:ServerIP SesionID

Qwinsta will produce a list of RDP session names and IDs:

 SESSIONNAME       USERNAME                 ID           STATE   TYPE        DEVICE
 console                                                             0            Conn       wdcon
 rdp-tcp                                                              65536    Listen     rdpwd
                                   michael                           1            Active    rdpwd

Rwinsta will disconnect the ID session:

C:\rwinsta /server: 1

Additionally - you can use the /console switch to connect to the console session of a Windows XP Professional-based computer, or a Windows Server 2003:

mstsc.exe /v:ServerName[ :Port] /console

The commands Querry Session and Reset Session call the above commands.

To kill a TS session on a machine within the domain, simply type this from any VPS server:

reset session session_ID /server:server_name

server_name can be the NT server name, or an IP address. To find the session_ID, use this command:

query session /server:server_name

Now you've got your session_IDs, so just kill those sessions! Now on to the neat part: You can use this command to reset connections on dedicated servers.

From the Run box, type the following:

runas /netonly /user:dedservername\administrator cmd

Now, just use the above process to Query the sessions, and kill all that you need to. For dedicated resets, using the IP address for server_name works a lot better.

Article ID: 196, Created On: 9/3/2002, Modified: 8/31/2010

Feedback (0)