Visual Studio Setup Project: How Can I force an Uninstaller to run in Administrator mode?

瘦欲@ 提交于 2019-12-03 17:47:07

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" and
  • Impersonate="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:

    [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
    public override void Uninstall(IDictionary savedState)
    {
        base.Uninstall(savedState);
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!