使用 Wix 自定义操作时复制命令不起作用
题
我有以下内容 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
不是复制我的文件吗?
谢谢!
解决方案
AFAIK copy
是命令 shell 解释器的一部分,而不是其本身的命令。例如,如果您例如,您可以检查此项做一个 dir copy.* /s
在里面 Windows
-文件夹。没有独立实现的文件 copy
。你可以做什么:在命令解释器的调用前面添加,例如:
cmd /c copy /y 64bits.txt C:\Windows\System32
这 /c
-参数告诉解释器在执行后关闭(您也可以使用 [%COMSPEC]
- 环境变量而不是 cmd
)。您还可以使用 CAQuietExecute
自定义操作以防止 cmd 弹出窗口,如上所述 这里.
也许你也可以使用 CopyFile
-元素 为了你的任务?这样你就不必处理 shell 窗口等。
不隶属于 StackOverflow