Search This Blog

Tuesday, April 19, 2011

Terminal services Manager commands for CLI

Hi Guys... This article will teach you how we can check the remote login sessions &amp how we can
 kill those sessions &amp also how we can view the remote processes &amp
 how we can kill those... this article will help you to use CLI when some times GUI is not responding.

 To view who and all users are connected to the system here i have given for local system

 C:\Users\reddy>quser
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
reddyjg console 1 Active none 4/19/2011 2:16 PM

If we want to check the remote system users
 C:>quser /server:REMOTEServername
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME

if you want the help syntax you can check the help
quser /?

Here i have given one more command which will be usefull for the same work as above command does. QWinsta is different and better. It has more features and options.
 C:>qwinsta /?
Display information about Terminal Sessions.
QUERY SESSION [sessionname | username | sessionid] [/SERVER:servername] [/MODE] [/FLOW] [/CONNECT] [/COUNTER] sessionname Identifies the session named sessionname. username Identifies the session with user username. sessionid Identifies the session with ID sessionid. /SERVER:servername The server to be queried (default is current). /MODE Display current line settings. /FLOW Display current flow control settings. /CONNECT Display current connect settings. /COUNTER Display current Terminal Services counters information.

 To logoff the remote sessions

 C:\Users\reddy>logoff /?
Terminates a session.



LOGOFF [sessionname
sessionid] [/SERVER:servername] [/V] [/VM]

sessionname The name of the session.
sessionid The ID of the session.
/SERVER:servername Specifies the Remote Desktop server containing the user
session to log off (default is current).
/V Displays information about the actions performed.
/VM Logs off a session on server or within virtual machine. Th
e unique ID of the session needs to be specified.

 EXAMPLE
C:>logoff /server:Remoteservername 1 /v
Logging off session ID 1


There is one more command which will do the same task to logoff a session remotely as logoff command does... RWinsta has same parameters and does same thing as log off command. It simply means Reset Windows Station. The help goes as,

C:\Users\reddy>rwinsta /?
RESET SESSION {sessionname

sessionid} [/SERVER:servername] [/V]



sessionname Identifies the session with name sessionname.

sessionid Identifies the session with ID sessionid.

/SERVER:servername The server containing the session (default is current).

/V Display additional information.




EXAMPLE
C:>RWinsta /Server:MyWinServer 1
 the above command will reset the session with ID 1

How to view the remote running processes
>Tasklist /s Servername

 there are many options available for this command Just go through the help...

Kill the tasks remotely

To kill the tasks running on the server remotely is by using the taskkill command
>taskkill /s Servername

here is the help examples

Examples:

TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"