[wix-users] Executing Batch File
Joel McBeth
Joel.McBeth at zuerchertech.com
Thu Apr 5 05:38:00 PDT 2018
Here is the documentation for using the Execution custom action:
http://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html
CAQuietExec is being depreciated for WixQuietExec. You don't use ExeCommand with WixQuietExec. I would look at the examples in the link above.
Also a tip, if you are installing bcpimp.bat you can directly reference the file by ID. I couldn't quickly find the documentation on this with a good example, but check out this stack overflow: https://stackoverflow.com/questions/9664652/how-do-i-reference-the-installed-path-of-a-file-in-a-registry-value
Although that might all be pointless as I don't think you can capture the output of WixQuietExec, and if you could I'm not sure you could easily parse it without a custom action. That being said, you should probably just write your own custom action to do all of this instead of using WixQuietExec.
For point 3, you can probably schedule the BCP custom action to run before the SQL scripts are installed.
-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Ven H via wix-users
Sent: Thursday, April 5, 2018 3:34
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Cc: Ven H <venh.123 at gmail.com>
Subject: [wix-users] Executing Batch File
I am trying to execute a batch file through my MSI. I am using the BuiltIn Custom Action with the following code. The batch file is meant for BCP.
Hence I am passing the arguments to the command using properties, as given below in Product.wxs
<CustomAction Id="test" ExeCommand="[INSTALLFOLDER]bcpImp.bat
"[SQLSERVER]\[SQLINSTANCE]" "[SQLUSER]" "[SQLPASSWORD]" "[SQLDB]" "[SQLTABLE]" "[BCPIMPFILE]"" Execute="deferred" Return="check"
Directory="INSTALLFOLDER" />
<InstallExecuteSequence>
<Custom Action="test" After="InstallFiles">NOT Installed</Custom>
</InstallExecuteSequence>
This works fine and the data gets imported. But I have a couple of issues.
1. During execution, it pops up a Console Window. To suppress it, if I use DllEntry="CAQuietExec", I get an error that "The CustomAction element may only have one of the following target attributes specified at a time." So, I cannot have DllEntry and ExeCommand specified at the same time in my CustomAction element. Hence I am not able to execute the BCP command quietly. Is this achievable?
2. To understand whether the custom action executed successfully and to capture it's return value, I tried assigning a Property. In that case I had to remove the Directory attribute, otherwise, it was not getting compiled.
But, I got a runtime exception "A program required for this install could not be run.". So I am not sure how to read the return value. I need this because, I want to execute some more SQL scripts, after the data is imported through BCP. So, I want to check if the BCP import ran successfully, then accordingly, I want to execute more sql scripts. Is this possible?
3. To reiterate the second part of the above issue, I would like to execute some sql scripts after the execution of the custom action. Is this possible? If yes, how?
Please help.
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
More information about the wix-users
mailing list