0

Is it possible to grant administrative rights for a specific portions/snippets of the program when they are executed?
I know we can use manifest files to give our whole application the admin rights,but i don't like that since suppose 70% ~ 80% of my application services don't need administrative rights and or my end users don't really like to face UAC prompt each time they run the application.
Is there a way to achieve such a goal?

Hossein
  • 24,202
  • 35
  • 119
  • 224

1 Answers1

4

The rights that executing code has are controlled by the process token which is a process wide object. So, if your process has elevated rights, all code that executes in that process has elevated rights.

The conclusion is that, in order for different parts of your application to have different rights, you need to have multiple processes.

It is perfectly common and standard for applications to do this. An application can start with separate rights. When the user wishes to perform an action that requires elevated rights, the program invokes a separate executable to perform that task. This is indeed better for the user since they only need to face the UAC dialog for actions that actually need elevation.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490