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

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.

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 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:
  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, point to New, and then click Project. The New Project dialog box appears.
  3. Under Project Types, click Visual Basic Projects.
  4. Under Templates, click Windows Application.
  5. In the Name box, type MyWinApp, and then click OK. By default, a Windows Form that is named Form1 is created.
  6. Add a Button control to the Form1 form. By default, a Button control that is named Button1 is added to the Form1 form.
  7. Double-click Button1, and then add the following code to the Button1_Click event procedure.
    MessageBox.Show("This is a test Windows application.")
  8. On the Build menu, click Build Solution.
  9. On the File menu, click Exit.
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

  1. Start Visual Studio .NET.
  2. On the File menu, point to New, and then click Project. The New Project dialog box appears.
  3. Under Project Types, click Setup and Deployment Projects.
  4. Under Templates, click Setup Project.
  5. In the Location box, type C:\Setup.
  6. In the Name box, type MySetup, and then click OK.
  7. Add the Windows application to the Setup project, and then add a shortcut to the Programs menu. To do this, follow these steps:
    1. In Solution Explorer, right-click MySetup, point to Add, and then click File. The Add Files dialog box appears.
    2. In the Add Files dialog box, locate and then double-click the MyWinApp folder on your computer.
    3. In the MyWinApp folder, double-click the bin folder.
    4. In the Add Files dialog box, click the MyWinApp.exe file, and then click Open.
    5. 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.
    6. In the Select Item in Project dialog box, double-click Application Folder.
    7. Click MyWinApp.exe, and then click OK.
  8. Add the text file to the Setup project, and then add a shortcut to the Programs menu. To do this, follow these steps:
    1. In Solution Explorer, right-click MySetup, point to Add, and then click File. The Add Files dialog box appears.
    2. In the Add Files dialog box, locate and then click the MyText file on your computer. Click Open.
    3. 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.
    4. In the Select Item in Project dialog box, double-click Application Folder.
    5. Click MyText.txt, and then click OK.
  9. On the Build menu, click Build Solution.
back to the top

Advertise all the features in the Windows Installer file

  1. Click Start, click Run, type cmd in the Open box, and then click OK.
  2. 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.
  3. On the Welcome to the MySetup Setup Wizard page, click Next.
  4. On the Select Installation Folder page, type C:\Setup in the Folder box, and then click Next.
  5. In the Confirm Installation box, click Next.
  6. In the Installation Complete box, click Close.
  7. Click Start, point to Programs, and then click Shortcut to MyWinApp.exe. The installation process starts.
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

  1. Open the Windows Installer file by using the Orca database editor:
    1. Install the Windows Installer SDK on your computer. To obtain the Windows Installer SDK, visit the following Microsoft Web site:
    2. 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.
    3. Click Start, point to Programs, and then click Orca.
    4. On the File menu, click Open.
    5. 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.
  2. Modify the tables in the MySetup.msi file:
    1. In the left pane, click the FeatureComponents table.
    2. In the Feature column, replace the two existing values with the following values:

      Feature1
      Feature2

    3. In the left pane, click the Feature table.
    4. Replace the existing value in the Feature column with the following value:

      Feature1

    5. On the Tables menu, click Add Row to add a row to the Feature table. The Add Row dialog box appears.
    6. In the Feature - String[38], Required box, type Feature2.
    7. Click Display, and then type 2 in the Display - Short box.
    8. Click Level, and then type 1 in the Level - Short, Required box.
    9. Click Directory, and then type TARGETDIR in the Directory_ - String[72] box.
    10. Click Attributes, and then type 0 in the Attributes - Short, Required box.
    11. In the Add Row dialog box, click OK.
    12. In the left pane, click the MsiAssembly table.
    13. 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.
    14. In the left pane, click the Shortcut table.
    15. 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.
  3. On the File menu, click Save.
  4. On the File menu, click Exit.
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.
  1. Click Start, click Run, type cmd in the Open box, and then click OK.
  2. 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.
  3. On the Welcome to the MySetup Setup Wizard page, click Next.
  4. On the Select Installation Folder page, type C:\Setup in the Folder box, and then click Next.
  5. In the Confirm Installation box, click Next.
  6. In the Installation Complete box, click Close.
  7. Click Start, and then point to Programs to see the shortcut to your application.
back to the top

REFERENCES

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:MajorLast Reviewed:7/20/2004
Keywords:kbsetup kbPackage kbHOWTOmaster kbhowto KB870716 kbAudDeveloper