0

我有一个运行 CustomAction 的安装程序,它运行嵌入式 powershell 脚本来测试各种所需 Windows 功能的安装状态。这可以正常工作,但完成起来非常慢。

是否有替代方法来测试这些功能?我希望每个功能和子功能的注册表项都有一些内容,但我还没有找到关于该主题的任何文档。

4

2 回答 2

4

在其中一个安装项目中,我们使用dism.exe来启用所需的 Windows 功能。

例如,在 IIS 8 中启用 ASP.NET 是通过以下自定义操作完成的:

<!-- 32-bit edition of Windows knows where to find dism.exe -->
<Property Id="DISMEXEPATH" Value="dism.exe" />

<!-- 64-bit edition of Windows requires this workaround to get proper dism.exe version -->
<SetProperty Id="DISMEXEPATH" Value="[WindowsFolder]Sysnative\dism.exe" After="AppSearch">VersionNT64</SetProperty>

<!-- And the CA to do the job (with the help of [quiet execution CA][2]) -->
<CustomAction Id="SetForEnableAspNetIIS8" Property="EnableAspNetIIS8" Value="&quot;[DISMEXEPATH]&quot; /norestart /quiet /online /enable-feature /featurename:IIS-ApplicationDevelopment /featurename:IIS-ASPNET45 /featurename:IIS-NetFxExtensibility45 /featurename:NetFx4Extended-ASPNET45 /featurename:IIS-ISAPIExtensions /featurename:IIS-ISAPIFilter" />
<CustomAction Id="EnableAspNetIIS8" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check"/>

这似乎不是一个好的做法,但它适用于该项目。

于 2013-09-25T06:24:38.457 回答
2

我最终使用(现已删除)建议使用托管 DTF 自定义操作来查询 C# 中的服务器功能。

[CustomAction]
public static ActionResult CheckFeatures(Session session)
{
    SelectQuery q = new SelectQuery("Win32_ServerFeature");
    ManagementObjectSearcher s = new ManagementObjectSearcher(q);
    foreach (ManagementObject e in s.Get())
    {
        if((UInt32)e["ID"] == FeatureId)
        {
            session["FeatureIsSet"] = "1";
        }
    }
}

<CustomAction Id="CACheck" BinaryKey="CA" DllEntry="CheckFeatures" 
Execute="immediate" Return="check" />
<Binary Id="CA" SourceFile="path/to/bin" />
于 2013-09-27T00:32:29.013 回答