views:

41

answers:

1

I have a program installed in ProgramData. I use UAB 2.1 to updating app but it's failed because accessing to the path is denied (OK with text files so I think there's problem with UAC). How can I get overwriting rights in ProgramData/MyAppFolder or display a dialog to notice user give overwriting rights for updater.

Many thanks in advance.

Update

I've read an article at http://blogs.msdn.com/b/cjacks/archive/2008/02/05/where-should-i-write-program-data-instead-of-program-files.aspx. It said that You'll want to create your directory and set the ACLs you need at install time. Should I change installation folder to LocalAppData or try to set ACLs at install time according the article.

A: 

Apps that update themselves have a hard time under UAC. Your best bet is to partition the code that does the update into a separate exe. Put a manifest with requireAdministrator on that exe. In the main app, leave the code that checks for updates, and have it enable a button or menu item when an update is needed. Put a shield on that button or menu item, and have it launch the separate exe with ShellExecute. The user will get a UAC consent dialog, which they will be expecting because of the shield. The separate exe, because it's elevated, will be able to write to Program Files and other protected areas.

Kate Gregory
Thank you for answering. I've understood your solution but still somethings must considered: 1> I think the separate exe with UAC consent dialog have not good user experience. How could I modify UAC consent dialog to show an clearly explanation.2> In case my users are only use program with standard account.Should I change installation folder to LocalAppData or try to set ACLs at install time.Thank you.
langxangvn
You can't change the UAC dialog. You can, however, give them one of your own in advance. So when an update is available, give them a message box "An update is available. To install it click the Update button. You will need to consent to the [describe it in a way they will understand] dialog." Signing your app may make the UAC dialog more pleasant for them since it won't say Unknown Publisher and have the scary orange bar across the top.Installing your app outside ProgramFiles leaves your users vulnerable to malware. I would not recommend it.
Kate Gregory
Thank you very much.
langxangvn