Search notes:

tscon.exe

Session Connection Utility. The ts stands for Terminal Server (now being called Remote Desktop Services).

Example: Switching between user sessions in the command line

Although the primary focus of tscon.exe and tsdiscon.exe is Remote Desktop Services, it is possible to use these command line tools to switch between sessions.
The initial position is that only one user (besides services) is connected (and has a session), which can be queryed with query session:
C:\> query session
 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
 services                                    0  Disc
>console           Rene                      1  Active
So, we want to login with an additional user and its separate session. This is possible with tsdiscon.exe. tsdiscon does not log out the that is executing this command, but it locks his account and gotes to the logon-screen. With the logon screen, we're able to start the second user session:
C:\> tsdiscon
Now, with another user logged in, we can query the sessions again:
C:\> query session
 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
 services                                    0  Disc
                   Rene                      1  Disc
>console           AnotherUser               2  Active
With tscon, we can switch back to the first session, without logging out the currently active session:
C:\> tscon 1 /password:secretGarden

See also

tsdiscon.exe, the session disconnection utility

Index