How to switch user from a command line

11

5

XP, Vista or Windows 7:

Is there a command to use the "switch user" feature, the same way there is one to lock the workstation?

user34049

Posted 2010-04-13T08:48:43.433

Reputation: 119

Answers

16

Is there a command to use the "switch user" feature,

You can connect to an existing session with tscon.


What I'd like to do is get to the "welcome screen",

Use tsdiscon.

If Fast User Switching is on, then simply locking the workstation* should display the Welcome Screen too.

* I hope you don't use rundll32 LockWorkStation.

user1686

Posted 2010-04-13T08:48:43.433

Reputation: 283 655

Sorry about the delay. TSDISCON suits my purpose. – user34049 – 2010-08-10T15:21:18.630

I'd like to emphasize that this works when not using RDP, even if the documentation doesn't give hints in that direction. – Bowi – 2018-03-08T16:12:26.767

tscon works even via RDP, only tsdiscon won't return you to the login screen. – user1686 – 2018-07-25T16:31:20.583

@Bowi do you mean that this doesn't work when using RDP instead? – Matthieu – 2019-10-28T13:55:34.163

1@Matthieu No. As far as I remember, the documentation of tsdiscon says use this to disconnect from a rdp session. So my comment is a hint to anyone else who 1) reads this answer 2) reads tsdiscon documentation and 3) says Hey, this answer is wrong, tsdiscon can only be used when using RDP!. – Bowi – 2019-10-28T14:05:09.427

3Then choose that as answer :) – kokbira – 2011-05-10T19:56:05.257

2

I believe it is possible, this article from Lifehacker explains how:

runas /user:*computer name\*account name explorer.exe

Sam152

Posted 2010-04-13T08:48:43.433

Reputation: 2 052

Thanks, but this only opens an Explorer window under the context of another user. I've used it many times. What I'd like to do is get to the "welcome screen", or even downright open a session under the other user's ID, with a single command (which I'd put in a shorcut in the quick-load toolbar). – user34049 – 2010-04-13T15:31:34.083

2*computer name\* is unneccessary. – user1686 – 2010-04-13T15:41:28.007

And runas will prompt for a password, so you can't use it in scripts. Use PsExec instead if you can.

– Matthieu – 2019-10-28T13:57:22.010

"computername" is necessary to access another computer. about launching explorer, it is only 50% of the path... – kokbira – 2011-05-10T19:56:52.290

2@kokbira Then Sam152 should change his answer to stipulate that is it unnecessary unless you are trying to run an instance of explorer.exe in the context of another account existing on another PC, though I note that the OP didn't state he wanted to do this with an account from another PC, in fact he didn't request anything to do with another instance of explorer.exe. – user66001 – 2013-03-07T07:03:03.497

ok, but I'm talking about killing explorer before running it as another user. doing as @sam152 said will open only a new explorer window – kokbira – 2013-03-22T11:55:52.747

this only works in XP – MDT Guy – 2013-12-18T18:37:53.633