【问题标题】:Running a VBscript from MSI package从 MSI 包运行 VBscript
【发布时间】:2015-06-24 10:02:09
【问题描述】:

我在使用 WIX 制作的 .MSI 包中执行 VBscript 时遇到了一点问题。尝试构建项目时会引发 2 个错误:

未找到 CustomAction 元素的 DllEntry、Error、ExeCommand、JScriptCall、Script、Value 或 VBScriptCall 属性;其中之一是必需的。

CustomAction 元素包含非法的内部文本:'Directory="INSTALLFOLDER"

我不完全理解它为什么会抛出这些错误。

我确实给了它INSTALLFOLDER 作为目录,因为这是 VBscript 所在的位置,第二个错误我不知道,因为我不完全了解如何格式化 ExeCommand

这是我使用的代码:

<Feature Id="ProductFeature" Title="wix_script_execution" Level="1">
          <ComponentGroupRef Id="script"/>
            </Feature>
        </Product>

        <Fragment>
            <Directory Id="TARGETDIR" Name="SourceDir">
                <Directory Id="ProgramFilesFolder">
                    <Directory Id="INSTALLFOLDER" Name="wix_script_execution" />
                </Directory>
            </Directory>
        </Fragment>

      <Fragment>
        <ComponentGroup Id="script" Directory="INSTALLFOLDER">
          <Component Id="InstallationScript" Guid="{AFA49EED-4F2C-42B4-B7EC-D3B7896C970C}">
            <File Id="InstallationScript" KeyPath="yes" Source="C:\Users\fjansen\Documents\Visual Studio 2013\Projects\Wix test\Installation script\obj\Debug\Installation script.exe" />
          </Component>
        </ComponentGroup>
      </Fragment>

      <Fragment>
      <CustomAction Id="RunInstallScript">
        Directory="INSTALLFOLDER"
        ExeCommand="[INSTALLFOLDER]Installation script.exe"
        Execute="commit"
        Return="ignore"/>
      </CustomAction>
      <InstallExecuteSequence>
        <Custom Action="RunInstallScript" Before="InstallFinalize" />
      </InstallExecuteSequence>
      </Fragment>

其中包含自定义操作的片段是从互联网上复制并由我修改的,但显然方式不正确。

最终目标是在所有文件复制到目标位置后,此 VBscript 会自动运行。

VBscript只需执行一次,无需安装。

2015 年 7 月 7 日添加:

我终于能够测试建议的信息。但是它仍然没有执行文件,编译项目时我没有收到任何错误,因此我不清楚原因是什么。

这是我与其中包含的建议一起使用的代码:

     <Fragment>
    <CustomAction Id="RunInstallScript"
      Directory="INSTALLFOLDER"
      ExeCommand="[INSTALLFOLDER]Installation script.exe"
      Execute="commit"
      Return="ignore"
    />
  <InstallExecuteSequence>
    <Custom Action="RunInstallScript" Before="InstallFinalize" />
  </InstallExecuteSequence>
  </Fragment>

我认为问题与 ExeCommand 有关,因为它只是不执行脚本。芽我就是不能让它工作,我错过了什么?

提前致谢。

【问题讨论】:

    标签: xml vbscript wix


    【解决方案1】:
    <CustomAction Id="RunInstallScript">
        Directory="INSTALLFOLDER"
        ExeCommand="[INSTALLFOLDER]Installation script.exe"
        Execute="commit"
        Return="ignore"/>
      </CustomAction>
    

    Id="RunInstallScript" 之后有一个额外的&gt;,所以你的属性(例如Directory=)变成了内部文本。如果您删除该字符,这些错误将消失。还有一个额外的结束标签——它应该是/&gt;&gt;&lt;/CustomAction&gt;。最后,该自定义操作应如下所示:

    <CustomAction Id="RunInstallScript"
      Directory="INSTALLFOLDER"
      ExeCommand="[INSTALLFOLDER]Installation script.exe"
      Execute="commit"
      Return="ignore"/>
    

    【讨论】:

    • 还有额外的结束标签 "/> "
    • @Isaiah4110:是的,我也错过了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多