在安装过程中,有没有办法检查系统中是否启用了IIS的功能?
例如,为了检查.NET框架的版本并应用某些条件,我们可以使用以下示例:
<PropertyRef Id="NETFRAMEWORK20"/>
<Condition Message="This application requires .NET Framework 2.0. Please
install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK20]]>
</Condition>
但有没有可能检查启用IIS的功能?
提前谢谢!
答案 0 :(得分:0)
此注册表项列出已安装的组件
HKLM\SOFTWARE\Microsoft\InetStp\Components
如果某个组件尚未安装,则该组件不会显示在该列表中
因此,如果您想要在未启用HTTP重定向功能的情况下阻止安装,则可以执行以下操作:
<Property Id="REDIRECT">
<RegistrySearch Id="redirects" Root="HKLM" Key="SOFTWARE\Microsoft\InetStp\Components" Name="HttpRedirect" Type="raw" />
</Property>
<Condition Message='HTTP Redirection is not configured in IIS. Please install HTTP Redirection in IIS first, and then $(var.ProductName).'><![CDATA[Installed OR REDIRECT]]></Condition>
然而,更客户友好的方法可能是在安装过程中启用所需的功能。 您可以通过调用DISM实用程序在安装程序中执行此操作:
<CustomAction Id='AddIISComponent' Property='IISComponent' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /featurename:IIS-HttpRedirect /all' Execute='immediate'/>
<CustomAction Id="IISComponent" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="ignore" Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="AddIISComponent" After="CostFinalize" />
<Custom Action="IISComponent" After="InstallInitialize"><![CDATA[(NOT Installed)]]></Custom>
</InstallExecuteSequence>
请注意/ featurename:命令行中的IIS-HttpRedirect
您可以通过运行
获取可能的功能名称列表dism /online /Get-Features