我想向用戶顯示一個對話框,指出「這將隨此安裝而被刪除」,如果按下「是」或「確定」,則安裝可以繼續;否則,我想放棄它。WiX - 使用session.message函數的vbscript自定義動作
所以我定義了一個自定義操作(運行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
那種 「& H0B000034」 我用的是「 Session.Message「參數來自MSDN的示例,請參閱http://msdn.microsoft.com/en-us/library/windows/desktop/aa371672(v=vs.85).aspx。
始終腳本正在執行我在MSI日誌中出現以下錯誤:
Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action ShowUninstallInformationDlg script error -2147467259, Msi API Error: Message,Kind,Record Line 19, Column 1,
我已搜查谷歌大量使用Session.Message的例子,但沒有成功的結果...誰能幫助?謝謝!
你不需要vbscript來做你正在做的事情。您可以使用您的屬性作爲ControlEvents的條件來顯示MSI對話框。在VBScript中執行此操作只會增加對已知脆弱技術的依賴性,從而使安裝程序的可靠性降低。 – 2012-02-27 13:29:01
我已經試過了,但是我不能用對話框中斷UI鏈而不強迫它永遠退出!你有沒有工作的例子? – moik 2012-02-27 15:24:42