Create MSI packages via command lines: Unleash the power of automation

Written by Alex Marin · May 10th, 2023

Automation is probably one of the most used words in the IT Industry these days. We can't enter a room without hearing about it in the software packaging industry. However, sometimes simplicity is key.

NoteIf you want to explore how much automation you can introduce into your software packaging process, check out this article: “How much can you automate your software packaging process? An IT Pro perspective.

In this article, we want to get down to basics and explore if it’s possible to create MSI packages using the command line.

As we dive deeper into the topic of creating MSI packages from the command line, we'll now shift our focus to a specific aspect of automation - the use of the Installer Object from the Windows Installer technology.

What is the Installer Object?

The Installer Object is a component of the Windows Installer technology that provides a set of programming interfaces for working with MSI packages. It is a powerful tool for automating software packaging and deployment tasks and is commonly used in enterprise software development and deployment scenarios.It enables software developers to manipulate and modify MSI packages programmatically using a range of methods and properties. The Installer Object can be accessed through the Component Object Model (COM) and requires the automation support to be loaded before it can be used.

Let's take a closer look at these methods and explore what each of them can do.




Adds a source to the list of valid network sources in the sourcelist.


Advertises an installation package.


Advertises an installation package.


Applies one or more patches to products eligible to receive the patch. Sets the PATCH property to the path of the patch packages provided.


Invokes an installation and sets the PATCH property to the path of the patch package for each product listed by the patch package as eligible to receive the patch.


Removes all network sources from the source list.


Invokes a user interface wizard sequence that collects and stores both user information and the product code.


Configures the installed state of a product feature.


Installs or uninstalls a product.


Generates an advertised script.


Returns a new Record object with the requested number of fields.


Enables logging of the selected message type for all subsequent installation sessions in the current process space.


Extracts information from a patch as an XML string.


Takes the path to a file and returns a 128-bit hash of that file.


Takes the path to a file and returns a SAFEARRAY of bytes that represents the hash or the encoded certificate.


Returns the size of the specified file.


Returns the version string or language string of the specified path.


Forces the installer to search the source list for a valid product source the next time a source is required.


Opens an installer package and initializes an installation session.


Returns a Record object that contains error parameters for the most recent error from the function that produced the error record.


Opens an existing database or creates a new one.


Opens an installer package for use with functions that access the product database and install engine.


Opens an installer package for an installed product using the product code.


Returns the installed path of an assembly.


Returns the full component path and performs any necessary installation.


Returns the full component path and performs any necessary installation.


Reads information about a specified registry key of value.


Reinstalls features or corrects problems with installed features.


Reinstalls a product or corrects installation problems in an installed product.


Removes one or more patches to products eligible to receive the patch.


Increments the usage count for a particular feature and returns the installation state for that feature.

The OpenDatabase method offers multiple openMode options, two of which are:






Creates a new database, transact mode read/write.



Creates a new database, direct mode read/write.

Knowing these, we can develop the following PowerShell script to create the MSI package by using the command line:

$MSIFilePath = "C:\Users\User\Desktop\test.msi"
$WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer
$WindowsInstallerDatabase = $WindowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $null, $WindowsInstaller, @(($MSIFilePath), 4))
$WindowsInstallerDatabase.GetType().InvokeMember("Commit", "InvokeMethod", $Null, $WindowsInstallerDatabase, $Null)
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($WindowsInstallerDatabase) | Out-Null

As you can see, we're creating the test.msi using msiOpenDatabaseModeCreateDirect. As the Microsoft documentation mentions, we need to call the commit method and release the COM object once we've completed the operation.

Executing the script above will create the MSI in the designated location without any errors. However, upon opening the MSI file, you will notice that there are no tables or data present.

empty MSI file

As you can probably guess, our first step would be to populate the script with all the necessary tables for the database before we can begin adding the required information. However, using the built-in PowerShell functionality is probably near to impossible to create and manipulate MSI packages.

One alternative would be to use the more superior interop library Microsoft.Deployment.WindowsInstaller, which is found in the Windows Installer XML Deployment Tools Foundation.

Another free alternative is the WiX Toolset, but it has its downsides: a steep learning curve, requires programming knowledge, and has a higher cost for feature creation.

How to use Advanced Installer to Create MSI Packages from command line?

When it comes to creating MSI packages through PowerShell automation, including PowerShell automation, Advanced Installer is the go-to solution. As the top alternative to the WiX Toolset, it offers a user-friendly interface and powerful command-line interface that makes it easy to create and manipulate MSI packages.

NoteSign up for a 30-day full feature trial and experience the benefits of Advanced Installer's advanced features and user-friendly interface for yourself.Download now!

Advanced Installer offers a range of features and capabilities, including the ability to create MSI packages from scratch using CLI interfaces and support for repackaging an installer solely through the command line.

Moreover, if you plan to use batch files or cmd.exe in your PowerShell scripts, you can benefit from the Advanced Installer CLI support.

Here’s how the Advanced Installer command lines for creating a project, adding files, registries and building the project look like:

"" /newproject "C:\MyProject\Sample.aip" -type "professional" -lang "en" -overwrite
"" /edit "C:\MyProject\Sample.aip" /NewReg -RegValue HKUD\Software\[Manufacturer]\[ProductName]\Settings\AppSettings -Data #x36
"" /edit "C:\MyProject\Sample.aip" /AddFile APPDIR C:\Windows\notepad.exe
"" /edit "C:\MyProject\Sample.aip" /NewFeature Samples
"" /edit "C:\MyProject\Sample.aip" /SetCurrentFeature Samples
"" /edit "C:\MyProject\Sample.aip" /AddFile APPDIR C:\foo.edi
"" /edit "C:\MyProject\Sample.aip" /SetCurrentFeature MainFeature
"" /edit "C:\MyProject\Sample.aip" /NewShortcut -name NOTEPAD -dir SHORTCUTDIR -target APPDIR\notepad.exe -wkdir APPDIR
"" /build "C:\MyProject\Sample.aip"

NoteThe command lines need to be executed in the installation folder of advinst.exe, located in Program Files (x86).

MSI Command Line

TipFor those who prefer using PowerShell, we offer multiple Automation Interfaces for configuring and building your Installer Project. Check the full list on our Advanced Installer PowerShell Automation Interfaces page.


In today's world where automation plays a crucial role, it's essential to not overlook the fundamentals that enable us to have greater control over our code.

Command-line tools for creating MSI packages provide a powerful way to automate software packaging and deployment tasks in enterprise software development and deployment scenarios.

We hope you found this article helpful.

Written by
See author's page
Alex Marin

Application Packaging and SCCM Deployments specialist, solutions finder, Technical Writer at Advanced Installer.