Create msi from a batch file

Home » Documentation » Create msi from a batch file

That’s right. You can wrap a .bat file instead of an executable installer.

Let’s say that you simply want to create a MSI package from a batch file and some other files belonging to that script. You can do that using the MSI Wrapper.

Here is an example of how to do that. The following code is a sample batch file, which will copy a test.txt file to the program files folder under the sub directory MSI Test.

REM -- Get the directory where this script running from

REM -- Copy file to program files
SET DESTDIR=%ProgramFiles%\MSI Test
COPY "%SCRIPTDIR%\test.txt" "%DESTDIR%\test.txt"

REM -- Return exit code 0

Before you wrap this batch file, you place it in an folder together with the test.txt file. Then you specify it as the executable file in the MSI Wrapper.

After this you have to specify some mandatory settings before you can build your MSI package. These settings include the Upgrade code, Product name, Manufacturer, and Version number.

Other script languages

​With the ability to package a batch script and related files, you can launch a wide variety of other script languages. This includes PowerShell,  Python, JavaScript and VB Script.

Exit codes​

The exit codes will translate to error states in the MSI. An exit code of 0 (zero) from the batch file will signal success to the Windows installer. Everything else will translate to error 1603 and the installation is a failure. Keep in mind that there is no roll back of what your batch file has changed.

If you want to handle more exit codes in a custom way, you can still use the mapping of exit codes.

Exit codes

You can download the sample files here. Batch File Sample