Wix 刻录不允许删除文件 [英] Wix burn doesn't allow to remove file

查看:31
本文介绍了Wix 刻录不允许删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个引导程序,我想删除在安装过程中创建的链接.所以我写了以下步骤:

I'm creating a bootsrapper and I want to remove links that are created during installation. So I write following step:

<Chain>
  ...
  <ExePackage Id="removelnk" Cache="no" SourceFile="run.bat" InstallCommand="del &quot;C:UsersPublicDesktopParity UI.lnk&quot;" />
</Chain>

其中 run.bat 只是 %* 允许运行任意代码,如 此处.

Where run.bat is simply %* which allows to run arbitrary code as described here.

然而,它不起作用:

[19EC:0E2C][2018-06-16T18:32:27]i301: Applying execute package: removelnk, action: Install, path: C:ProgramDataPackage Cache1608BB75347CD8C40187E5F3C0A969ED73A98D51
un.bat, arguments: '"C:ProgramDataPackage Cache1608BB75347CD8C40187E5F3C0A969ED73A98D51
un.bat" del "C:UsersPublicDesktopParity UI.lnk"'
[19EC:0E2C][2018-06-16T18:32:27]e000: Error 0x80070001: Process returned error: 0x1
[19EC:0E2C][2018-06-16T18:32:27]e000: Error 0x80070001: Failed to execute EXE package.
[0AE4:2B94][2018-06-16T18:32:27]e000: Error 0x80070001: Failed to configure per-machine EXE package.
[0AE4:2B94][2018-06-16T18:32:27]i319: Applied execute package: removelnk, result: 0x80070001, restart: None
[0AE4:2B94][2018-06-16T18:32:27]e000: Error 0x80070001: Failed to execute EXE package.

如果我从 cmd 的日志中执行此命令,那么它会按预期工作.它甚至可以在没有管理员权限的情况下工作.

If I execute this command from log in my cmd then it works as expected. It even works without admin privileges.

这里出了什么问题?

推荐答案

创建转换:您可以使用 转换 以修改任何 MSI 文件 -转换的一个非常常见的用途是删除此类快捷方式.您应该能够在引导程序中指定的命令行上应用该转换 - 尽管我从未尝试过使用 WiX 引导程序.

Creating a Transform: You can use a transform to modify any MSI file - a very common use for a transform is to remove such shortcuts. You should be able to apply that transform on the command line specified in your bootstrapper - though I have never tried this with WiX bootstrappers.

转换是应用于原始 MSI 的小数据库片段".它会更改内存中的 MSI 文件,您几乎可以随心所欲地更改.您可以使用 Orca 或等效的免费工具.当然也可以使用商业工具——例如高级安装程序.事实上,他们有一个很好的小视频展示了这个过程(朝向底部).

Transforms are "little database fragments" that are applied to the original MSI. It changes the MSI file in memory and you can pretty much change whatever you want. You can create transforms with Orca or an equivalent free tool. Commercial tools - such as Advanced Installer - can also be used of course. In fact they have a nice little video showing the process (towards the bottom).

这里有很长的转换解释(除其他外):如何更好地利用 MSI 文件.

There is a long explanation of transforms (among other things) here: How to make better use of MSI files.

应用转换:您可以通过 在安装过程中转换属性.

快速示例命令行:

msiexec.exe /I "My.msi" /QN /L*V "C:My.log" TRANSFORMS="C:1031.mst;C:My.mst"

参数快速说明:

/I = run installation sequence
/QN = run completely silently
/L*V "C:My.log"= verbose logging
TRANSFORMS="C:1031.mst;C:My.mst" = Apply transforms 1031.mst and My.mst.

<小时>

Burn Bundle 详细信息:我还没有尝试在 Burn 包中应用转换(所以我应该感觉不回答),但是 MsiPackage 元素 我相信是你所需要的.我发现了这个相当复杂的示例MsiProperty 子元素MsiPackage 元素.


Burn Bundle Details: I have not tried applying a transform in a Burn bundle (so I should have the sense not to answer), but the MsiPackage element is what you need I believe. I found this rather complicated sample of a Burn bundle source file - perhaps it is worth a look? It seems the magic is in the MsiProperty child element for the MsiPackage element.

更新:

Burn Hello-World 样式示例:终于可以在 Windows 计算机(在 Linux 计算机上)上运行一个快速测试.以下是通过 Burn 应用变换的方法(最小示例,仅用于展示基础知识,而不是假装是好的标记).

Burn Hello-World Style Example: Finally got to run a quick test on a Windows computer (was on a Linux one). Here is how you can apply a transform via Burn (minimal sample, just intended to show the basics, not pretending to be good markup).

只是内联警告:我听到一些谣言说以这种方式进行的转换可能不适用于所有情况 - 例如修理.请彻底测试.它适用于我的测试.还要测试升级方案(例如重大升级).

Just inlining the warning: I hear some rumors that the application of the transform in this way might not work in all cases - such as repair. Please test thoroughly. It worked for my test. Also test upgrade scenarios (major upgrade for example).

这会将转换 ShortcutDesktop.mst 应用到原始 MSI ShortcutDesktop.msi:

This will apply the transform ShortcutDesktop.mst to the original MSI ShortcutDesktop.msi:

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

    <!-- Maybe generate yourself an Upgrade-GUID here: https://www.guidgenerator.com/ -->

    <Bundle Name="MyCoolTestApp" Version="1.0.0.0" Manufacturer="Someone"
            UpgradeCode="PUT-GUID-HERE">        

    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />

        <Chain>
            <MsiPackage SourceFile="ShortcutDesktop.msi">
                <MsiProperty Name="TRANSFORMS" Value="ShortcutDesktop.mst" />
            </MsiPackage>
        </Chain>

    </Bundle>

</Wix>

要构建上面的 Burn 包 BurnTest.wxs:

To build the Burn bundle BurnTest.wxs above:

set SetupName=BurnTest

candle.exe %SetupName%.wxs -ext WixBalExtension >> %SetupName%.log
light.exe %SetupName%.wixobj -ext WixBalExtension >> %SetupName%.log

以及指向 github 上更好的 Burn 示例的链接:

And a link to a better Burn example on github:

这篇关于Wix 刻录不允许删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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