1

In order to get whether the current process is running with administrator privileges, we use the following C# code:

public static bool IsElevated {
    get {
        return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
    }
}

However, I am trying to find whether another separate process is elevated or not.

How do I go about doing that programmatically?

MathuSum Mut
  • 2,765
  • 3
  • 27
  • 59

1 Answers1

2

Try this out: https://stackoverflow.com/a/4497572/3049344

var process = Process.GetProcessesByName("YouProcessName").First();
IntPtr tokenHandle;
if (!OpenProcessToken(process.Handle, TOKEN_READ, out tokenHandle))
{
         throw new ApplicationException("Could not get process token.  Win32 Error Code: " + Marshal.GetLastWin32Error());
}
                             ...
Community
  • 1
  • 1
Dmitrii Zyrianov
  • 2,208
  • 1
  • 21
  • 27