Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Checking to see if a product is installed


3 replies to this topic

vengeanz

vengeanz
  • Full Members
  • 4 posts

Posted 24 October 2006 - 21:07

Hi,

I've been trying to use the function MsiQueryProductState or property Installer.ProductState to check if an MSI product is installed.

I checked msi.h to see what constants I would need if I wanted to use the COM object Installer.ProductState in a vbscript and I came across something I thought was strange.

in msi.h they declare

typedef enum tagINSTALLSTATE
{
...
INSTALLSTATE_ADVERTISED = 1
INSTALLSTATE_REMOVED = 1
...
}

If the function returns 1 how do I know if the product is either advertised or removed or am I missing something here?

cheers
vengeanz

Gareth at Serif

Gareth at Serif
  • Full Members
  • 85 posts

Posted 30 October 2006 - 12:17

For situations like this I've simply set a new row in the Upgrade table with a flag for OnlyDetect. This will find your product and set a property accordingly that you can then detect within your package (after AppSearch in your sequence) to see if the other product(s) is present on the system or not.

Regards,
Gareth

vengeanz

vengeanz
  • Full Members
  • 4 posts

Posted 02 November 2006 - 08:55

Hey Gareth,

Thanks for your reply.

In this situation I wanted to check if the product is installed from VBscript or C code, without actually running any specific MSI package.

I think I can do this, but I was wondering why the enum in the msi.h file has two (and I would have thought distinct) install states having the same value.

The way I see it Advertised is a form of Installed Product whereas Removed is ... well, removed.

so if I get a 1 back from either function is my product installed or not?


Cheers
vengeanz

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 02 November 2006 - 14:07

The return type INSTALLSTATE is used for multiple functions. In this case, INSTALLSTATE_REMOVED can be returned from MsiGetComponentState, in which case it means that the component is about to be removed. Note that components can never be advertised - only features can.

When a product is not installed, MsiQueryProductState returns INSTALLSTATE_ABSENT. This value is also returned when the product was installed some time ago, but not anymore.

BTW You can also search on products using an upgrade code - look at MsiEnumRelatedProducts.