/build/static/layout/Breadcrumb_cap_w.png

Using the Windows installer object to get upgrade code

Hello

At the moment I am using a VB Script to call the installer object to get the Product code to figure out if the application is installed. I am going though the process of updating the package to the next version and want to know if it’s possible to change it from using the Product code to search for to the Upgrade code so I only have to look for one variable in the code instead of looking for two variables.

Here is the following code I am using to get the product code:


Function PackageInstalled (ProductCode)
Dim ProductState
ProductState – installer.productState (DSWT505ProductCode)
If ProductState <> INSTALLSTATE_LOCAL AND ProductState <> INSTALLSTATE_ADVERTISED And ProductState <> INSTALLSTATE_DEFAULT THEN
Package Installed = false
Else
PackageInstalled=true
End if
End function

0 Comments   [ + ] Show comments

Answers (10)

Posted by: anonymous_9363 15 years ago
Red Belt
0
I think you'll need to dig a bit deeper as, IIRC, ProductState returns INSTALLSTATE_DEFAULT only for the currently logged-in user.If all your apps are installed per-machine, all well and good but if any are installed per-user and you query for an app installed by someone other than the current user, it'll return INSTALLSTATE_ABSENT.

EDIT:
Found this discussion http://forum.installsite.net/index.php?act=ST&f=26&t=14035

EDIT2:
Out of curiosity, I re-read the MSDN entry on ProductState. INSTALLSTATE_ABSENT means that is *is* installed but not for the current user. Not installed at all returns INSTALLSTATE_UNKNOWN.
Posted by: ditch_nz 15 years ago
Purple Belt
0
if you can get the product code, could you just query the registry in HKLM\software\microsoft\uninstall\[ProductCode] to see if it's installed?
Posted by: jmcfadyen 15 years ago
5th Degree Black Belt
0
use the .productsEx methods it works across multiple user hives (i.e. per user)
Posted by: anonymous_9363 15 years ago
Red Belt
0
use the .productsEx methods it works across multiple user hives (i.e. per user) I wonder why MSDN doesn't SAY that? It simply says that it returns a RecordList of installed products. The entry for the 'Products' property states that it enumerates (to a StringList) all products installed for the current user, so it's curious that ProductsEx doesn't make the distinction clear.

Anyway, good to know, John. Nice one.
Posted by: AngelD 15 years ago
Red Belt
0
Ian,

I think John is referring to the UserSid parameter for the ProductsEx method where you can specify which "user" to enumerate for.
Posted by: anonymous_9363 15 years ago
Red Belt
0
Ok, so now I'm wondering why a search on MSDN for 'ProductsEx' (another unfortunate choice of nomenclature, right up there with 'expertsexchange'... think about it...) doesn't turn up a method, only the property? http://msdn.microsoft.com/en-us/library/aa369461(VS.85).aspx
Posted by: AngelD 15 years ago
Red Belt
0
You're correct Ian!

ProductsEx refer to as a property for the Installer object; the actual function/method doing the work is MsiEnumProductsEx.

My guessing is that you can still use the Installer.ProductState(<ProductCode>) to find out if the product is installed; msiInstallStateAbsent (The product is installed for a different user) and msiInstallStateDefault (The product is advertised but not installed).

However I would just populate the Upgrade table to handle the "upgrade" for the next version.
Just keep in mind to use the same ALLUSERS; per-machine or per-user.
Posted by: jmcfadyen 15 years ago
5th Degree Black Belt
0
sorry i meant thos ..

set objInstaller = CreateObject("WindowsInstaller.Installer")

For Each objProduct In objInstaller.ProductsEx("", "", 7)
strProductCode = objProduct.ProductCode
strUserSid = objProduct.UserSid
strSource = objInstaller.ProductInfo(strProductCode, "Installsource")
msgbox objProduct.ProductCode & strSource
exit for
Next


similar code to what you want. , you basically trawl through the installer object like so.

this will present you with product codes that are installed.
Posted by: jmcfadyen 15 years ago
5th Degree Black Belt
0
oh one other thing, i thought it was a method, obviously mistaken I don't use it much but its quite handy.

detects per user installs as well, in the above example I had a per user install with no source paths i needed to update to stop the dreaded browse window appearing for everyone.

poor planning p1sses me off sometimes.. :-)
Posted by: anonymous_9363 15 years ago
Red Belt
0
poor planning p1sses me off sometimes.. :-) After me, John....Cool, wet grass...Cool, wet grass...
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ