WiX CustomAction ExeCommand 失败? [英] WiX CustomAction ExeCommand failing?

查看:22
本文介绍了WiX CustomAction ExeCommand 失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在安装合并模块期间运行一个命令行(由 WiX 创建)a>) 使用以下代码.

I have a command line I want to run during the install of a merge module (created by WiX) with the below code.

<CustomAction
    Id='SetWebsiteProtocols'
    Execute='commit'
    Return='ignore'
    Impersonate="yes"
    FileKey='Web.config'
    ExeCommand='c:\windows\system32\inetsrv\appcmd.exe set app "Default Web Site/My Website" /enabledProtocols:http,net.tcp,net.pipe' />

<InstallExecuteSequence>
    <Custom Action="SetWebsiteProtocols" After="InstallFiles"/>
</InstallExecuteSequence>

当我在命令行(目前硬编码)上运行命令时,它工作正常.但是,在安装期间运行时,它会失败.打开日志记录显示错误代码 1721,但谷歌搜索没有返回任何感兴趣的内容.

When I run the command on the command line (hard coded at the moment) it works fine. However, when run during an install, it fails. Turning on logging shows the error code 1721, but googling that returns nothing of interest.

我该如何解决这个问题?

How do I fix this problem?

推荐答案

我发现你的代码有很多问题.

I see many issues with your code.

  1. 您已安排提交,如果策略禁用回滚,则不会处理该提交.

  1. You are scheduled for commit which will not be processed if rollback is disabled by policy.

您正在冒充 UAC,如果您的使用 MSI 不是由提升 UI/执行过程的 setup.exe 引导的.

You are impersonating the UAC which may fail in UAC/Elevated situations if your consuming MSI isn't bootstrapped by a setup.exe that is elevating the UI/Execute process.

您已硬编码了 system32 文件夹的路径,该文件夹可能不存在,因为 WINDOWS 不必称为 WINDOWS,或者可能是 32 位或 64 位系统文件夹取决于操作系统平台.

You have hardcoded a path to the system32 folder which either might not exist because WINDOWS doesn't have to be called WINDOWS or might be the 32-bit or 64-bit system folder depending on OS platform.

您忽略了返回码,因此如果失败,您的安装将继续进行.插入并祈祷任何人?

You are ignoring the return code so if this fails your install will keep going. Plug and pray anyone?

在安装过程中,你会看到一个巨大的、丑陋的、闪烁的黑色控制台窗口,它只会尖叫哦,这家伙不知道他在做什么."

You will have a big ugly flashing black console window during the install that just screams 'oh this guy didn't know what he was doing.'

您绝对不会退出 EXE.

You will get absolutely no logging out of the EXE.

您可能没有意识到直接调用 EXE 自定义操作可能会发生的问题.

You probably aren't aware of the problems that can occur directly calling an EXE custom action.

这里有一些阅读材料可以帮助您理解这些问题:

Here's some reading to help you understand these concerns:

EXE 自定义操作的集成障碍

现在我还要提到您可能正在重新发明轮子,但似乎 WiX 的内置 IIS 自定义操作不会暴露您需要的变化点.这是一种耻辱.因此,我建议您查看以下功能来修复您的 EXE 调用:

Now I would also mention that you are possibly reinventing the wheel, but it seems that WiX's built-in IIS custom actions don't expose the variation point you need. That's a shame. So I would suggest looking at the following feature to fix up your EXE call:

我发现这是一种非常优雅的调用 EXE 的方式,无需闪烁的 DOS 框,正确登录您的 MSI 日志并修复 Microsoft 的许多 EXE 问题.从那里您只需要修复它,以便正确解析正确的 32 位或 64 位 appcmd.我的安装程序只针对 Server 2008 R2,这是一个 64 位平台,所以我的代码如下所示:

I find this is a very elegant way of calling your EXE without a flashing DOS box, proper logging into your MSI log and a fix many of Microsoft's EXE concerns. From there you just need to fix it so you are properly resolving the correct 32-bit or 64-bit appcmd. My installers only target Server 2008 R2 which is a 64-bit only platform so my code looks like this:

(此代码增强了 InstallShield 未公开的内容...)

(This code augments something InstallShield doesn't expose... )

<CustomAction Id="SetIISAuthCAD"
              Property="SetIISAuth"
              Value="&quot;[System64Folder]inetsrv\appcmd.exe&quot; set config &quot;Default Web Site/MyApplication&quot; /section:system.webServer/security/authentication/windowsAuthentication /useAppPoolCredentials:true /commit:MACHINE/WEBROOT/APPHOST " />
<CustomAction Id="SetIISAuth"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec64"
              Execute="deferred"
              Return="ignore"
              Impersonate="no" />
<InstallExecuteSequence>
    <Custom Action="SetIISAuth"
            Before="InstallFinalize">Not Installed</Custom>
    <Custom Action="SetIISAuthCAD"
            Before="SetIISAuth">Not Installed</Custom>
</InstallExecuteSequence>

这篇关于WiX CustomAction ExeCommand 失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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