views:

210

answers:

2

I have an .NET application which is run with default rights as the current user, then at some point I need to perform an action which requires admin rights.

How can I get admin rights on-demand in a .NET application?

Requiring that the application is run with admin rights from the beginning is not appropriate as it may be that such action may not be called.

+2  A: 

I don't think this is possible. One way to get around it would be to split your application in two, one for all the operations that doesn't need elevation and one for the ones that do. Then you run the non elevated app as normal but start up the elevated one when needed.

ho1
A: 

Ask username/password and impersonate the admin user.

Hasan Khan