Menu
InformatiWeb Pro
  • Index
  • System admin
  • Virtualization

Login

Registration Password lost ?
FR
  • Windows Server
    • WMS 2012
    • WS2012 R2
    • WS2016
  • Citrix
    • Citrix NetScaler Gateway
    • Citrix XenApp / XenDesktop
    • Citrix XenServer
  • VMware
    • VMware ESXi
    • VMware vSphere
    • VMware Workstation
  • Microsoft
    • Hyper-V
  • RAID
    • Adaptec SmartRAID
  • UPS
    • APC Back-UPS Pro
  • InformatiWeb Pro
  • System admin
  • Windows Server
  • Courses
  • Learn how to deploy RDS on WS 2012 and 2012 R2
  • Unblock a session as admin
26 / 27
  • Put a session host into maintenance
  • Unblock your session as a user
  • Windows Server
  • 19 April 2019 at 18:21 UTC
  • InformatiWeb

Unblock your users RDS session as administrator on Windows Server 2012 / 2012 R2 / 2016

When your users use RemoteApp programs or desktops that you have made available through the RDS solution, it's possible that one program crashes on the server.
It's also possible that their session has a problem and that you are the only one who can solve this problem. Indeed, only the administrator has access to the physical server to manage the sessions and the use of its resources.

  1. Close processes or the session from the GUI
  2. Close processes or the session from the command line
    1. Close a process on a specific session
    2. Close a specific session

1. Close processes or the session from the GUI

By using the graphical interface of your server, you can help your users with the task manager.

As an administrator, by clicking on the "More details" option in the task manager, you will be able to manage open sessions on your session host server, as well as open processes in each session.
For example, as an administrator, you could close a RemoteApp program (in this case : Microsoft Excel) remotely.

Or completely close the session of the remote user by right clicking "Sign off" (or "Log off") on it.
Then, your user will be able to access the desktops and/or programs RemoteApp they can use.

From the server manager, you can also disconnect or log off a user.
To do this, go to "Remote Desktop Services -> Collections -> Name of the collection (optional).
Then, in the list of connections, locate the name of your user and right-click "Log off" on it.

Once the session is closed from the server, your user will receive the following error message :

Plain Text

Your Remote Desktop Services session has ended.
...
Your network administrator or another user might have ended your session.
...

2. Close processes or the session from the command line

For fans of the command line or those who have installed a server in Core mode, here is how to close the processes and sessions of your users.

2.1. Close a process on a specific session

To begin, you must retrieve the session ID that corresponds to the session of the desired user (in our case : InformatiUser).

Batch

query session

This command will display a list of Terminal Server sessions open on the current server.

Plain Text

 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE

 services                                    0  Disc
>console           Administrator             1  Active
 rdp-tcp#0         InformatiUser             2  Active
 rdp-tcp                                 65536  Listen

To close RemoteApp programs or other processes on one of these sessions, you will need to specify on which session you want to close the process.
If you don't specify this information as a parameter, the process will be closed on your session and not the user's one.

To list the processes launched on a specific session, you will have to use the "query process" command by specifying the ID of the desired session.

Batch

query process /ID:2

Which give :

Plain Text

 USERNAME              SESSIONNAME         ID    PID  IMAGE
 system                rdp-tcp#0            2   3500  csrss.exe
 system                rdp-tcp#0            2   2564  winlogon.exe
 dwm-2                 rdp-tcp#0            2    328  dwm.exe
 informatiuser         rdp-tcp#0            2   1220  taskhostex.exe
 informatiuser         rdp-tcp#0            2   2936  rdpclip.exe
 informatiuser         rdp-tcp#0            2   2732  rdpinit.exe
 informatiuser         rdp-tcp#0            2   2292  rdpshell.exe
 informatiuser         rdp-tcp#0            2   1192  excel.exe

Or by specifying the name of the user.

Batch

query process InformatiUser

In this case, you will see only those launched as [user name]. The system processes will not be displayed.

Plain Text

 USERNAME              SESSIONNAME         ID    PID  IMAGE
 informatiuser         rdp-tcp#0            2   1220  taskhostex.exe
 informatiuser         rdp-tcp#0            2   2936  rdpclip.exe
 informatiuser         rdp-tcp#0            2   2732  rdpinit.exe
 informatiuser         rdp-tcp#0            2   2292  rdpshell.exe
 informatiuser         rdp-tcp#0            2   1192  excel.exe

To close a process on the right user session, the quickest is to target the process with its ID (which is unique per process per session).
Important : the PID changes each time the process is closed and restarted.

In our case, we will close "Microsoft Excel" which corresponds to the "excel.exe" process whose ID is : 1192

Batch

taskkill /PID 1192 /F

Display again the list of processes launched on this session.

Batch

query process InformatiUser

As you can see, the process "excel.exe" has disappeared from the list.

Plain Text

 USERNAME              SESSIONNAME         ID    PID  IMAGE
 informatiuser                              2   1220  taskhostex.exe
 informatiuser                              2   2936  rdpclip.exe
 informatiuser                              2   2732  rdpinit.exe
 informatiuser                              2   2292  rdpshell.exe

We then relaunched our Microsoft Excel RemoteApp program from the client computer to show you another technique.
For those who would like to close a process with the name of the executable file on a specific session, here are 2 possibilities.

1st possibility :

  • use the "SESSION" filter to target a specific session. In our case, this is the session with ID : 2.
  • use the "im" (which means : image) parameter to target a process by its name. In our case : excel.exe.

Batch

taskkill /FI "SESSION eq 2" /im:excel.exe /F

Plain Text

SUCCESS: The process "EXCEL.EXE" with PID 2220 has been terminated.

2nd possibility :

  • use the "USERNAME" filter to target a specific session. In our case, this is the session opened by this user : InformatiUser.
  • use the "im" (which means : image) parameter to target a process by its name. In our case : excel.exe.

Batch

taskkill /FI "USERNAME eq InformatiUser" /im:excel.exe /F

Plain Text

SUCCESS: The process"EXCEL.EXE" with PID 1552 has been terminated.

2.2. Close a specific session

To begin, list the active sessions on your session host server.

Batch

query session

This command will allow you to know the open sessions on your server, as well as the ID of each session.

Plain Text

 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
 
 services                                    0  Disc
>console           Administrator             1  Active
 rdp-tcp#0         InformatiUser             2  Active
 rdp-tcp                                 65536  Listen

To close a session using its ID, use this command :

Batch

logoff 2

If you want to use the name of the session (which has nothing to do with the name of your user), use the command like this.
The name of the session being what is indicated in the "SESSION" column of the result returned by the "query session" command mentioned above.

Batch

logoff rdp-tcp#0

After the session is closed, your user will receive an error message :

Plain Text

Your Remote Desktop Services session has ended.
You were logged off the remote computer.

Share this tutorial

Partager
Tweet

To see also

  • WS 2012 / 2012 R2 - RDS - Set up HA on your RDS infrastructure

    Windows Server 6/7/2019

    WS 2012 / 2012 R2 - RDS - Set up HA on your RDS infrastructure

  • WS 2012 / 2012 R2 / 2016 - RDS - Access RemoteApp via a modern application

    Windows Server 3/8/2019

    WS 2012 / 2012 R2 / 2016 - RDS - Access RemoteApp via a modern application

  • WS 2012 / 2012 R2 / 2016 - RDS - Attempt to unblock the session as a user

    Windows Server 4/28/2019

    WS 2012 / 2012 R2 / 2016 - RDS - Attempt to unblock the session as a user

  • WS 2012 / 2012 R2 / 2016 - RDS - Change the properties of RemoteApps

    Windows Server 3/16/2019

    WS 2012 / 2012 R2 / 2016 - RDS - Change the properties of RemoteApps

Comments

You must be logged in to post a comment

Share your opinion

Pinned content

  • Software (System admin)
  • Linux softwares
  • Our programs
  • Terms and conditions
  • Share your opinion

Contact

  • Guest book
  • Technical support
  • Contact

® InformatiWeb-Pro.net - InformatiWeb.net 2008-2022 - © Lionel Eppe - All rights reserved.

Total or partial reproduction of this site is prohibited and constitutes an infringement punishable by articles L.335-2 and following of the intellectual property Code.