PDA

View Full Version : How to find the ProductCode of an installed product?


NewsArchive
09-18-2001, 11:00 PM
Hi,

I am working on upgrade of a product. Is there anybody who knows how can I
get the product code of the installed product on a target machine? The scene
is: I want to write a CA to check the target machine for installed product
(same name, but different product code), if there is one, it will get the
product code and uninstall it. But how can the CA execute during the new
package installation, and get the installed product code (if there is one
installed)?

Thanks,
Peter

NewsArchive
09-23-2001, 11:00 PM
Have you looked at a major upgrade? Iit seems to exactly what you want.

http://www.installsite.org/files/iswi/Upgrading.html

Typically you know what the product code would be because you shipped it.
Otherwise, use msispy from the WI SDK, or use a script like this on a system
with that old product installed:

Option Explicit
Public installer, prod, a, fso

Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("components.txt", True)

' Connect to Windows Installer object
Set installer = CreateObject("WindowsInstaller.Installer")
a.writeline ("Products")
For Each prod In installer.products
a.writeline (prod & " " & installer.productinfo (prod,
"InstalledProductName") & " " & installer.productinfo (prod,
"VersionString") )
Next

"Peter" <yabing.bi@ncr.com> wrote in message
news:3ba91507@rpc1284.daytonoh.ncr.com...
> Hi,
>
> I am working on upgrade of a product. Is there anybody who knows how can I
> get the product code of the installed product on a target machine? The
scene
> is: I want to write a CA to check the target machine for installed product
> (same name, but different product code), if there is one, it will get the
> product code and uninstall it. But how can the CA execute during the new
> package installation, and get the installed product code (if there is one
> installed)?
>
> Thanks,
> Peter
>
>

NewsArchive
09-24-2001, 11:00 PM
Hi, Phil,

The article is exactly I am following to implement upgrade. In method 2 in
the article, if I detected more than one version of the product installed
(same name, different product code), how can I use the "uninstall100" CA?
Will it work to have more than one product codes after 'msiexec /x "?, if
so, what delimiter should I use to separate them? If not, how can I remove
all of the installed products?

I am really appreciated for your suggestions and help.

Thanks,
Peter

"Phil Wilson" <phil.wilson@unisys.nospam.com> wrote in message
news:3baf76b0@news.installshield.com...
> Have you looked at a major upgrade? Iit seems to exactly what you want.
>
> http://www.installsite.org/files/iswi/Upgrading.html
>
> Typically you know what the product code would be because you shipped it.
> Otherwise, use msispy from the WI SDK, or use a script like this on a
system
> with that old product installed:
>
> Option Explicit
> Public installer, prod, a, fso
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set a = fso.CreateTextFile("components.txt", True)
>
> ' Connect to Windows Installer object
> Set installer = CreateObject("WindowsInstaller.Installer")
> a.writeline ("Products")
> For Each prod In installer.products
> a.writeline (prod & " " & installer.productinfo (prod,
> "InstalledProductName") & " " & installer.productinfo (prod,
> "VersionString") )
> Next
>
> "Peter" <yabing.bi@ncr.com> wrote in message
> news:3ba91507@rpc1284.daytonoh.ncr.com...
> > Hi,
> >
> > I am working on upgrade of a product. Is there anybody who knows how can
I
> > get the product code of the installed product on a target machine? The
> scene
> > is: I want to write a CA to check the target machine for installed
product
> > (same name, but different product code), if there is one, it will get
the
> > product code and uninstall it. But how can the CA execute during the new
> > package installation, and get the installed product code (if there is
one
> > installed)?
> >
> > Thanks,
> > Peter
> >
> >
>
>

NewsArchive
09-25-2001, 11:00 PM
Thanks, Phil,

I made small changes on the sample code. It could get the installed product
code. But I have problem to setup properties through the code.
Here is the code:
--------------------
Option Explicit
Public installer, prod, fso, x, list

Set fso = CreateObject("Scripting.FileSystemObject")

' Connect to Windows Installer object
Set installer = CreateObject("WindowsInstaller.Installer")
x=0
For Each prod In installer.products
if installer.productinfo (prod, "InstalledProductName")= "Myproductname"
then
list = list & prod & ";"
x=x+1
end if
Next

if len(list)>0 then
list = left(list, len(list)-1)
x=x-1
else
x<0
end if

if x>0 then
Property("FOUNDOLDER") = 0
else if x<0 then
Property("FOUNDOLDER")=-1
else
Property("FOUNDOLDER") = 1
Property("INSTALLEDCODE") = list
end if
'MsgBox list
-----------------------

The last MsgBox could print right product code when I blocked the code using
Property("..")=..., otherwise I got the compile error "Variable is
undefined: Property". I use Property in this way because I had a small CA
which run VBScript with location set as "Stored directly in the custom
action", and the code it one line --
Property("MYDIR")=Property("ProgramFilesFolder") + "new\dir" --, it works
fine. What's wrong with my vb code above? I also tried to store it directly
in the custom action, and also tried to block "Option explicit" option, but
didn't work at all...

Thanks for any help,
Peter

"Phil Wilson" <phil.wilson@unisys.nospam.com> wrote in message
news:3baf76b0@news.installshield.com...
> Have you looked at a major upgrade? Iit seems to exactly what you want.
>
> http://www.installsite.org/files/iswi/Upgrading.html
>
> Typically you know what the product code would be because you shipped it.
> Otherwise, use msispy from the WI SDK, or use a script like this on a
system
> with that old product installed:
>
> Option Explicit
> Public installer, prod, a, fso
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set a = fso.CreateTextFile("components.txt", True)
>
> ' Connect to Windows Installer object
> Set installer = CreateObject("WindowsInstaller.Installer")
> a.writeline ("Products")
> For Each prod In installer.products
> a.writeline (prod & " " & installer.productinfo (prod,
> "InstalledProductName") & " " & installer.productinfo (prod,
> "VersionString") )
> Next
>
> "Peter" <yabing.bi@ncr.com> wrote in message
> news:3ba91507@rpc1284.daytonoh.ncr.com...
> > Hi,
> >
> > I am working on upgrade of a product. Is there anybody who knows how can
I
> > get the product code of the installed product on a target machine? The
> scene
> > is: I want to write a CA to check the target machine for installed
product
> > (same name, but different product code), if there is one, it will get
the
> > product code and uninstall it. But how can the CA execute during the new
> > package installation, and get the installed product code (if there is
one
> > installed)?
> >
> > Thanks,
> > Peter
> >
> >
>
>