Friday, December 24, 2010

Logoff remote desktop sessions via CMD

To List the session in remote server we use quser.exe

Display information about users logged on to the system.

QUSER [username sessionname sessionid] [/SERVER:servername]

username Identifies the username.
sessionname Identifies the session named sessionname.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server to be queried (default is current).

Example:

C:>quser /server:CONCHNDATP001

USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
A-BalaK ica-tcp#966 10 Active 7 12/25/2010 3:04 PM
GBala ica-tcp#969 1 Active 9 12/25/2010 3:30 PM
Admin ica-tcp#984 5 Active 1:06 12/25/2010 4:33 PM
Finance ica-tcp#987 2 Active 4 12/25/2010 6:20 PM

Logoff the Remote Sessions

To Log off the terminal session of the remote server, Before you log off the remote session, you should know the "Session ID" which you get it from "QUSER" commands as above stated.

1. Logoff
Logoff command kicks off (logging off) the specified remote session. Log off help shows,

C:>logoff /?
Terminates a session.

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

sessionname The name of the session.
sessionid The ID of the session.
/SERVER:servername Specifies the Terminal server containing the user
session to log off (default is current).
/V Displays information about the actions performed.


E.g.,

C:>logoff 2 /server:CONCHNDATP001 /v
Logging off session ID 2



1 comment:

  1. Do you know the command to logoff particular user (Not session)?
    Like logoff /server:xxxx username
    My requirement is that i want to logoff a particular user and not the session. Because username is unique for all the servers but session ID

    vary for the same user in different different servers. So for example i am making a batch file to logoff the same user from 100 servers

    simultaneously, i have to put 100 different session IDs or session names for all the servers, but if i know the command to logoff the same

    user from 100 different servers then it will be easier for me to make a batch file and log hi

    ReplyDelete