1

I'm trying to find a way to determine if a process is setup to run as administrator without the process running. All solutions I've been able to find are for determining if the current user is able to run a process as administrator or to check if a current running process is running in administrator mode. I want to be able to check on a process that is not running, but to be able to determine that in it's Properties > Compatibility Properties > the 'Run this program as an administrator' flag is checked.

Before this gets marked as a duplicate question, I've checked here: C# Check if run as administrator

Here: Detect if running as Administrator with or without elevated privileges?

Here: Detect if another process is started as "Run as Administrator"

As well as most other related questions.

A lot of these question answer whether or not the current user has administrator privileges for a specified process.

Other questions answer whether or not a current process is running in administrator mode or not.

I want to be able to detect if a process, that is not currently running, has the 'Run this program as an administrator' flag checked within compatibility settings.

Thanks for any help in advance!

StevieP
  • 131
  • 1
  • 14
  • A program can require to run as a Admin but the flag is off; it's internal to the program; what would you do in those case? – Bestter Jan 24 '19 at 19:48
  • @Bestter I'm not concerned for those cases right now. This is mainly going to be used to verify installer procedures were carried out as expected. An installer sets these properties and then I want to be able to verify properties were set as expected. – StevieP Jan 24 '19 at 19:50
  • This might help: https://www.techspot.com/guides/1718-run-as-administrator-explained/. It looks like (after a quick scan) that it points to HKCR\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers. – Flydog57 Jan 24 '19 at 19:52
  • @Flydog57 Thanks, I understand that administrator properties can be assigned from multiple areas. Our installer should be assigning the privilege via compatibility settings so checking that the layer in place wouldn't be verifying that the compatibility settings are set as expected. I need to verify compatibility settings within a process. I'm not entirely sure it's possible but that's the solution I'm currently looking for. – StevieP Jan 24 '19 at 20:02
  • Well, when you set the compatibility setting, it's going to write to either the file system or the registry. Setup process monitor to look at Explorer. Turn monitoring on, make a sample compatibility change, then turn off the process mon spigot and wade through all the entries to see what changed. I'm about 99% sure that this shim information is stored in the OS somewhere, and doesn't affect the process directly; that it only affects how the shell starts the process – Flydog57 Jan 24 '19 at 20:14

0 Answers0