【问题标题】:Copy command is not working using Wix Custom Action使用 Wix 自定义操作时复制命令不起作用
【发布时间】:2014-04-11 08:19:10
【问题描述】:

我有以下CustomAction

<CustomAction Id="CopyToSystem32" ExeCommand="copy /y 64bits.txt C:\Windows\System32" Directory="INSTALLFOLDER" Impersonate="no" Execute="deferred" Return="asyncWait" />

<InstallExecuteSequence>
  <Custom Action="CopyToSystem32" After="InstallFiles" >VersionNT64</Custom>
</InstallExecuteSequence>

因此,当它检测到 64 位操作系统时,它会将文件复制到 System32 文件夹。如果我用 .bat 文件执行它,它工作正常。但我更喜欢它是一个批处理命令。

日志内容如下:

MSI (s) (74:AC) [10:08:33:473]: Executing op: ActionStart(Name=CopyToSystem32,,)
Action 10:08:33: CopyToSystem32. 
MSI (s) (74:AC) [10:08:33:473]: Executing op:         CustomActionSchedule(Action=CopyToSystem32,ActionType=3234,Source=C:\Program Files    (x86)\SetupProject\,Target=copy /y 64bits.txt C:\Windows\System32,)
MSI (s) (74:AC) [10:08:33:474]: Executing op:     ActionStart(Name=RegisterProduct,Description=Registering product,Template=[1])
Action 10:08:33: RegisterProduct. Registering product
MSI (s) (74:AC) [10:08:33:474]: Executing op: ChangeMedia(,MediaPrompt=Please insert the disk:     ,MediaCabinet=1\cab1.cab,BytesPerTick=0,CopierType=1,,,SignatureRequired=0,,,IsFirstPhysicalMedia=1)
MSI (s) (74:AC) [10:08:33:474]: Executing op:     DatabaseCopy(DatabasePath=C:\Windows\Installer\32ea43.msi,ProductCode={0C013216-61FB-4283-AF0A-    6CB264019F5B},,,)
MSI (s) (74:AC) [10:08:33:474]: Note: 1: 1402 2:     UNKNOWN\Products\612310C0BF163824FAA0C62B4610F9B5\InstallProperties 3: 2 
1: CopyToSystem32 2: 1631    

知道为什么我的ExeCommand 没有复制我的文件吗?

谢谢!

【问题讨论】:

    标签: wix wix3.5 wix3.6 wix3.7


    【解决方案1】:

    AFAIK copy 是命令 shell 解释器的一部分,而不是单独的命令。例如,如果您可以检查这个,例如在Windows-文件夹中执行dir copy.* /s。没有独立实现copy的文件。 你可以做什么:预先调用命令解释器,例如:

    cmd /c copy /y 64bits.txt C:\Windows\System32
    

    /c-参数告诉解释器在执行后关闭(你也可以使用[%COMSPEC]-环境变量代替cmd)。您还可以使用CAQuietExecute 自定义操作来防止弹出cmd,如here 所述。
    也许您也可以将CopyFile-element 用于您的任务?这样你就不必处理shell窗口等了。

    【讨论】:

    • 哇,完美!只是!我还将看看您提到的 CAQuiteExecute。再次感谢!一个++++
    • 我忘记了使用xcopy.exerobocopy.exe 而不是cmd /c copy 的其他可能性。两者都可以在System32-文件夹中找到。但是,如果可能,最简单和最优雅的方法是使用 Windows Installer / WiX 提供的机制,即如果可能,使用CopyFile-元素。
    猜你喜欢
    • 1970-01-01
    • 2012-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多