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 9169869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:56:17+00:00 2026-06-17T15:56:17+00:00

I am currently working on some parental control software. This software is supposed to

  • 0

I am currently working on some parental control software. This software is supposed to log out a user and then lock the account so that they cannot log back in unless the parent/admin has specified that they can.

I have tried several things so far such as setting flags on the user account saying that it is disabled. This completely removes it from the login screen. From what I have found out is that if the user account is logged in, it doesn’t apply the ADS_Disable flag. I have also tried looking for resources on logging out another account but I can only seem to find information on logging out the account that is running the logout command. Such as Pinvoke, or directly calling the LOGOUT.EXE program.

I found a resource on LSAUser and found that there might be something there. I am doing this project for school and I am needing a little guidance. Since there is such a sparse amount of information on doing this, is there a better way of doing what I want to do? Or is there a reason why I shouldn’t do this? Any alternatives?

  • 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-06-17T15:56:18+00:00Added an answer on June 17, 2026 at 3:56 pm

    Use the WTSDisconnectSession() Windows API. See article here.

    using System;
    using System.Runtime.InteropServices;
    using System.ComponentModel;
    
    class Program
    {
      [DllImport("wtsapi32.dll", SetLastError = true)]
      static extern bool WTSDisconnectSession(IntPtr hServer, int sessionId, bool bWait);
    
      [DllImport("Kernel32.dll", SetLastError = true)]         
      static extern int WTSGetActiveConsoleSessionId();
    
      const int WTS_CURRENT_SESSION = -1;
      static readonly IntPtr WTS_CURRENT_SERVER_HANDLE = IntPtr.Zero;
    
      static void Main(string[] args)
      {
        if (!WTSDisconnectSession(WTS_CURRENT_SERVER_HANDLE,
             WTS_CURRENT_SESSION, false))
          throw new Win32Exception();
      }
    }
    

    Even without remote desktop, it will disconnect the current user and go to the login screen. The processes will still run in the background. After manually login in again, the running programs will appear as they were before the disconnect.

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

Sidebar

Related Questions

I'm currently working on some .Net based software (.Net Framework 3.5 SP1) that integrates
I'm currently working on some logging code that supposed to - among other things
I am currently working with some users that do not have the .NET Framework
Some background I'm currently working on a mobile site so I keep switching user
I'm currently working on some concurrent code that would appear to have a few
I'm currently working on some R&D for improving the process and practice that we
I am currently working on some Java code that has a lot of ActionListeners
I am currently working with some large Trie structures in Haskell that I build
I'm currently working with some data using Javascript that is in the form of
I am currently working with some code that my co-worker wrote. Here is a

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.