Question

I implement wix to generate some msi. I'd like to maintain .bat file (that is packed within this wix project) to contain some work to do (and to be activated with some custom action) I added the .bet to my wix project in VS2010.

My question is

  1. how do I actually wrap it within the msi that on target machine the script will be available to run?
  2. How do I actually refer to that embedded batch file in the custom section element
Was it helpful?

Solution

This might not be the answer you're looking for, but I strongly recommend you NOT going this way. Running batch file from inside the MSI package has a number of disadvantages, which will shoot you one day:

  • antivirus might block the execution
  • as for any deferred custom action (the one which changes the target system state) you'll have to create a rollback action, and for a batch file which might include a number of steps of different nature it could be much more difficult
  • you don't have the progress (I doubt this is at all possible for batch script)

Instead, I encourage you to do the following:

  • analyze your batch script and make a list of exact things it does to the target system
  • take a look at the standard Windows Installer functionality and WiX extensions to see what's there out of the box
  • design your installation to use standard functionality as much as possible and custom actions as little as possible
  • if you still need a custom action, stick to the DLL ones and make sure rollback actions are present for deferred actions

OTHER TIPS

You're looking for what I think is a type 18 custom action:

The executable is generated from a file installed with the application. The 
Source field of the CustomAction table contains a key to the File table. The 
location of the custom action code is determined by the resolution of the target 
path for this file; therefore this custom action must be called after the file 
has been installed and before it is removed.

The CustomAction element has the ExeCommand attribute for just this sort of occasion. It would look something like this:

<CustomAction Id="ExecuteMyBatchFile" 
              FileKey="[#FileKey]" 
              ExeCommand="Arguments passed to batch file"
              Execute="deferred"/>

Of course, this is assuming the batch file is installed by the msi.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top