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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:54:51+00:00 2026-06-12T06:54:51+00:00

I want to get a handle on the current logon session of processes whose

  • 0

I want to get a handle on the current logon session of processes whose parent is explorer.exe.

If we run a process as administrator or a service it won’t have a logon session. The reason I want to get the logon session is that I have a program (.exe) which I want to restrict opening when a user tries to open it via (right click on the .exe–> run as administrator) and when a user opens it via administrator we don’t have a logon session associated with it whereas when a user opens it by double clicking on it, it has a logon session associated with it.

I searched quite some places, but I just get the process for getting the logon SID. If someone wants more information, you can download http://technet.microsoft.com/en-us/sysinternals/bb896653 and under the explorer –> right click on any program executing –> security. Here you will find the logon session.

  • 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-12T06:54:52+00:00Added an answer on June 12, 2026 at 6:54 am

    You can get the logon session associated with a process by using OpenProcessToken followed by GetTokenInformation with the TokenStatistics option. However, this is not a sensible way of finding out whether or not a process was launched using “run as administrator” because there is no straightforward way to determine whether a particular logon session is elevated or not. It is not true that a process launched with “run as administrator” will not have a logon session.

    To find out whether a process was “run as administrator” use the TokenElevationType option. This should return TokenElevationTypeFull if and only if “run as administrator” was used.

    (One caveat: I’m not certain what TokenElevationType will return if a non-administrative user uses “run as administrator” and then enters an administrator username and password. You should test this scenario. You might want to use TokenElevation rather than TokenElevationType.)

    If what you really want to know is whether the process has administrative privilege, you should use CheckTokenMembership instead. Look for the Administrators group. The MSDN documentation has sample code that does exactly this.

    The distinction here is what you want to happen if UAC is disabled (and the user is an administrator) or if the user is the local Administrator. In these cases there is no “run as administrator” option, all processes are run with administrator privilege automatically. If you want to detect these cases, use CheckTokenMembership. If you only want to detect the cases where the user explicitly said “run as administrator” use TokenElevationType.

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

Sidebar

Related Questions

In a nested WPF ToolBarPanel-ToolBar-Menu we want to get rid of the grip handle
I want to do the following with my javascript codeblock. Handle all current and
Is there a way to get the service name from C# that the current
I want to programmatically determine if the current user (or process) has access to
In my application I want to get the current mouse cursor to display it
Why would I want to get out of an Error Handler (after handling) with
I want get the time used for a case so I can create an
I want get all of the Geom objects that are related to a certain
I want get as much as possible from Redis + Hiredis + libevent. I'm
What I want: get a xml from the AppData to use What I code

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.