我正在执行一个批处理文件,通过wix bundle使用IF NOT EXIST
子句检查是否存在特定文件。它看起来像下面
@echo off
set EMS_INSTALL_ROOT="C:\Program Files (x86)\TOOLS\EMS\swVersion.txt"
IF NOT EXIST "%EMS_INSTALL_ROOT%" (
exit 1
)
set /p Version=<"%EMS_INSTALL_ROOT%"
REG ADD HKCU\CurrentSwVersion /v SwVersion /t REG_SZ /d %VERSION% /f
exit 0
并且bundle.wxs文件看起来像
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Bundle Name='Language Installer 1.0'
Version='1.0'
UpgradeCode='{CFA901F4-F22D-4826-AF17-CEF08636626A}'
Manufacturer='xxx'>
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication
LicenseFile="license.rtf"
SuppressOptionsUI ="yes"
/>
</BootstrapperApplicationRef>
<Chain>
<ExePackage SourceFile="sw_version_check.bat" Compressed="yes"/>
<MsiPackage SourceFile="multilang.msi" Compressed="yes" DisplayInternalUI='yes'/>
</Chain>
</Bundle>
</Wix>
所以,当我在外部执行相同的批处理文件时,比如命令提示符returns 0
,当我通过捆绑它returns 1
运行时。
这是我从bundle
[1140:00EC][2017-11-10T09:46:46]i305: Verified acquired payload: sw_version_check.bat at path: C:\ProgramData\Package Cache\.unverified\sw_version_check.bat, moving to: C:\ProgramData\Package Cache\F791A31D2DE729790CB77093BD38CF43E3FDA802\sw_version_check.bat.
[1140:00EC][2017-11-10T09:46:46]i304: Verified existing payload: multilang.msi at path: C:\ProgramData\Package Cache\{EBB4657C-1AE5-423A-B2E4-2F0E6738BF2F}v1.0.0.0\multilang.msi.
[1140:0E20][2017-11-10T09:46:46]i301: Applying execute package: sw_version_check.bat, action: Install, path: C:\ProgramData\Package Cache\F791A31D2DE729790CB77093BD38CF43E3FDA802\sw_version_check.bat, arguments: '"C:\ProgramData\Package Cache\F791A31D2DE729790CB77093BD38CF43E3FDA802\sw_version_check.bat"'
[1140:0E20][2017-11-10T09:46:46]e000: Error 0x80070001: Process returned error: 0x1
[1140:0E20][2017-11-10T09:46:46]e000: Error 0x80070001: Failed to execute EXE package.
[0DB8:0DC8][2017-11-10T09:46:46]e000: Error 0x80070001: Failed to configure per-machine EXE package.
[0DB8:0DC8][2017-11-10T09:46:46]i319: Applied execute package: sw_version_check.bat, result: 0x80070001, restart: None
[0DB8:0DC8][2017-11-10T09:46:46]e000: Error 0x80070001: Failed to execute EXE package.
我甚至试图在bundle.exe上run as admin
但得到相同的结果。
那么,有人可以告诉我这里我做错了吗?
编辑1
根据@Squashman的建议,我在示例脚本中进行了更改并且它工作但是我应用于动态脚本的同样的事情它再次开始失败。它看起来像
@echo off
FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY "HKLM\SOFTWARE\MANBW" /v "ROOT" 2^>nul`) DO (
set ValueName=%%A
set ValueType=%%B
set "ECS_INSTALL_ROOT=%%CswVersion.txt"
)
IF NOT EXIST "%ECS_INSTALL_ROOT%" (
exit 1
)
set /p Version=<"%ECS_INSTALL_ROOT%"
REG ADD HKCU\CurrentSwVersion /v SwVersion /t REG_SZ /d %VERSION% /f
exit 0
抱歉再次打扰。请告诉我,我正在动态脚本中正确应用@Squashman的建议吗?请帮助我花了5-6小时进行反复试验。