Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 371807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:09:00+00:00 2026-05-12T14:09:00+00:00

Is there a way to force a logoff (knowing this is not recommended) of

  • 0

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…?

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 & Settings, etc…). Sounds a little crazy but I can’t find a better way…

So, I need to find a way to programmatically force the logoff & 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?

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 🙂

Any help or hints would be much appreciated…
Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:09:00+00:00Added an answer on May 12, 2026 at 2:09 pm

    Microsoft has this solution in c++, which you can use to hack a c# solution, or put in a DLL and call it using COM interop.

    http://support.microsoft.com/kb/196070

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to force the this keyword to act as a ref
is there a way to force the login to be case insensitive using acegi
Is there any way to force Maven to use remote artifacts and not those
Is there a way to force expression engine to NOT render items within curly
Is there a way to force sql connection to always user 'string' as unicode
Is there any way to force a user to give his/her input via overwriting
Is there are way to force a singleton instance to reset whenever a user
Is there a way to force the use of the this keyword in Visual
Is there any way to force a listview control to treat all clicks as
Is there any way to force an update of software using RunOnce, without having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.