0

I'm trying to manage user's RDP session at Windows Server 2003. I have one Windows host. This host runs several user sessions.

c:>qwinsta

SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>console           Administrator           0   Active  wdcon
rdp-tcp                                    65536  Listen  rdpwd
rdp-tcp#1         test1                    1   Active  rdpwd
rdp-tcp#2         test2                    2   Active  rdpwd

Sometimes I need to close user's session and open it from the scratch.

RWinsta %sessionID% command works fine - user session is closed.

but I still have mstsc.exe process running and an opened window with the information "the remote session was disconnected because your session was logged off at the remote computer"

How could I close not only user session but mstsc process also? Thank you.

cyber_by
  • 61
  • 5
  • So for now I'm using the next solution: 1. I wrote an java application - it creates .rpd files for each user (user01.rdp, user02.rpd and so on) with the rdp settings inside (login, passwd, host..) 2. run "mstsc.exe user01.rdp" - it creates rdp session and! the RDP window title contains username "user01 - bla bla bla" Now it is possible to filter mstsc.exe by username using "tasklist /FI WINDOWTITLE", and than I can logoff user and after that kill mstsc process. Insane algorithm, but it works. – cyber_by Jun 12 '15 at 13:43

1 Answers1

0

Try below code and check if it works :

taskkill /PID /F

Try more options according to your requirement ,

Try taskkill /?

prudviraj
  • 3,634
  • 2
  • 16
  • 22
  • LOGOFF works similar to RWinsta command. It will logoff user but don't close mstsc.exe window. – cyber_by Jun 10 '15 at 18:05
  • The ID from the "qwinsta" command is not the same as the PID of the "mstsc.exe". We need to know the PID of the process, because we have 3-4 already running mstsc.exe process - and I'm unable to filter them by user name, all processes has the same attributes in "tasklist" command except PID. – cyber_by Jun 12 '15 at 13:43