Visual Studio 安装项目:如何强制卸载程序在管理员模式下运行?

发布于 2024-12-12 08:16:54 字数 883 浏览 0 评论 0 原文

我创建了一个 Visual studio 安装项目,并且为我的主应用程序创建了一个安装程序类。在此安装程序类中,我重写了卸载程序功能以清理由我的应用程序创建的额外文件夹。这在 Windows XP 中工作正常,但在 Windows 7 中不行,因为我认为它与 UAC 有关。如何强制我的卸载程序提升权限?

我在另一篇文章中问过这个问题,但我不清楚我的意图。

我找到了这些链接,但我不知道它是否相关:
http://msdn.microsoft.com/en-us/library/aa370852.aspx
http://msdn.microsoft.com/en -us/library/aa370134%28v=VS.85%29.aspx




更新 (11/7/2011)

I发现Orca可以用来修改msi安装应用程序属性,但没有合适的文档(或示例/教程)。以下是我解决此问题所采取的步骤:

  1. 使用 Orca 打开 appInstal.msi。
  2. 从左表中单击 customAction
  3. 将新条目添加到所有行的末尾(通过双击新行)
  4. 输入 Elevate_Install_Uninstall 作为操作名称,输入 3072 作为类型
  5. ,输入 ALL 作为目标并将源保留为空

希望这可以帮助某人/

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:

  1. open the appInstal.msi with Orca.
  2. from the Left Tables click on customAction
  3. add a new entry to the end of all the rows (by double clicking a new row)
  4. type Elevate_Install_Uninstall for Action names and 3072 for type
  5. type ALL for target and leave Source empty

Hope this helps someone/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

面如桃花 2024-12-19 08:16:54

我的假设是您创建了一个新的自定义操作,该操作在卸载 MSI 包时执行。要运行提升的自定义操作(无论是在安装还是卸载时),它必须推迟,并且必须标记为noimpersonation 标志。

在 WiX 中,您可以设置 CustomAction 元素的这些属性

  • 执行=“deferred”
  • Impersonate=“no”

就 Windows Installer 而言,您的自定义操作必须设置以下位:msidbCustomActionTypeInScript + msidbCustomActionTypeNoImpersonate;请参阅自定义操作脚本内执行选项

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.

紫轩蝶泪 2024-12-19 08:16:54

Vista 的 UAC 与 Windows 7 类似,因此您应该在这里找到一些帮助:

http://www.professionalvisualstudio.com/blog/2007/10/05/enabling-your-application-for-uac-on-vista/

这篇文章详细介绍了如何调整您的应用程序运行时不会遇到 UAC 问题。

它允许您将清单文件添加到您的解决方案中,以确保它在特定权限级别上运行。

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.

魂ガ小子 2024-12-19 08:16:54

将这些属性添加到卸载过程中:

    [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
    public override void Uninstall(IDictionary savedState)
    {
        base.Uninstall(savedState);
    }

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);
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文