Microsoft KB Archive/870716

= How to advertise a Windows Installer package that you created by using Visual Studio .NET =

Article ID: 870716

Article Last Modified on 4/3/2007

-

APPLIES TO


 * Microsoft Windows Installer 2.0
 * Microsoft Windows Installer 1.0

-





SUMMARY
''This 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.



IN THIS TASK

 * INTRODUCTION
 * Requirements
 * Create a Windows application to include in the Windows Installer file
 * Create a text file to include in the Windows Installer file
 * Create a Windows Installer file by using Visual Studio .NET
 * Advertise all the features in the Windows Installer file
 * Advertise the features explicitly
 * Modify the Windows Installer file by using the Orca database editor
 * Advertise the features explicitly by using the ADVERTISE property
 * REFERENCES



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  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  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 top

Requirements
This 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 top

Create a Windows application to include in the Windows Installer file
To 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.</li>  Double-click Button1, and then add the following code to the Button1_Click event procedure. MessageBox.Show(&quot;This is a test Windows application.&quot;) </li> On the Build menu, click Build Solution.</li> On the File menu, click Exit.</li></ol>

back to the top

Create a text file to include in the Windows Installer file

 * 1) Start Notepad, and then type This is a text file. in the blank text file.
 * 2) On the File menu, click Save As. The Save As dialog box appears.
 * 3) In the File name box, type MyText, and then click Save.
 * 4) On the File menu, click Exit to close the text file.

back to the top

Create a Windows Installer file by using Visual Studio .NET
<ol> Start Visual Studio .NET.</li> On the File menu, point to New, and then click Project. The New Project dialog box appears.</li> Under Project Types, click Setup and Deployment Projects.</li> Under Templates, click Setup Project.</li> In the Location box, type C:\Setup .</li> In the Name box, type MySetup, and then click OK.</li> Add the Windows application to the Setup project, and then add a shortcut to the Programs menu. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> In Solution Explorer, right-click MySetup, point to Add, and then click File. The Add Files dialog box appears.</li> In the Add Files dialog box, locate and then double-click the MyWinApp folder on your computer.</li> In the MyWinApp folder, double-click the bin folder.</li> In the Add Files dialog box, click the MyWinApp.exe file, and then click Open.</li> 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.</li> In the Select Item in Project dialog box, double-click Application Folder.</li> <li>Click MyWinApp.exe, and then click OK.</li></ol> </li> <li>Add the text file to the Setup project, and then add a shortcut to the Programs menu. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>In Solution Explorer, right-click MySetup, point to Add, and then click File. The Add Files dialog box appears.</li> <li>In the Add Files dialog box, locate and then click the MyText file on your computer. Click Open.</li> <li>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.</li> <li>In the Select Item in Project dialog box, double-click Application Folder.</li> <li>Click MyText.txt, and then click OK.</li></ol> </li> <li>On the Build menu, click Build Solution.</li></ol>

back to the top

Advertise all the features in the Windows Installer file
<ol> <li>Click Start, click Run, type cmd in the Open box, and then click OK.</li> <li>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.</li> <li>On the Welcome to the MySetup Setup Wizard page, click Next.</li> <li>On the Select Installation Folder page, type C:\Setup in the Folder box, and then click Next.</li> <li>In the Confirm Installation box, click Next.</li> <li>In the Installation Complete box, click Close.</li> <li>Click Start, point to Programs, and then click Shortcut to MyWinApp.exe. The installation process starts.</li></ol>

back to the top

Advertise the features explicitly
To 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 top

Modify the Windows Installer file by using the Orca database editor
<ol> <li>Open the Windows Installer file by using the Orca database editor: <ol style="list-style-type: lower-alpha;"> <li>Install the Windows Installer SDK on your computer. To obtain the Windows Installer SDK, visit the following Microsoft Web site:

http://www.microsoft.com/msdownload/platformsdk/sdkupdate/

</li> <li>Install the Orca database editor by double-clicking the Orca.msi file in the \Bin folder.

Note  is a placeholder for the path of the location where the Windows Installer SDK is installed.</li> <li>Click Start, point to Programs, and then click Orca.</li> <li>On the File menu, click Open.</li> <li>In the Open dialog box, locate and then click the MySetup.msi file that you created in the &quot;Create a Windows Installer file by using Visual Studio .NET&quot; section. Click Open. The tables in the MySetup.msi file are listed in the left pane.</li></ol> </li> <li>Modify the tables in the MySetup.msi file: <ol style="list-style-type: lower-alpha;"> <li>In the left pane, click the FeatureComponents table.</li> <li>In the Feature column, replace the two existing values with the following values:

Feature1

Feature2

</li> <li>In the left pane, click the Feature table.</li> <li>Replace the existing value in the Feature column with the following value:

Feature1

</li> <li>On the Tables menu, click Add Row to add a row to the Feature table. The Add Row dialog box appears.</li> <li>In the Feature - String[38], Required box, type Feature2 .</li> <li>Click Display, and then type 2 in the Display - Short box.</li> <li>Click Level, and then type 1 in the Level - Short, Required box.</li> <li>Click Directory, and then type TARGETDIR in the Directory_ - String[72] box.</li> <li>Click Attributes, and then type 0 in the Attributes - Short, Required box.</li> <li>In the Add Row dialog box, click OK.</li> <li>In the left pane, click the MsiAssembly table.</li> <li>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.</li> <li>In the left pane, click the Shortcut table.</li> <li>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.</li></ol> </li> <li>On the File menu, click Save.</li> <li>On the File menu, click Exit.</li></ol>

back to the top

Advertise the features explicitly by using the ADVERTISE property
To 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. <ol> <li>Click Start, click Run, type cmd in the Open box, and then click OK.</li> <li>At the command prompt, use one of the following commands to advertise the features: <ul> <li>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

</li> <li>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

</li></ul>

Press ENTER. The MySetup dialog box appears.</li> <li>On the Welcome to the MySetup Setup Wizard page, click Next.</li> <li>On the Select Installation Folder page, type C:\Setup in the Folder box, and then click Next.</li> <li>In the Confirm Installation box, click Next.</li> <li>In the Installation Complete box, click Close.</li> <li>Click Start, and then point to Programs to see the shortcut to your application.</li></ol>

back to the top

<div class="references_section">