batch-file - WIX 在 InstallExecution 序列中调用批处理文件

标签 batch-file wix invoke

我是 WIX 的新手,我正在尝试从我的 WIX 安装程序中调用一个批处理文件。
MyBatch.bat 包含从 c:\到 D:\的文本文件的简单副本

我无法调用批处理文件。下面是我的代码。

请帮帮我。

  <?xml version="1.0" encoding="UTF-8"?>
  <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define ProductName='Test Product' ?>
  <?define ProductVersion='1.0.0.0' ?>
  <?define ProductCode='b7bc7c6f-9a4e-4973-be84-eca8e3427c97'?>
  <?define UpgradeCode='06a81104-1e30-463d-87e1-e8a79b4c682a'?>
  <?define Manufacturer='Respond'?>
  <Product Id="$(var.ProductCode)" Language="1033" Version='$(var.ProductVersion)' Name='Respond'
  Manufacturer='$(var.Manufacturer)' UpgradeCode='$(var.UpgradeCode)'>
    <Package InstallerVersion='200' Compressed='yes' />
    <Media Cabinet='media1.cab' EmbedCab='yes' Id ='1' />
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id='ProgramFilesFolder'>
        <Directory Id='INSTALLDIR' Name='$(var.ProductName)'>
          <Component Id='ProductComponent' Guid='b11556a2-e066-4393-af5c-9c9210187eb2'>
            <File Id='Calc' DiskId='1' Source='C:\WINDOWS\system32\calc.exe'/>
            <File Id='my_batch_script' Name='MyBatch.bat' DiskId='1' Source='MyBatch.bat'   />
          </Component>
        </Directory>
      </Directory>
      <Directory Id='ProgramMenuFolder'>
        <Directory Id='ApplicationProgramsFolder' Name='$(var.ProductName)'>
          <Component Id='MainExecutable' Guid='EDED00D8-2465-46CA-86D6-B20DE921EFA6'>
            <Shortcut Id='ShortcutCalc' Description='$(var.ProductName)' Name ='Calculator of Windows'
            Target='[INSTALLLOCATION]Calc.exe' WorkingDirectory='INSTALLLOCATION'/>
            <RemoveFolder Id='ApplicationProgramsFolder' On='uninstall'/>
            <RegistryValue Root='HKCU' Key='Software\$(var.Manufacturer)\$(var.ProductName)' Type ='multiString'
            Name='installed' Value='1' KeyPath='yes'/>
          </Component>
        </Directory>
      </Directory>
    </Directory>

    <Feature Title='SetupProject1' Level='1' Id ='AppFeature'>
      <ComponentRef Id='ProductComponent' Primary='yes'/>
      <ComponentRef Id='MainExecutable'/>
    </Feature>

    <Property Id='WIXUI_INSTALLDIR' Value='INSTALLDIR' ></Property>
    <WixVariable Id='WixUILicenseRtf' Overridable='yes' Value='License.rtf'/>
    <?include CustomActions.wxi?>
    <UI>
      <?include UISequence.wxi?>
      <?include Dialogs.wxi?>
    </UI>

    <CustomAction Id="BatchCmd" Property="ThePath" Value="[INSTALLDIR]MyBatch.bat" />
    <CustomAction Id="BatchRun" Property="ThePath" ExeCommand='"[INSTALLDIR]MyBatch.bat"' Return='asyncWait' Impersonate="yes"/>

    <InstallExecuteSequence>
      <Custom Action="BatchCmd" After="InstallFiles" >Not Installed </Custom>
      <Custom Action="BatchRun" After="BatchCmd">Not Installed </Custom>
    </InstallExecuteSequence>
  </Product>

</Wix>

最佳答案

这对我有用。

<CustomAction Id="test"
    ExeCommand="[INSTALLDIR]MyBatch.bat"
    Directory="INSTALLDIR" Execute="deferred" Return="asyncWait"/>

<InstallExecuteSequence>
    <Custom Action="test" After="InstallFiles">NOT Installed</Custom>
</InstallExecuteSequence>

关于batch-file - WIX 在 InstallExecution 序列中调用批处理文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9563820/

相关文章:

javascript - 从 Javascript/XPCOM 调用的批处理文件不显示命令提示符窗口

batch-file - 批量双延迟扩展?

installation - WIX 安装程序 : Adding POS as a prerequisite

wix - Pyro 和文件排序

bash - 通过cli测试AWS lambda函数

c# - 查找并调用通用重载方法

string - Windows 批处理文件 - 需要从参数中删除换行符

powershell - 在 Windows powershell 中将日期添加到重定向文件名

wix - Bootstrap 应用程序回滚

c# - 反射和 WCF