In most of the projects, multiple applications need to be
delivered at once to the client. Instead of creating a setup file (or MSI File)
for each application and delivering all the setup files to the client, the
better solution is to provide a Main Setup file that contains setup files of
each application. The Main Setup file will also have the splash screen, which
executes the Setup files in the Main Setup file. When executed, the Main Setup
file pops up a splash screen, enabling end-users to select all the applications
or a few applications for installation. This simplifies the process of
This article demonstrates how to implement the same thing through
simple custom code.
Visual Studio .NET 2003
Creating the Setup for Each Application
The steps given below describe the process to create the setup
for each application.
Add a Windows Application project with the name Application1. To this,
add a form with a Label. In the Label, set the text as Welcome to Application1.
Now add a Setup project with the name Application1Setup.
In the File System Editor (SetUp), add the above Windows project as the Primary
Output project in the Application Folder.
Compile the solution.
Similarly, create two more applications as Application2 and Application3,
and for each of these applications, create Setups as Application2Setup and Application3Setup.
Designing the Splash Screen
Create a Windows Application project with the name SplashScreen.
To this, add a form which should look as follows.
2. Add the following code by double-clicking the Button
control labeled “Install.”
private void btnInstall_Click(object sender, System.EventArgs e)
StreamWriter sw = null;
if (ChkApplication1.Checked == false &&
chkApplication2.Checked == false &&
chkApplication3.Checked == false )
MessageBox.Show("Please Select the Application, You
would like to Install");
Assembly objAssembly = Assembly.GetAssembly(this.GetType());
string strAppPath= objAssembly.CodeBase;
strAppPath = strAppPath.Replace("SplashScreen.dll","");
Uri objUri = new Uri(strAppPath);
strAppPath = @objUri.AbsolutePath;
string strBatchFilePath = strAppPath + @"Setup.bat";
sw = File.CreateText(strBatchFilePath);
string ReadString = "@echo off";
if (ChkApplication1.Checked == true)
string strAppltn1Path = strAppPath + "Application1Setup.msi";
strAppltn1Path = strAppltn1Path.Replace("/","\\");
strAppltn1Path = @"msiexec /i " + strAppltn1Path;
if (chkApplication2.Checked == true)
string strAppltn2Path = strAppPath + "Application2Setup.msi";
strAppltn2Path = strAppltn2Path.Replace("/","\\");
strAppltn2Path = @"msiexec /i " + strAppltn2Path;
if (chkApplication3.Checked == true)
string strAppltn3Path = strAppPath + "Application3Setup.msi";
strAppltn3Path = strAppltn3Path.Replace("/","\\");
strAppltn3Path = @"msiexec /i " + strAppltn3Path;
sw = null;
In the above listing, first the current assembly path is
fetched, and the batch file named Setup.bat is created in the same assembly
path. Then, it checks which application is selected by the end-users for
installation. The selected applications' MSI file path is fetched, concatenated
with the command “msiexec /i,” and written into the batch file. The command “msiexec
/i” executes the MSI file.
Once all the selected applications are written into the batch
file, this batch file is executed by the System.Diagnostics.Process.Start
namespace method, which executes the MSI files contained in this batch file one
Also, add the code shown below in the Checkbox
private void chkSelectAll_CheckedChanged(object sender, System.EventArgs e)
if (chkSelectAll.Checked == true)
ChkApplication1.Checked = true;
chkApplication2.Checked = true;
chkApplication3.Checked = true;
ChkApplication1.Checked = false;
chkApplication2.Checked = false;
chkApplication3.Checked = false;
In the above listing, when the chkSelectAll checkbox is
selected, all the applications (Application1, Application2, and Application3)
will be selected for installation. With chkSelectAll unselected, all the
applications are unselected. Finally, compile the project.
Creating the Main Setup Consisting of Individual Setups
and Splash Screen
Now add another Setup project as MainSetup.
To this, add the above SplashScreen project as the Primary
Output project in the Application Folder.
And now add Application1Setup, Application2Setup, and Application3Setup
to the Application folder (Setup) as shown below.
In the Custom Action Editor (Set Up), add SplashScreen as
the Primary Output project to the Install folder as shown below.
Now compile the project.
Executing the Main Setup
Execute the Main Setup file, on which the splash screen is
displayed (see Figure 4). In the splash screen, select the Applications you
want to deploy (suppose Application1 and Application2 are selected), and click
the Install button. This executes first the Application1Setup; on completing
the Application1Setup execution, it executes the Application2Setup.
Now go to c:\DynamicMSI -> and find Application1 and Application2
as shown below.
Click Application1.exe, on which a screen is displayed with the
text "Welcome to Application1." Similarly, perform the above step for
On selecting the Select All option in the splash screen, all
the applications will be selected for installation, and they will be
executed one by one when the Install button is clicked.
In this article, I have demonstrated how to provide the
splash screen, which enables end users to select some of the applications or
all the applications at once for installation using Visual Studio .NET 2003.
You have also seen how to execute an MSI file dynamically.