Prerequisites are usually installed by the Setup.exe bootstrapper, before the main installation takes place. This is called a Setup Prerequisite and is the usual method for installing. However, if you have a Basic MSI project, you can also assign a prerequisite to a feature. This is called a Feature Prerequisite. This is convenient because it allows the user to select whether a prerequisite will be installed. But sometimes, neither of these two methods will work or are available to you.
For example, in an InstallScript MSI project, if your company or client does not want SQL Server installed as a Setup Prerequisite, then you are only left with one option, installing it from the script. This is because Feature Prerequisites are not available in InstallScript MSI projects.
I recently needed to do a SQL Server installation from InstallScript code and I learned something. The 2008 versions of SQL Server don’t always install successfully with this method. This is surprising, because I used LaunchApplication like I always do in InstallScript. But it didn’t matter, the installation still failed. But, there was one method that worked.
If a SQL Server installation need to be a part of any installation, the usual advice is to create a batch file with all the options you need and get the installation to first work from that. When that works successfully, you can add the options to the SQL Server prerequisite in your InstallShield project and the installation will generally work. If it doesn’t, just run the batch file from InstallScript code using LaunchApplication.
Here is an example batch file:
Batch File Showing Installation of SQL Server from Command Line
Here is the code that executes the batch file:
InstallScript Code Showing Execution of Batch File
Now you have another option when installing SQL Server from InstallScript code.