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

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

问题描述

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

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.

这里有什么问题?

推荐答案

创建转换:您可以使用 transform 修改任何 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 或等效的免费工具.当然,也可以使用商业工具(例如 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).

这里对转换(除其他外)有很长的解释:如何更好地利用 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 元素 是您所需要的.我发现了这个相当复杂的示例 的 Burn 捆绑源文件 - 也许值得一看?似乎魔力在于 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:

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

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