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?
Asked
Active
Viewed 233 times
0

Hossein
- 24,202
- 35
- 119
- 224
-
thanks thats what i was after ;) – Hossein Apr 20 '13 at 13:46
-
I think that this is one of the things that a Service is for. – RBarryYoung Apr 20 '13 at 14:41
-
1This is not a duplicate as the question asks how to "grant" rights to code whereas the other question asks how to "require" it. These have differently solutions. – Yogi Oct 06 '19 at 03:08
1 Answers
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