9

I'm trying to create a utility similar to Microsoft's abandoned Super Fast User Switcher (download), which allows fast user switching without going through the Welcome screen.

I have a working implementation using the undocumented WinStationConnectW API (along with WTSEnumerateSessions), but it can only switch to a user who is already logged in.

How can I create a login session so that it can switch to a user who is not logged in?
I only need to support XP, although it'd be nice to work on Vista / Seven. (My current code already does)

I know that this is possible because Super Fast User Switcher does it. (Although it needs a Windows service to do it)

I'm writing C#, but I can translate any answer into C#.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Did you try P/Invoking LogonUser? – Hans Passant Jan 25 '10 at 18:17
  • @nobugz: `LogonUser` creates a user token, not a logon session. I'm already using it to verify passwords. – SLaks Jan 25 '10 at 18:24
  • 1
    Since other groups do some similar work with stuff like Citrix or GotoMyPC I would think that this would be doable. However, they may be doing something in their own service, so I'm not sure. – jcolebrand Nov 01 '10 at 17:15
  • @drachenstern: AFAIK, none of these create login sessions; they simply reuse existing ones (using `WinStationConnectW`). I'm not sure about Citrix, though. – SLaks Nov 01 '10 at 17:20
  • you managed to create session in win 7? – Omega Doe Jul 20 '16 at 06:46

2 Answers2

6

I solved this in XP by calling the undocumented InitiateInteractiveLogon function in the ShellLocalMachine COM object in shgina.dll.

This method, which can only be called by the Local System account, will log a user on to the console. (It cannot log a user on to an RDP session)

The version of the DLL included with Windows 7 (and presumably also Vista) does not contain this method.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • 4
    This function is _so_ undocumented that it has no Google search results whatsoever. (Google hasn't indexed this answer yet) http://www.google.com/search?q=shgina.dll+ShellLocalMachine+%2BInitiateInteractiveLogon – SLaks Feb 01 '10 at 20:57
-1

Which Windows versions you want to target?

I believe that there is no simple way. For Windows XP there is GINA. For Windows Vista, there is 'Credential Providers'.

Also, if you are targeting Windows XP, you can create service, that sends keystrokes to WinLogon desktop to log in as if user pressed them on keyboard. This was done by RealVNC or UltraVNC, I don't remember. However, this approach does not work in Windows Vista.

Maris B.
  • 2,333
  • 3
  • 21
  • 35
  • GINA is out of the question because it is (for some reason) incompatible with Fast User Switching. – SLaks Jan 31 '10 at 12:45