none
How to Programatically switch users in windows 7? RRS feed

  • Question

  • Hi

    Lets say i am currently loged into my desktop as two users, One to the local machine and the other to a domain.

    Each has its own desktop. Each desktop has its own set of icons.

    I want to essentially hotkey switch users in such a way that my experience is that i end up on the other desktop without having to re-enter my passwords or perform any clicks.

    In other words. i am on desktop one. I hit lets say "ctrl-Alt-S" and i end up on the other desktop. As simple as that.

    Seems like a simple idea.

    Any security issues are mute as i am the owner of both logins.

    I want to write this in vb.net and am assumeing that i need to use API's.

    Thanks up front

    Jerry C

    Saturday, September 11, 2010 2:47 PM

Answers

All replies


  • That is a security feature of windows that I don't think will be possible to avoid.

    --
    Mike
    Saturday, September 11, 2010 4:37 PM
  • I found a product that does it. It is called DUST.

    It works well and costs $15.

    If it can do it, then i'm sure I can.... If only i knew how!!

    with DUST, all i have to do is press ctrl-alt-S and i get the login screen for the other login.

    I press enter and the saved password gets me in.

    So rapiddly pressing ctrl-alt-s and then enter, gets me to the other desktop in about 7 secs. Pretty good.

    But!!! and that a big but, i want to learn how to do this. and get rid of the need to press enter.

    so my question still stands.

    Thanks

    Jerry C

     

    Saturday, September 11, 2010 11:19 PM
  • Thanks for your question. With some research on this, found  out that Windows Terminal Services APIs can be used for this purpose.

    1.      After getting the handle of server you can enumerate the sessions on the machine using WTSEnumerateSessions

    2.      Then you can provide the session id to the WTSConnectSession where the first parameter should be the target session id that you want to switch to and second parameter can be -1.

    3.      I have to supply the password in third parameter, supplying empty string fails. Looking at the documentation for the parameter, this make sense as well. Currently I don’t know to do successful switch without supplying password.

     

    http://msdn.microsoft.com/en-us/library/aa383837(VS.85).aspx

    http://msdn.microsoft.com/en-us/library/aa383833(VS.85).aspx

    http://msdn.microsoft.com/en-us/library/bb394782(VS.85).aspx

     

    The above is the main logic, rest UI thing can be implemented based on your need and choice.

     

    I hope this helps.

    Wednesday, September 15, 2010 2:31 PM
    Moderator