How to advertise a Windows Installer package that you created by using Visual Studio .NET (870716)
The information in this article applies to:
- Microsoft Windows Installer 2.0
- Microsoft Windows Installer 1.0
SUMMARYThis article discusses how to advertise a Microsoft Windows Installer (.msi) package. This article contains an example that demonstrates how to advertise a Windows Installer file that you create by using Microsoft Visual Studio .NET.
The Windows Installer file includes a Windows application and a text file. You can advertise the features in the Windows Installer file only by using the command-line option of the Msiexec executable program. Additionally, you must use the ADVERTISE property to advertise the features. This article discusses the following two ways to advertise the features: - Advertise all features
- Advertise only some features
If you want to advertise only some features, you must modify the Windows Installer file by using the Orca database editor. INTRODUCTION Windows Installer can advertise the availability of an
application without installing the application. If an application is
advertised, only the interfaces that are required for loading and for starting the
application are presented. If you start the advertised interface, Windows Installer installs the required components. This method is also
referred to as installation-on-demand. Advertising is applied to each feature of an
application. When an application is advertised, the application appears to have been
installed. The Start menu contains the appropriate shortcuts, files on your computer are
associated with the application, and registry entries on your computer reflect the application's
installation. However, the application is not installed until the first time that you try to start it. When you create a Windows Installer file by using Visual
Studio .NET, you do not have the option to designate that your package is to be
advertised. You can advertise the package only by using a command-line option
during the installation. At the command prompt, you can explicitly list the
features that you want to advertise or you can advertise all the features. To explicitly
list the features, you must use a command that is similar to the
following: Msiexec.exe /i PathofAndIncludingWindowsInstallerFile
ADVERTISE=Feature1,Feature2,Feature3 If you want to use this command, the features must be present in
the Feature column of the Feature table in the Windows Installer file. To advertise all
the features, you must use a command that is similar to the following: Msiexec.exe /i PathofAndIncludingWindowsInstallerFile ADVERTISE=ALL If you
include the ADVERTISE property in the Property table of the Windows Installer file and then set
the value to ALL, the advertised package cannot be installed or removed.
back to the topRequirementsThis article assumes that you are familiar with the following topics: - Windows applications
- Orca database editor
- Setup and Deployment projects
The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need: - Microsoft Visual Studio .NET
- Microsoft .NET Framework
- Microsoft Windows Platform Software Development Kit (SDK)
back to the topCreate a Windows application to include in the Windows Installer fileTo create a Windows application by using Microsoft Visual
Basic .NET, follow these steps:
- Start Microsoft Visual Studio .NET.
- On the File menu, point to
New, and then click Project. The New
Project dialog box appears.
- Under Project Types, click Visual
Basic Projects.
- Under Templates, click Windows
Application.
- In the Name box, type
MyWinApp, and then click OK. By
default, a Windows Form that is named Form1 is created.
- Add
a Button control to the Form1 form. By default,
a Button control that is named Button1 is added to the Form1 form.
- Double-click Button1, and then add the
following code to the Button1_Click event procedure.
MessageBox.Show("This is a test Windows application.") - On the Build menu, click Build
Solution.
- On the File menu, click
Exit.
back to the topCreate a text file to include in the Windows Installer file- Start Notepad, and then type This is a text
file. in the blank text file.
- On the File menu, click Save
As. The Save As dialog box appears.
- In the File
name box, type MyText, and then click Save.
- On the File menu, click
Exit to close the text file.
back to the topCreate a Windows Installer file by using Visual Studio .NET- Start Visual Studio .NET.
- On the File menu, point to
New, and then click Project. The New
Project dialog box appears.
- Under Project Types, click Setup
and Deployment Projects.
- Under Templates, click Setup
Project.
- In the Location box, type
C:\Setup.
- In the Name box, type
MySetup, and then click OK.
- Add the Windows application to the Setup project, and then
add a shortcut to the Programs menu. To do this, follow these steps:
- In Solution Explorer, right-click
MySetup, point to Add, and then click
File. The Add Files dialog box
appears.
- In the Add Files dialog box, locate
and then double-click
the MyWinApp folder on your computer.
- In the MyWinApp folder, double-click
the bin folder.
- In the Add Files dialog box, click the
MyWinApp.exe file, and then click
Open.
- In the left pane of the File System editor, click
User's Programs Menu, right-click the blank space in the
right pane, and then click Create New Shortcut. The
Select Item in Project dialog box appears.
- In the Select Item in Project dialog
box, double-click Application Folder.
- Click MyWinApp.exe, and then click
OK.
- Add the text file to the Setup project, and then
add a shortcut to the Programs menu. To do this, follow these steps:
- In Solution Explorer, right-click
MySetup, point to Add, and then click
File. The Add Files dialog box
appears.
- In the Add Files dialog box, locate
and then click the MyText file on your computer. Click Open.
- In the left pane of the File System editor, click
User's Programs Menu, right-click the blank space in the
right pane, and then click Create New Shortcut. The
Select Item in Project dialog box appears.
- In the Select Item in Project dialog
box, double-click Application Folder.
- Click MyText.txt, and then click
OK.
- On the Build menu, click Build
Solution.
back to the topAdvertise all the features in the Windows Installer file- Click Start, click
Run, type cmd in the Open box, and then click OK.
- At the command prompt, type the following command, and then press ENTER:
msiexec /i C:\Setup\MySetup\Debug\MySetup.msi ADVERTISE=ALL The MySetup Setup Wizard
appears. - On the Welcome to the MySetup Setup Wizard
page, click Next.
- On the Select Installation Folder page,
type C:\Setup in the Folder box, and
then click Next.
- In the Confirm Installation box, click
Next.
- In the Installation Complete box, click
Close.
- Click Start, point to
Programs, and then click Shortcut to
MyWinApp.exe. The installation process starts.
back to the topAdvertise the features explicitlyTo advertise the features explicitly, you first must
modify the Windows Installer file by using the Orca database editor. Microsoft provides the
Orca database editor to edit your Windows Installer file. The Orca database editor is
included with the Microsoft Windows Installer Software Development Kit
(SDK). To explicitly list the features in the ADVERTISE property, you first must define the features in the Feature table. The ADVERTISE property can
only use the features in the Feature column of the Feature table. You must
modify all the tables in the Windows Installer file that contain the Feature column. To do this, use the Orca database editor to modify the FeatureComponents table, the MsiAssembly table, the Feature table, and the
Shortcut table. After you have modified the Windows Installer
file, you can use the list of features that are defined in the Feature table to specify the features that you want to advertise. To advertise the features that you want that appear in the Feature table, add them to the ADVERTISE property. back to the
topModify the Windows Installer file by using the Orca database editor- Open the Windows Installer file by using the Orca database editor:
- Install the Windows Installer SDK on your computer. To obtain the Windows Installer SDK, visit the following Microsoft Web site:
- Install the Orca database editor by double-clicking
the Orca.msi file in the InstalledPath\Bin folder.
Note InstalledPath is a placeholder
for the path of the location where the Windows Installer SDK is installed. - Click Start, point to
Programs, and then click Orca.
- On the File menu, click
Open.
- In the Open dialog box, locate and then click the
MySetup.msi file that you created in the "Create a Windows Installer file by using Visual Studio .NET" section. Click Open. The tables
in the MySetup.msi file are listed in the left pane.
- Modify the tables in the MySetup.msi file:
- In the left pane, click the
FeatureComponents table.
- In the Feature column, replace the two
existing values with the following values:
- In the left pane, click the Feature table.
- Replace the existing value in the
Feature column with the following
value:
- On the Tables menu, click Add
Row to add a row to the Feature table. The Add Row
dialog box appears.
- In the Feature - String[38], Required
box, type Feature2.
- Click Display, and then type
2 in the Display - Short
box.
- Click Level, and then type
1 in the Level - Short, Required
box.
- Click Directory, and then type
TARGETDIR in the Directory_ - String[72]
box.
- Click Attributes, and then type
0 in the Attributes - Short, Required
box.
- In the Add Row dialog box, click
OK.
- In the left pane, click the MsiAssembly
table.
- In the right pane, change the value in the Feature column to the value that corresponds to the existing component. The correct value for the existing component appears in the Feature column of the FeatureComponents table.
- In the left pane, click the Shortcut table.
- In the right pane, change the values in the Target column to the values that correspond to the existing components. The correct values for the existing component appear in the Feature column of the FeatureComponents table.
- On the File menu, click
Save.
- On the File menu, click
Exit.
back to the topAdvertise the features explicitly by using the ADVERTISE
propertyTo advertise the features explicitly, the list of features that you want to advertise must follow the ADVERTISE property. To do this, follow these steps. Note
Use commas to separate the feature names. - Click Start, click
Run, type cmd in the Open box, and then click OK.
- At the command prompt, use one of the following commands to advertise the features:
- To advertise only one feature, type one of the following commands:
msiexec /i C:\Setup\MySetup\Debug\MySetup.msi ADVERTISE=Feature1
msiexec /i C:\Setup\MySetup\Debug\MySetup.msi ADVERTISE=Feature2 - To advertise a list of features, separate the features by using commas. To do this, type the following command:
msiexec /i C:\Setup\MySetup\Debug\MySetup.msi ADVERTISE=Feature1,Feature2 Press ENTER. The MySetup dialog box
appears. - On the Welcome to the MySetup Setup Wizard
page, click Next.
- On the Select Installation Folder page,
type C:\Setup in the Folder box, and
then click Next.
- In the Confirm Installation box, click
Next.
- In the Installation Complete box, click
Close.
- Click Start, and then point to
Programs to see the shortcut to your application.
back to the
topREFERENCES
For additional information about how to create Setup projects, click the following article number to view the article in the Microsoft Knowledge Base:
307353
How to create a Setup package by using Visual Studio .NET
For more information, visit the following
Microsoft Developer Network (MSDN) Web sites: back to the
top
Modification Type: | Major | Last Reviewed: | 7/20/2004 |
---|
Keywords: | kbsetup kbPackage kbHOWTOmaster kbhowto KB870716 kbAudDeveloper |
---|
|
|
©2004 Microsoft Corporation. All rights reserved.
|
|