【发布时间】:2012-02-24 11:19:09
【问题描述】:
我想向用户显示一个对话框,上面写着“此安装将被删除”,如果按下“是”或“确定”,则可以继续安装;否则,我想中止它。
因此我定义了一个自定义操作(运行 vbscript),如下所示:
<CustomAction Id="ShowUninstallInformationDlg" Impersonate="yes" Return="check" Execute="immediate" BinaryKey="ShowUninstallInformationDlg.vb" VBScriptCall=""/>
<Binary Id="ShowUninstallInformationDlg.vb" SourceFile="c:\myscripts\installer\ShowUninstallInformationDlg.vbs"/>
<InstallExecuteSequence>
<Custom Action="ShowUninstallInformationDlg" After="FindRelatedProducts">NOT Installed AND NOT PATCH AND NOT MYPRODUCT_ANYVERSION=""</Custom>
</InstallExecuteSequence>
VBSCRIPT (ShowUninstallInformationDlg.vbs):
'ShowUninstallInformationDlg
Option Explicit
Dim text
Dim productName
Dim rec
productName = Session.Property("ProductName")
text = "The following installations are going to be removed with the installation of " & productName & ":"
If Session.Property("MYPRODUCT_ANYVERSION") <> "" Then
text = text & "\n * MyOtherProduct (any version)"
End If
Set rec = Session.Installer.CreateRecord(1)
rec.StringData(0) = text
Session.Message &H0B000034, rec
我用作“Session.Message”参数的那种“&H0B000034”来自 MSDN 的一个示例,请参阅http://msdn.microsoft.com/en-us/library/windows/desktop/aa371672(v=vs.85).aspx。
总是在执行脚本我在我的 MSI 日志中收到以下错误:
错误 1720。此 Windows 安装程序包有问题。无法运行完成此安装所需的脚本。请联系您的支持人员或软件包供应商。自定义操作 ShowUninstallInformationDlg 脚本错误 -2147467259,Msi API 错误:消息,种类,记录第 19 行,第 1 列,
我已经在谷歌上大量搜索了使用 Session.Message 的示例,但没有成功的结果......有人可以帮忙吗?谢谢!
【问题讨论】:
标签: vbscript wix custom-action