Privilege Elevation only when and if required.

Posted by Cameron Peters on Stack Overflow See other posts from Stack Overflow or by Cameron Peters
Published on 2010-06-17T18:18:00Z Indexed on 2010/06/17 18:23 UTC
Read the original article Hit count: 824

Filed under:
|

My application only very occasionally requires privilege elevation... I need to reference some 3rd party COM components that only work correctly when run as administrator.

I would like my application to request privilege elevation only when it needs it... Generally, I don't want my application to run as administrator unless I need to use the 3rd party COM components.

I see that CoCreateAsAdmin could potentially solve the problem, but the component author doesn't set up the required registry entries, and I'm not sure how to use CoCreateAsAdmin in C# and in conjuction with Runtime-Callable-Wrapper that is created by tlbimp.

Another solution would be to spawn another process, but I have no experience with this yet... I don't want to create a completely separate application... I would be happy to create an assembly that runs in a separated elevated process if someone can show me how to make it work.

Thanks...

© Stack Overflow or respective owner

Related posts about c#

Related posts about privilege-elevation