views:

493

answers:

1

Hi,

I have written a wizard in c++ which installs some files to the program files folder under windows. As I understand, I need Admin rights to write to program files under Vista/7. So my question is: Is there a way to turn on Admin rights while the application is running respectively only for one wizard page? Or do I have to start another process with Admin rights for this one wizard page?

+2  A: 

Typically you have a shield logo'd button and then shell out to another process whose manifest requests elevation.

But really it soudns like you're writing an installer so you should use something designed for that like WiX.

http://stackoverflow.com/questions/133379/elevating-process-privilege-programatically http://msdn.microsoft.com/en-ie/magazine/cc163486%28en-us%29.aspx

Ruben Bartelink
Kind of but I need some custom controls in it. Besides the application is already written, and I try to make it Windows Vista/7 compatible.
mgiza
You need another process unless you require admin on startup via a manifest (which is easy but obviously you dont want to require it each time. There's nothing that says you can't invoke yourself of course). Other approaches might be to preassign rights to a directory at install time. Or otherwise write to AppData or ProgramData like you're supposed to insterad of writing directly to Program Files.
Ruben Bartelink