I've created a Visual studio Setup Project, and I have an Installer Classes created for my main App. In this Installer Class, I overridden the Uninstaller function to clean extra folders created by my app. This works fine in windows XP, but not in Windows 7 since I assume it has something to do with UAC. How Can I force my Uninstaller to elevate privileges?
I've asked this question in another post, but I wasn't clear on my intentions.
I've found these links but I don't know if it's relevant:
http://msdn.microsoft.com/en-us/library/aa370852.aspx
http://msdn.microsoft.com/en-us/library/aa370134%28v=VS.85%29.aspx
UPDATE (11/7/2011)
I found out about Orca which it can be used to modify the msi install app properties, but there are no proper documentation for it, (or examples/tutorials). So here are the steps I took to fix this issue:
- open the appInstal.msi with Orca.
- from the Left Tables click on customAction
- add a new entry to the end of all the rows (by double clicking a new row)
- type Elevate_Install_Uninstall for Action names and 3072 for type
- type ALL for target and leave Source empty
Hope this helps someone/
My assumption is that you created a new custom action which executed when uninstalling your MSI package. To run a custom action elevated — either on install or on uninstall — it has to be deferred and it has to be marked with noimpersonation flag.
In WiX, you would set these properties of the
CustomAction
element:Execute="deferred"
andImpersonate="no"
.In terms of Windows Installer, your custom action has to have these bits set:
msidbCustomActionTypeInScript
+msidbCustomActionTypeNoImpersonate
; see Custom Action In-Script Execution Options.Vista's UAC is similar to window's 7's so you should find some help here:
http://www.professionalvisualstudio.com/blog/2007/10/05/enabling-your-application-for-uac-on-vista/
This write up details how to adjust your app to run without running into problems with UAC.
It allows you to add a manifest file to your solution to make sure it runs at a certain level privilege wise.
Add these attributes to the Uninstall procedure: