none
When I try to uninstall my own application I get "You do not have sufficient access to uninstall XXXX"

    Question

  • Hello everyone,

    I am facing a rather annoying problem. I have developed an application that consists of a single EXE file. Now I am trying to add install/uninstall capabilities to it without using external setup packagers like InstallShield or whatnot..

    For example I have programmed the command-line switch "/install" to add the necessary registry key values under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall

    This has worked flawlessly. Now my application appears in the "Programs and Features" list along with all other installed programs from my computer. Now when I click the "Uninstall/Change" button it is supposed to execute the contents of the "UninstallString" key which is calling my application with the "/uninstall" switch. This in turn will delete itself and remove the entry from the registry.

    The problem is that when I click the "Uninstall/Change" button I get an error message saying that I do not have sufficient access to uninstall my app even though I am logged on as an administrator.

    It is worth mentioning that if I right click on the executable file, select "Properties" and check the "Run as administrator" option then the uninstall will work like a charm but I would like to know how to make it work without running it as administrator. I mean all other applications can be uninstalled just fine and they are not running as administrator. Also the uninstall will work flawlessly on Windows XP but that was something to be expected. The problem happens both in Vista and Windows 7. In Vista I even get an UAC prompt and after I confirm that it still tells me that I don't have sufficient access.

    I guess the question is how do I convince the TrustedInstaller that my application is OK to uninstall without any kind of special access? Any insight into this matter is greatly appreciated. Thank you.

    Saturday, June 18, 2011 6:09 PM

Answers

  • This issue has been solved. The manifest needs to specify: requestedExecutionLevel level="highestAvailable" uiAccess="false"
    Then it will work just fine. If uiAccess is "true" then you get the insufficient access error. If requestedExecutionLevel is "asInvoker" then the executable will not be deleted from Program Files.
    I hope this will help anyone else facing this problem.
    • Marked as answer by Melissa Perry Sunday, June 19, 2011 2:19 PM
    Sunday, June 19, 2011 2:19 PM

All replies

  • This is bothering me as well, since it also happens with all those non corporate permitted applications, which users tend to install (Google Toolbar, Chrome, Firefox and such).

    Invoking the installer as it happens in Control Panel to uninstall this stuff seems to require Administrator permissions.

    For your application - what happens, if you run it with its uninstall switch in a command prompt?

    Best greetings from Germany
    Olaf

    Saturday, June 18, 2011 11:00 PM
  • That's a good question. When I run it with the /uninstall switch at the command prompt it deletes its shortcuts from the Desktop and Start Menu, it removes the entry from the "Add/Remove Programs" list in the registry but it fails to delete itself and its folder from Program Files. If I run it from an elevated command prompt then it will also manage to delete itself and its folder from the Program Files. So I guess the question remains how do I tell it to elevate itself when it is run with the /uninstall switch? The Add/Remove module should automatically elevate all applications when they are uninstalled but it seems not to work in this case.
    Sunday, June 19, 2011 12:55 AM
  • This issue has been solved. The manifest needs to specify: requestedExecutionLevel level="highestAvailable" uiAccess="false"
    Then it will work just fine. If uiAccess is "true" then you get the insufficient access error. If requestedExecutionLevel is "asInvoker" then the executable will not be deleted from Program Files.
    I hope this will help anyone else facing this problem.
    • Marked as answer by Melissa Perry Sunday, June 19, 2011 2:19 PM
    Sunday, June 19, 2011 2:19 PM
  • Hi,

    Thanks for your update and effort.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
    Wednesday, June 22, 2011 8:50 AM