WIX启用Windows功能 [英] WIX enable Windows feature

查看:128
本文介绍了WIX启用Windows功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装我的软件之前,我必须检查是否启用了某些Windows功能.

I have to check if some windows features are enabled beore installing my software.

我可以检查它或使用dism命令行工具安装它.

I can check it or install it using dism command line tool.

我创建了一个自定义操作来执行此操作,但是有没有办法以"WIX本机方式"来执行此操作?

I create a custom action to do this, but is there a way to do it in a "WIX native way" ?

<Property Id="dism" Value="dism.exe" />
<CustomAction Id="InstallMSMQContainer" Property="dism" ExeCommand=" /online /enable-feature /featurename:MSMQ-Container /featurename:MSMQ-Server /featurename:MSMQ-ADIntegration" Return="check" Impersonate="yes"  Execute="oncePerProcess"/>

<InstallUISequence>
  <Custom Action="InstallMSMQContainer" After="CostFinalize" Overridable="yes">NOT Installed</Custom>
</InstallUISequence>

问题在于该命令会启动命令提示符,这对于最终用户而言非常难看. 如何使它变得更好?我不知道我是否需要引导程序来执行此操作(例如安装.NET Framework).

The problem is that command launch a command prompt, which is very ugly for end user. How can I make it nicer? I don't know if i need a bootstraper to do this (like installing the .NET Framework).

有什么办法可以管理这些东西吗?

Is there any extention to manage that things ?

我现在正在使用WIX 3.7.

I'm now using WIX 3.7.

推荐答案

David Gardiner的答案暗示了我的正确解决方案.无需创建自己的自定义操作.这是Windows 64位安装的方法:

David Gardiner's answer hinted at the correct solution in my case. Creating your own custom action is not necessary. Here is how to do it for a 64 bit installation of Windows:

首先确定是否已安装MSMQ:

First determine if MSMQ is installed:

<Property Id="MSMQINSTALLED">
  <RegistrySearch Id="MSMQVersion" Root="HKLM" Key="SOFTWARE\Microsoft\MSMQ\Parameters" Type="raw" Name="CurrentBuild" />
</Property>

声明您的自定义操作.你需要两个.一种将属性设置为dism的路径,另一种将其执行:

Declare your custom actions. You need two. One to set a property to the path to dism, and another to execute it:

<CustomAction Id="InstallMsmq_Set" Property="InstallMsmq" Value="&quot;[System64Folder]dism.exe&quot; /online /enable-feature /featurename:msmq-server /all" Execute="immediate"/>
<CustomAction Id="InstallMsmq" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check"/>

最后在安装顺序中指定自定义操作:

Finally specify the custom actions in the install sequence:

<InstallExecuteSequence>
  <Custom Action="InstallMsmq_Set" After="CostFinalize"/>
  <Custom Action="InstallMsmq" After="InstallInitialize">NOT REMOVE AND NOT MSMQINSTALLED</Custom> 
</InstallExecuteSequence>

因为这可能会花费一些时间,所以我添加了以下内容来更新安装程序状态文本:

Because this can take a little bit of time I've added the following to update the installer status text:

<UI> 
  <ProgressText Action="InstallMsmq">Installing MSMQ</ProgressText> 
</UI> 

如果要在安装失败时删除MSMQ,也可以指定回滚操作.

You can also specify a rollback action if you want to remove MSMQ on installation failure.

这篇关于WIX启用Windows功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆