Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

INTRODUCTION

Windows Installer provides APIs that let a user query the Windows Installer database for the presence of a particular product. Each product is uniquely identified by its product code, which is a GUID. This article provides code samples that show how to programmatically check for the presence of a Windows Installer-based product by using its product code.

More Information

Call the API from Visual C++

The following is an example of how you can call the MsiGetProductInfoExW() method in Visual C++ to detect the presence of a specific product. The product is specified by its unique product code GUID.

TCHAR szVersion[20];
DWORD cchVersion = 20;
BOOL fInstalled = (ERROR_SUCCESS == MsiGetProductInfoEx (TEXT("{ProductCode}"), NULL, MSIINSTALLCONTEXT_MACHINE, INSTALLPROPERTY_VERSIONSTRING, szVersion, &cchVersion));

In this code example fragment, the fInstalled Boolean variable will contain a TRUE or FALSE value, depending on whether the product that is specified is installed or not installed.

Call the API from VBScript

The following is an example of how you can call the ProductInfo() method on the WindowsInstaller.Installer object in Microsoft Visual Basic Script to detect the presence of a specific product. The product is specified by its unique product code GUID.

                
Dim msi : Set msi = CreateObject("WindowsInstaller.Installer")
On Error Resume Next
Dim version : version = msi.ProductInfo("{ProductCode}", "VersionString")
Dim installed : installed = ( Err.Number = 0 )

In this code example fragment, the installed variable will contain a 0 or 1 value, depending on whether the product that is specified is installed or not installed.



Note The ProductCode property that is passed to the functions in both examples here include braces ({ }) inside the quotation marks. For more information about Windows Installer, visit the following Microsoft Windows Installer MSDN Web page:

http://msdn.microsoft.com/en-us/library/aa367449(VS.85).aspxFor more information about how to obtain the latest version of Windows Installer for your computer, visit the following Microsoft Web page:

http://www.microsoft.com/download/details.aspx?familyid=5A58B56F-60B6-4412-95B9-54D056D6F9F4&displaylang=en

For more information, visit the following Microsoft Web pages:

Note about the "Applies to" sectionIn addition to the products that are listed in the "Applies to" section, the information in this article also applies to the following product:

  • Windows Installer 4.0

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×