[wix-users] Executing Batch File

Ven H venh.123 at gmail.com
Thu Apr 5 00:33:35 PDT 2018


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.


More information about the wix-users mailing list