How do I programatically log off the current user and log on as another?
<p>Is there a way to force a logoff (knowing this is not recommended) of the current interactive (logged-on) user and then login with a new user account (interactive - not using stuff like LogonUser and other impersonation tricks) to simulate someone physically pressing LOGOFF and then selecting a new account to LOGON...?</p>

<p>The issue is that my service creates a new user account programatically - and I need to find a way to create its corresponding user profile. From what I can see the only way that works would be to physically logoff the current user, and then login as the new user (which will create the User Profile for HKCU, Documents &amp; Settings, etc...). Sounds a little crazy but I can't find a better way... </p>

<p>So, I need to find a way to programmatically force the logoff &amp; logon actions (from my running Windows Service under LocalSystem) - I have all the credentials and access rights needed ... Are there system function calls I can use?</p>

<p>For Logoff I think I can use WTSLogoffSession(...), still trying to get it to work but seems promising - however I have no clue what to do about logon...
Alternitively if there is a better approach to solve my problem I am all ears :)</p>

<p>Any help or hints would be much appreciated...
Thanks,</p>
