Reputation: 41
I have an executable that requires a preset of parameters being passed to it, hence the need for a batch file (.bat). All was working well until I figured that the folder path used in [WixBundleLastUsedSource] could contain a space.
Here is the EXE file packaged definition:
<ExePackage Id="myexepackage" Compressed="no" Permanent="yes" Cache="no"
After="previousfeature"
SourceFile="$(var.preprocessorvariable)\myexe.bat"
InstallCommand="[WixBundleLastUsedSource]myexe.exe [otherparam]" />
And here are some test I tried and the logs from them:
This one is the working variation:
Applying execute package: myexepackage, action: Install, path: C:\ProgramData\Package Cache\7AE3BA856B7D415569854BFE32DD3848112B7BFA\myexe.bat, arguments: '"C:\ProgramData\Package Cache\7AE3BA856B7D415569854BFE32DD3848112B7BFA\myexe.bat" C:\Users\user\Desktop\Install\myexe.exe otherparamvalue'
While the following two logs are from failures:
Applying execute package: myexepackage, action: Install, path: C:\ProgramData\Package Cache\7AE3BA856B7D415569854BFE32DD3848112B7BFA\myexe.bat, arguments: '"C:\ProgramData\Package Cache\7AE3BA856B7D415569854BFE32DD3848112B7BFA\myexe.bat" "C:\Users\user\Desktop\Install\myexe.exe" otherparamvalue'
Applying execute package: myexepackage, action: Install, path: C:\ProgramData\Package Cache\7AE3BA856B7D415569854BFE32DD3848112B7BFA\myexe.bat, arguments: '"C:\ProgramData\Package Cache\7AE3BA856B7D415569854BFE32DD3848112B7BFA\myexe.bat" "C:\Users\user\Desktop\Install new\myexe.exe" otherparamvalue'
Whenever I introduce quotes to the EXE file package with either "
or %quot;
like
<ExePackage Id="myexepackage" Compressed="no" Permanent="yes" Cache="no"
After="previousfeature"
SourceFile="$(var.preprocessorvariable)\myexe.bat"
InstallCommand=""[WixBundleLastUsedSource]myexe.exe"[otherparam]" />
it fails with:
e000: Error 0x80070001: Process returned error: 0x1
e000: Error 0x80070001: Failed to execute EXE package.
e000: Error 0x80070001: Failed to configure per-machine EXE package.
Is there a solution or workaround for this?
Upvotes: 4
Views: 5383
Reputation: 1
The following code works fine on my system:
InstallCommand='/q InstallFolder="[InstallFolder]"'
Upvotes: 0
Reputation: 67
I came across a similar problem when I was trying to pass arguments to the .net binary.
What I have done is use [WixBundleLastUsedSource] as the last argument.
<ExePackage Id="myexepackage" Compressed="no" Permanent="yes" Cache="no"
After="previousfeature"
SourceFile="$(var.preprocessorvariable)\myexe.exe"
InstallCommand="install [WixBundleLastUsedSource]" />
So, on the c# project I skipped the first argument and collect all the rest of the arguments and join it to get the full path and use that in the project.
var path = String.Join(" ", parsedArgs);
This fixed my issue.
Upvotes: 0
Reputation: 1
My experience with WiX 3.11.1 is that when providing the command parameters via InstallCommand or UninstallCommand, any double quotation marks will cause the command processor (i.e., cmd.exe) to fail. Passing double quotation marks can be tricky from batch script to batch script, let alone encoded in XML inside of WiX. It is probably possible to figure out the correct set of backslashes or other escape characters to place in front of each " tag, but I decided to bypass that completely.
My solution was to use single quotes and modify the batch script to replace all single quotes with double quotes before executing it. Other characters could be used.
<ExePackage Id="myexepackage" Compressed="no" Permanent="yes" Cache="no"
After="previousfeature"
SourceFile="$(var.preprocessorvariable)\myexe.bat"
InstallCommand="'[WixBundleLastUsedSource]myexe.exe' [otherparam]" />
And myexe.bat
is something like:
Set CommandText=%*
Set CommandText=%CommandText:'="%
Call %CommandText%
Upvotes: 0
Reputation: 11210
I had this happening to me because the Wix value passed in ended in a backslash. This ended up causing the second double quote to be escaped somewhere in the install engine, and as a result, the first quote was being stripped. For example:
<ExePackage SourceFile="..\bin\MyEXE.exe" Name="MyEXE.exe" InstallCommand=""InstallDir=[INSTALLDIR]" InstallType=MyType" />
When [InstallDir] ended in a backslash, instead of two command line args there was one, and the first " was being stripped off. The "fix" was to add a space before the second ":
<ExePackage SourceFile="..\bin\MyEXE.exe" Name="MyEXE.exe" InstallCommand=""InstallDir=[INSTALLDIR] " InstallType=MyType" />
Unfortunately some EXE packages might have a problem with the trailing space so this fix might not work for everyone.
Upvotes: 0
Reputation: 8563
The InstallCommand
attribute should contain the parameters passed to the exe. It shouldn't contain the .exe itself.
Upvotes: 1