自定义 VS 2008 安装项目卸载程序

发布于 2024-08-17 21:14:18 字数 179 浏览 5 评论 0原文

我有一个 .NET 应用程序的安装项目,如果安装/卸载在工作时不受影响,则安装/卸载都可以正常工作。

但是,如果有人在处理过程中取消卸载,则回滚似乎无法正确处理,并且在稍后尝试再次卸载时,用户会收到空引用异常。

我想简化一下情况;我想删除用户取消正在进行的卸载的能力。这可以做到吗?

谢谢, -本

I have a setup project for my .NET application, and both install/uninstall are working just fine, if they are left alone while they work.

However, if someone cancels the uninstall while it is processing, the rollback doesn't seem to be handled correctly, and upon trying to uninstall again at a later time, the user is greeted with a null reference exception.

I would like to just simplify the situation; I would like to remove the user's ability to cancel an uninstall in progress. Can this be done?

Thanks,
-Ben

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

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

发布评论

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

评论(1

一页 2024-08-24 21:14:18

是的,可以这样做。 MSDN 列出了几个选项;但是,仅修补 Visual Studio 创建的 MSI 文件可能会更简单。这可以使用 Orca 来完成(您可以在 Windows SDK 文件夹中找到此工具的安装程序,通常位于 C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\orca.msi 下)。

Orca 允许您编辑 MSI 数据库表。要隐藏取消按钮,您必须向 ControlCondition 表添加一条记录(来自 此处):

Dialog        | Control      | Action   | Condition
------------------------------------------------------
ProgressForm  | CancelButton | Hide     | 1

使用 Orca 添加记录的手动任务可能最好使用简短的 VBScript 来完成,如下所示:

Set oMsi = CreateObject("WindowsInstaller.Installer")

' get path to msi from command line
strMsiFullPath = Wscript.Arguments(0)
' open transacted
Set oDB = oMsi.OpenDatabase(strMsiFullPath , 1)

' insert a record into the [ControlCondition][3] table
Set oView = oDB.OpenView("INSERT INTO `ControlCondition` " & _
    "(`ControlCondition`.`Dialog_`, `ControlCondition`.`Control_`," & _
     "`ControlCondition`.`Action`, `ControlCondition`.`Condition`) " & _
     "VALUES ('ProgressForm', 'CancelButton', 'Hide', '1')")

' clean up
oView.Execute: oView.Close: oDB.Commit
Set oMsi = Nothing

此脚本可以作为构建后步骤添加到您的安装项目(请注意,输出路径的 Visual Studio 变量中有一个拼写错误):

cscript $(ProjectDir)patch.vbs $(BuiltOuputPath)

Yes, it is possible to do so. MSDN lists several options; however, it might be simpler to just patch the MSI file created by Visual Studio. This can be done using Orca (You will find an installer for this tool in the Windows SDK folder typically under C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\orca.msi).

Orca allows you to edit the MSI database tables. To hide the cancel button you would have to add a record to the ControlCondition table (from here):

Dialog        | Control      | Action   | Condition
------------------------------------------------------
ProgressForm  | CancelButton | Hide     | 1

This manual task of adding a record using Orca is probably better done with a short VBScript like that:

Set oMsi = CreateObject("WindowsInstaller.Installer")

' get path to msi from command line
strMsiFullPath = Wscript.Arguments(0)
' open transacted
Set oDB = oMsi.OpenDatabase(strMsiFullPath , 1)

' insert a record into the [ControlCondition][3] table
Set oView = oDB.OpenView("INSERT INTO `ControlCondition` " & _
    "(`ControlCondition`.`Dialog_`, `ControlCondition`.`Control_`," & _
     "`ControlCondition`.`Action`, `ControlCondition`.`Condition`) " & _
     "VALUES ('ProgressForm', 'CancelButton', 'Hide', '1')")

' clean up
oView.Execute: oView.Close: oDB.Commit
Set oMsi = Nothing

This script can be added as a post-build step to your setup project (Note that there is a typo in the Visual Studio variable for the output path):

cscript $(ProjectDir)patch.vbs $(BuiltOuputPath)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文