Windows 7 and 8 supports a feature that allows you to switch accounts on the same computer without logging out the first one. To do so, you can select Switch User from Start Menu on Windows 7 computers.
Or, on both Windows 7 or 8 computers, simple press Ctrl+Alt+Del, and select Switch User from the list.
But do you know that you can also quickly switch accounts right from a command line?
If you are switching to an account that hasn’t been logged in, press Win + R to bring up the Run dialog box, type tsdiscon
, and press Enter. It quickly locks your current account and switches you back to the log in screen readying for you to make the switch.
If you are switching to an account that’s already logged in, you can use the command tscon
instead with the proper syntax.
tscon {sessionid | sessionname}
Or you can specify the password with the switch /password:pw.
Behind the scene, both command lines, tsdiscon and tscon, are used to work with a remote desktop service session but since every user logged in Windows 7 or 8 can be considered a remote session, you can use the command to fulfill our needs descirbed in this post.
tscon {sessionid | sessionname}
how to use it? what should I put in place of sessionid or sessionname? I tried putting the user name, but its not working, its says session name not found. I even tried
tscon computernameusername
still the same problem.
Please help.
Thanks.
Open a CMD prompt, and run the following command:
%SystemRoot%System32tasklist.exe
TaskList will give you a list of all the running process, it also includes the Session Name (if there is one) and Session# (Note: the user must already be logged in to switch to it; otherwise first use “%SystemRoot%System32tsdiscon.exe /v” to disconnect from the current session [/v will write the current session name and ID to the command window while disconnecting; but you will need to log back on to that account to see it], and then logon as a different user to stat the new session. Now you can switch back using %SystemRoot%System32tscon.exe see the notes below.).
Open a CMD prompt, and run the following (/V is optional):
tsdiscon.exe /v
Optional Verbose Output (only visible if you log back in after using /V above):
“Disconnecting sessionID 2 from sessionname Console”
Logon as a new user, Open an Elevated CMD prompt [Runas Administrator], run the following command to switchback to session 2:
tscon.exe 2 /DEST:Console /PASSWORD:* /V
Note: * will prompt you for the password of the account/session you are switching to; otherwise the password needs to be entered in the command in lieu of the asterisk as plan text.
Now to switch back to session 1, run the following from an Elevated CMD prompt (enter the password for the account that is logged in to Session 1 when prompted):
tscon.exe 1 /DEST:Console /PASSWORD:* /V
If you are switching to an account that hasn’t been logged in, press Win + R to bring up the Run dialog box, type tsdiscon, and press Enter. It quickly locks your current account and switches you back to the log in screen readying for you to make the switch.
I typed tsdiscon in the Win + R dialog box, except it says file name not found. Please help me with this!