How can I execute a .BAT file from an .MSI installation?

Article:HOWTO4383  |  Created: 2005-09-21  |  Updated: 2006-01-26  |  Article URL
Article Type
How To

How can I execute a .BAT file from an .MSI installation?

To execute a .BAT file in a Windows Installer installation, you will have to use a custom action. Do the following:

  1. In the .WSI file, select View > MSI Script..
  2. In the Installation Sequence list, click the location in the sequence where you want to place the custom action.
  3. Double-click the Execute Program from Path custom action on the Custom tab. The Execute Program from Path dialog displays.
  4. Populate the Details tab as follows:
    • Name: Enter a name for the custom action.
    • Property: Enter %COMSPEC. This is the environment variable that holds the location of the cmd.exe program.
    • Command Line: Enter "/c <path to .BAT>\<batchfile.BAT>" (replacing the text in <> with the path and name of your batch file. Enclose the path and batch file name in double quotes. The /c switch closes the cmd.exe window after the batch file executes. To execute the batch file and keep the cmd.exe window open, enter /k instead. (This can be useful for debugging batch files.)

      Note: The cmd.exe launches in the System directory by default. If your batch file executes actions in another directory, you must explicitly account for that in the batch file. For example, to list the files in c:\mydir, add a line to the batch file that reads 'cd c:\mydir'.
  5. Click OK.

Legacy ID


Article URL

Terms of use for this information are found in Legal Notices