I am running vbscript to get an installed product code. The code is as following.
-----------------------------------
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
end if
if x>0 then
Property("FOUNDOLDER") = 0
else if x=-1 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 has only one line --
Property("MYDIR")=Property("ProgramFilesFolder") + "new\dir" --, it works
fine, i.e Property is accepted. 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...