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

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

问题描述

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

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:\Users\Public\Desktop\Parity 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:\ProgramData\Package Cache\1608BB75347CD8C40187E5F3C0A969ED73A98D51\run.bat, arguments: '"C:\ProgramData\Package Cache\1608BB75347CD8C40187E5F3C0A969ED73A98D51\run.bat" del "C:\Users\Public\Desktop\Parity 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.

这是怎么了?

推荐答案

创建转换 :您可以使用

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或同等的免费工具.当然也可以使用商业工具,例如Advanced Installer.实际上,他们有一个展示过程的漂亮视频(底部).

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).

这里有很多关于转换的解释():

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捆绑包中应用转换(因此我应该不回答),但是 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.

更新:

烧录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 Burn不允许删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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