我希望WIX Installer悄悄地调用NETSH命令将自签名证书绑定到IP地址:端口。

正在调用CAQuietExec,但是NETSH命令失败。

MSI (s) (C4:84) [16:19:50:455]: Executing op: CustomActionSchedule(Action=customQtExecRtBindCertToPort,ActionType=3137,Source=BinaryData,Target=CAQuietExec,CustomActionData="netsh" http add sslcert ipport=0.0.0.0:8080 certhash=2B2C23C6B1334F886B9FFD827D64BDC072BBEFD7 appid={123456-7890-12345-4567-AAABBBCCCDDDFFFF})
MSI (s) (C4:8C) [16:19:50:457]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI87DB.tmp, Entrypoint: CAQuietExec
MSI (s) (C4:78) [16:19:50:457]: Generating random cookie.
MSI (s) (C4:78) [16:19:50:458]: Created Custom Action Server with PID 2588 (0xA1C).
MSI (s) (C4:38) [16:19:50:477]: Running as a service.
MSI (s) (C4:38) [16:19:50:479]: Hello, I'm your 32bit Elevated custom action server.
CAQuietExec:
CAQuietExec:  SSL Certificate add failed, Error: 1312
CAQuietExec:  A specified logon session does not exist. It may already have been terminated.



  指定的登录会话不存在。它可能已经被终止。


当我从命令外壳运行完全相同的命令时,我成功了:

>SSL Certificate successfully added


我的代码很简单:

    <CustomAction
        Id="customQtExecRtBindCertToPortData"
        Property="customQtExecRtBindCertToPort"
        Value="&quot;netsh&quot; http add sslcert ipport=0.0.0.0:[RT_PORT] certhash=[CERT_THUMBPRINT] appid={123456-7890-12345-4567-AAABBBCCCDDDFFFF}"
        />
    <CustomAction
        Id="customQtExecRtBindCertToPort"
        BinaryKey="WixCA"
        DllEntry="CAQuietExec"
        Execute="deferred"
        Return="ignore"
        Impersonate="no"
        />


我曾尝试在Windows Server 2008 R2中以提升的特权运行,但仍收到相同的日志输出。

最佳答案

为了尝试修改安装程序以调用自定义控制台应用程序,该应用程序在后台调用NETSH(以及其他一些任务),我得出了我认为是实际问题的信息。

尽管我的CustomAction声明具有Execute =“ deferred”和Impersonate =“ no”属性的设置正确,但我认为当时未正确定义安装顺序,以在InstallInitialize和InstallFinalize之间发生,如此链接所述:Installation change do not ask for UAC permissions

使用UAC和所有有趣的东西部署到W2K12时,会导致相同的错误,然后将自定义操作安装程序序列设置为以下顺序,就可以解决所定义的问题。

        <Custom
            Action="customQtExecRTBindCertToPortData"
            Before="InstallFinalize"
            >
            <![CDATA[NOT Installed AND CERTIFICATE_NEEDED = "TRUE" AND &featureServices = 3 ]]>
        </Custom>
        <Custom
            Action="customQtExecRTBindCertToPort"
            After="customQtExecRTBindCertToPortData"
            >
            <![CDATA[NOT Installed AND CERTIFICATE_NEEDED = "TRUE" AND &featureServices = 3 ]]>
        </Custom>

关于c# - WIX CAQuietExec NETSH命令失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18218672/

10-15 02:47
查看更多