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

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

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.
Answered 02/27/2009 by: VBScab
Red Belt

Please log in to comment
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?
Answered 03/11/2009 by: ditch_nz
Purple Belt

Please log in to comment
0
use the .productsEx methods it works across multiple user hives (i.e. per user)
Answered 04/27/2009 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
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.
Answered 04/28/2009 by: VBScab
Red Belt

Please log in to comment
0
Ian,

I think John is referring to the UserSid parameter for the ProductsEx method where you can specify which "user" to enumerate for.
Answered 04/28/2009 by: AngelD
Red Belt

Please log in to comment
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
Answered 04/28/2009 by: VBScab
Red Belt

Please log in to comment
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.
Answered 04/28/2009 by: AngelD
Red Belt

Please log in to comment
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.
Answered 04/28/2009 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
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.. :-)
Answered 04/28/2009 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
0
poor planning p1sses me off sometimes.. :-) After me, John....Cool, wet grass...Cool, wet grass...
Answered 04/29/2009 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity