【发布时间】:2010-10-27 08:51:47
【问题描述】:
我正在使用 WiX 创建一个 MSI 安装程序,并且我有一个 *.bat 文件,我将其复制到 %temp% 下的 SomeFolder2(类似于下面的代码 sn-p...)
...
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='MyDir' Name='SomeFolder'>
<!-- %TEMP -->
<Directory Id="TempFolder" Name="TmpFolder">
<Directory Id='MyDir2' Name='SomeFolder2'>
<!-- CREATE THE %TEMP%\SomeFolder2 FOLDER -->
<Component Id='FolderComponent' Guid='{GUID}'>
<CreateFolder />
</Component>
<Component Id='CheckComponent' Guid='{GUID}'>
<File Id='mybat' Name='mybat.bat' DiskId='1' Source='.\mybat.bat' KeyPath="yes">
<Shortcut Id="mybatShcut"
Directory="ProgramMenuDir"
Name="{name}"
WorkingDirectory='INSTALLDIR'
Advertise="yes" />
</File>
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
...
现在,要运行它,我有两个自定义操作(DESTDIR 是 %TEMP%\SomeFolder2):
<CustomAction Id="SetPath" Property="ThePath" Value="[DESTDIR]\mybat.bat" />
<CustomAction Id="StartAction" Property="ThePath" ExeCommand="" Return="asyncNoWait" />
然后在安装顺序中:
<InstallExecuteSequence>
<Custom Action="SetPath" After="{some standard MS action}">NOT REMOVE="ALL"</Custom>
<Custom Action="StartAction" Before="{some other action}">NOT REMOVE="ALL"</Custom>
...
</InstallExecuteSequence>
我已将 SetPath 在各种标准操作(例如 PublishProduct)之后运行,而 StartAction 将在另一个自定义操作之前运行。
当我运行 MSI 文件时,我查看了日志,并且 ThePath 确实设置了正确的路径。但是,当 StartAction 运行时,我收到此错误:
返回值 1631。
根据文档,翻译为“ERROR_CREATE_FAILED”(Windows Installer 服务无法启动。请联系您的支持人员)。问题是,文件确实被复制到%TEMP%\SomeFolder2(在设置路径和实际执行之前,我可以添加...),但由于某种原因,它根本不执行(如果你执行手动或通过命令提示符之类的,它确实执行正常)。
我尝试将相同的文件放在ProgramFiles\Some_Directory_For_The_Program 下。同样的事情也会发生;它被复制到那里,但它不执行。为什么会这样?
【问题讨论】:
标签: installation wix windows-installer wix3