Wix 中满足条件时显示警告对话框
在我的 Wix 安装程序中,我正在搜索 Adobe acrobat reader 的注册表项,并显示带有“是”和“否”选项的警告对话框。此对话框应该在安装过程中在 WelcomeDlg 之后立即显示,以便用户在未安装 Adobe reader 的情况下“继续”或“退出”安装。
我在代码中发现一个问题,因为“AdobePrecessionDlg”不支持“ADOBEREADERINSTALLED”属性,即使注册表项存在,该对话框也会显示。
仅当不满足属性“ADOBEREADERINSTALLED”(即注册表项不存在)时,才应显示警告对话框“AdobePrecessionDlg”, 但到目前为止,这种情况还没有发生,因为我每次都能看到对话框显示。
我尝试了很多改变,但无法找出问题所在。这是我的代码:
Product.wxs
<Property Id="ADOBEREADERINSTALLED">
<RegistrySearch Id="ADOBEREADERINSTALLED_REGSEARCH" Key="Software\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe" Root="HKLM" Type="raw"/>
</Property>
<UIRef Id="PrerequisiteDialogUI" />
<UI Id="UserInterface">
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="FatalError" />
<DialogRef Id="UserExit" />
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="AdobePrerequisiteDlg">1</Publish>
</UI>
Components.wxs
<Fragment>
<UI Id="PrerequisiteDialogUI">
<Dialog Id="AdobePrerequisiteDlg" Width="370" Height="270" Title="Software Requirements Incomplete">
<Control Id="YES" Type="PushButton" X="180" Y="243" Width="56" Height="17" Default="yes" Cancel="yes" Text="YES">
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
<Control Id="NO" Type="PushButton" Text="NO" X="236" Y="243" Width="56" Height="17" Cancel="yes" >
<Publish Event="EndDialog" Value="Exit" />
</Control>
<Control Id="Text" Type="Text" X="1" Y="50" Width="340" Height="120" TabSkip="no">
<Text>
The following software requirements have not been met :
Adobe Acrobat Reader
Do you wish to continue ?
</Text>
</Control>
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Prerequisite for $(var.ProductName) is not installed." />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="Adobe Reader 9.0" />
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
</Dialog>
</UI>
<InstallUISequence>
<Show Dialog="AdobePrerequisiteDlg" Before="ExecuteAction"> <![CDATA[NOT Installed AND ADOBEREADERINSTALLED]]></Show>
</InstallUISequence>
<Fragment>
In my Wix Installer, I am searching for registry key for Adobe acrobat reader and displaying a warning dialog with "YES" and "NO" option. This dialog is supposed to display during the install sequence immediately after WelcomeDlg enabling user to "continue" or "exit" the installation if Adobe reader is not installed.
I am finding an issue in my code as the "AdobePrerequisiteDlg" does not honors the "ADOBEREADERINSTALLED" property, The dialog is getting displayed even when registry key exist.
The warning dialog "AdobePrerequisiteDlg" should only be displayed when Property "ADOBEREADERINSTALLED" is not satisfied (i.e. registry key does not exist),
But as of now that is not happening as I am able to see the dialog getting displayed everytime.
I tried many changes but not able to figure out where the problem exist. Here is my code :
Product.wxs
<Property Id="ADOBEREADERINSTALLED">
<RegistrySearch Id="ADOBEREADERINSTALLED_REGSEARCH" Key="Software\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe" Root="HKLM" Type="raw"/>
</Property>
<UIRef Id="PrerequisiteDialogUI" />
<UI Id="UserInterface">
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="FatalError" />
<DialogRef Id="UserExit" />
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="AdobePrerequisiteDlg">1</Publish>
</UI>
Components.wxs
<Fragment>
<UI Id="PrerequisiteDialogUI">
<Dialog Id="AdobePrerequisiteDlg" Width="370" Height="270" Title="Software Requirements Incomplete">
<Control Id="YES" Type="PushButton" X="180" Y="243" Width="56" Height="17" Default="yes" Cancel="yes" Text="YES">
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
<Control Id="NO" Type="PushButton" Text="NO" X="236" Y="243" Width="56" Height="17" Cancel="yes" >
<Publish Event="EndDialog" Value="Exit" />
</Control>
<Control Id="Text" Type="Text" X="1" Y="50" Width="340" Height="120" TabSkip="no">
<Text>
The following software requirements have not been met :
Adobe Acrobat Reader
Do you wish to continue ?
</Text>
</Control>
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Prerequisite for $(var.ProductName) is not installed." />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="Adobe Reader 9.0" />
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
</Dialog>
</UI>
<InstallUISequence>
<Show Dialog="AdobePrerequisiteDlg" Before="ExecuteAction"> <![CDATA[NOT Installed AND ADOBEREADERINSTALLED]]></Show>
</InstallUISequence>
<Fragment>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要括号或双 NOT 来表示条件:
NOT (Installed AND ADOBEREADERINSTALLED)
ORNOT Installed AND NOT ADOBEREADERINSTALLED
然后。当您启动安装程序时,您是否看到WelcomeDialog?或者 AdobePrecessionDlg 首先?如果是第二种变体,您需要对代码进行一些更改。试试这个:
产品.wxs
组件.wxs
First of all, you need brackets or double NOT for the condition:
NOT (Installed AND ADOBEREADERINSTALLED)
ORNOT Installed AND NOT ADOBEREADERINSTALLED
And then. Do you see WelcomeDialog when you start your installer? Or AdobePrerequisiteDlg goes first? If second variant, you need to make some changes in your code. Try this:
Product.wxs
Components.wxs