WiX CustomAction ExeCommand失败了吗?

Jon*_*Jon 4 windows-installer wix wix3 wix3.5

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

<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>
Run Code Online (Sandbox Code Playgroud)

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

我该如何解决这个问题?

Chr*_*ter 10

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

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

  2. 您正在冒充UAC,如果您的消费MSI没有通过setup.exe提升UI /执行过程来引导,则可能在UAC /高架情况下失败.

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

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

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

  6. 你绝对不会退出EXE.

  7. 您可能不知道直接调用EXE自定义操作可能发生的问题.

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

现在我还要提到你可能正在重新发明轮子,但似乎WiX的内置IIS自定义动作不会暴露你需要的变化点.真是太遗憾了.因此,我建议您查看以下功能以修复您的EXE呼叫:

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

(此代码增加了InstallShield不公开的内容......)

<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>
Run Code Online (Sandbox Code Playgroud)