Archive: Uninstaller + UAC plugin + Vista = confusion


Uninstaller + UAC plugin + Vista = confusion
After using the UAC plugin to make my installer work properly when run on Vista, I updated the uninstaller to also use the UAC plugin. But the uninstaller did not work properly when it was started by a "standard" user on Vista.

The problem is that when a "standard" user runs the uninstaller via the Vista equivalent of "Add/Remove Programs" Vista runs it as an administrator right from the start (i.e. it ignores the RequestExecutionLevel setting). This means the UAC plugin does not start the second process.

I have found that if I create a Start Menu shortcut to my uninstaller and use that from a "standard" account then the UAC plugin will create the second process because Vista pays attention to the RequestExecutionLevel setting in this case.

Am I doing something wrong or will I just have to tell my users to use the Start Menu to uninstall the program?


If you write the uninstall entry in HKCU it does not elevate, when you write to HKLM, it is a all-users type install and you should probably be prepared to handle any user uninstalling it.

If you add two dwords to your uninstall entry in HKLM:
NoElevateOnModify=1
NoRemove=1

you sort of get the desired effect, only problem is that the UI now calls it change instead of uninstall

Unless MS provides another dword for uninstall to disable elevation, there is probably nothing you can do (too late for RTM)

The UAC plugin was mostly designed for install use, not the uninstaller (Solve the run checkbox problem on the finish page)


Thank you for the helpful reply. I'll try your suggestion.

I have found the UAC plugin very useful, thanks for creating it!


I tried to use Anders' trick, only to find that clicking 'Change' in Add/Remove Programs wouldn't launch the uninstaller at all. Instead it displayed some generic error. Together with Anders I've found the solution:

You need to add a ModifyPath regstring to the HKLM uninstall key. You can probably skip the usual UninstallString, in this case. So it'd look something like:

NoElevateOnModify=1
NoRemove=1
ModifyPath="$INSTDIR\uninstall.exe"


Hope this helps someone someday.


Yes
YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES


Thanks! Thats it!

Note: You'll need UninstallString, otherwise your program won't show up in the Add/Remove programs dialog of the control panel ...


Originally posted by MSG
You need to add a ModifyPath regstring to the HKLM uninstall key. You can probably skip the usual UninstallString, in this case. So it'd look something like:
NoElevateOnModify=1
NoRemove=1
ModifyPath="$INSTDIR\uninstall.exe"
Hope this helps someone someday.
Almost, though much of the help is in some sort of imprecise pseudocode, so I have to admit, I can't really see a practical way around this.

When I write the uninstaller, I don't have easy access to the uninstall key.
I write something like this: WriteUninstaller $INSTDIR\Uninstaller.exe

Is this suggestion, then, meant to say that we determine what the key is (with no help from any apis or existing libraries), write some code to write to that registry, taking care to set NoRemove/ModifyPath.

ie are you suggesting the answer you've given, translates to something like this:
WriteRegStr HKLM $0 "NoElevateOnModify" 1
...

Originally posted by DolphinSandwich
Is this suggestion, then, meant to say that we determine what the key is (with no help from any apis or existing libraries), write some code to write to that registry, taking care to set NoRemove/ModifyPath.

ie are you suggesting the answer you've given, translates to something like this:
WriteRegStr HKLM $0 "NoElevateOnModify" 1
...
No, the solution is to write those regstrings during installation, not in the uninstaller. When you add your uninstaller to the Add/Remove Programs list, you write an UninstallString, DisplayName and DisplayIcon entry to "Software\Microsoft\Windows\CurrentVersion\Uninstall\YouAppName", right? That's when you also add the NoElevateOnModify and NoRemove entries.

Right I see.
Something like this:

WriteRegStr HKLM ${ControlPanelKey} "NoElevateOnModify" 1
WriteRegStr HKLM ${ControlPanelKey} "NoRemove" 1