Wix Toolset MSI不会从PowerShell脚本安装其他安装程序

时间:2020-06-16 01:18:37

标签: wix windows-installer wix3.5 wix3

我正在使用wix工具集创建MSI安装程序。

我的MSI将在自定义操作中运行Powershell脚本。 然后,powershell脚本(MYSCRIPT.ps1)将执行依赖项的安装程序。让我们将此依赖命名为D。

当我运行Powershell脚本时,D会完美地安装在系统中。

但是

当我运行从wix创建的MSI时,powershell脚本会运行,但无法安装D。 为什么会这样。

我怀疑Windows不允许多个安装程序(从wix生成的MSI和从powershell脚本执行的D的安装程序)同时运行。

如何避免这种情况。

下面是我的product.wxs文件的一部分

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

    <?define Manufacturer="DWJIDWJDJ"?>

    <Product Id="*" Name="JDCA" Language="1033" Version="0.0.0.0" Manufacturer="$(var.Manufacturer)" UpgradeCode="dad416b3-034d-49eb-9407-0b681e5108c3">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes" />

        <Property Id="ARPNOREPAIR" Value="yes" Secure="yes" />
        <Property Id="ARPNOMODIFY" Value="yes" Secure="yes" />

        <Feature Id="ProductFeature" Title="WDJNIDJDJW" Level="1">
            <ComponentGroupRef Id="InstallScriptsGroup" />
            <ComponentGroupRef Id="ResourcesGroup" />
        </Feature>

        <CustomAction Id="ComponentsInstallAction" Property="WixShellExecTarget" Directory="INSTALLFOLDER" ExeCommand ='"$(env.SystemRoot)\system32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NonInteractive -NoProfile -Command ./MYSCRIPT.ps1' Execute="deferred" Impersonate="no" Return="check" />

        <InstallExecuteSequence>
            <Custom Before="InstallFinalize" Action="ComponentsInstallAction">Not Installed or REINSTALL</Custom>
        </InstallExecuteSequence>

    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="CommonAppDataFolder">
                <Directory Id="IhmDir" Name="IHM">
                    <Directory Id="INSTALLFOLDER" Name="IhmZebraComponents" />
                </Directory>
            </Directory>
        </Directory>

        <ComponentGroup  Id="InstallScriptsGroup"  Directory="INSTALLFOLDER">
            <Component Id="ComponentsInstallerScript" Guid="72cef904-4426-470d-a2d0-9545d0127f0a">
                <File Id="ComponentsInstallerSscript" Source="MYSCRIPT.ps1" KeyPath="yes" Checksum="yes"/>
            </Component>
        </ComponentGroup>

        <ComponentGroup  Id="ResourcesGroup"  Directory="INSTALLFOLDER">

CONTINUED

安装D的powershell脚本中的代码为

$Argument = "-S -f1`"$InstallResponseFile`""

$InstallProcess = Start-Process -Wait -FilePath $SetupFile -Argument $Argument -PassThru

LogWrite("| INFO | Completed execution of $SetupFile")

在此先感谢您的帮助

2 个答案:

答案 0 :(得分:0)

如果我们以异步模式运行自定义操作,则只能从wix工具集中的自定义操作安装其他安装程序。

因此更改行是可行的。

<CustomAction Id="ComponentsInstallAction" Property="WixShellExecTarget" Directory="INSTALLFOLDER" ExeCommand ='"$(env.SystemRoot)\system32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NonInteractive -NoProfile -Command ./MYSCRIPT.ps1' Execute="deferred" Impersonate="no" Return="check" />

<CustomAction Id="ComponentsInstallAction" Property="WixShellExecTarget" Directory="INSTALLFOLDER" ExeCommand ='"$(env.SystemRoot)\system32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -NonInteractive -NoProfile -Command ./MYSCRIPT.ps1' Execute="immediate" Impersonate="no" Return="asyncNoWait" />

答案 1 :(得分:0)

我认为在这一点上,您应该重新评估如何安装从属应用程序。为避免此类头痛,您是否考虑过使用WiX Bootstrapper?

WiX Bootstrapper允许您嵌入/下载并安装依赖的应用程序,以及处理升级等。