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

Setting a Property in a CA


1 reply to this topic

Scott Mayham

Scott Mayham
  • Full Members
  • 54 posts

Posted 29 April 2011 - 14:22

Folks,

(This topic is strictly MSI in nature - InstallShield is not being used in this project).

I have a small set of LaunchConditions, and I am trying to add another. I need to detect whether the user running the MSI has access to the SharePoint Server "Farm" which is to host the app I'm installing, and use the results of that determination in a LaunchConditions item.

So, I wrote a small vbscript (type 6) Custom Action which is run very early in the InstallUISequence, before the LaunchCondition action. It tries to instantiate a certain object which will succeed only if the required access is present. It then adds a Property (CANACCESSFARM) to the Property table, setting its value to "True" or "False" depending on the instantiation test. Finally, I have a LaunchCondition based on this Property being set to "True".

However, the LaunchCondition always succeeds, even when the required access is not present. Moreover, the verbose log makes it clear that the CA is run. However, the Property summary which appears near the end of the log shows that the CANACCESSFARM Property is never added to the Property table.

Here's the code. What am I doing wrong?


Option explicit
On Error Resume Next

Dim oFarm
Dim sql
Dim view
Dim record

Set oFarm = CreateObject ("SPFarm.Local")

if (oFarm = Nothing) then
sql = "INSERT INTO `Property` (`Property`, `Value`) VALUES ('CANACCESSFARM', 'False')"
else
oFarm = Nothing
sql = "INSERT INTO `Property` (`Property`, `Value`) VALUES ('CANACCESSFARM', 'True')"
end if

view = database.OpenView(sql)
record = installer.CreateRecord(2)
view.Execute(record)
view.Close()


Thanks,
ScottM
T. Scott Mayham
Senior Software Engineer - Innovations
678 319 8384
Scott.Mayham@Infor.com

Scott Mayham

Scott Mayham
  • Full Members
  • 54 posts

Posted 29 April 2011 - 16:01

False alarm - I figured it out (see code below).

I don't need to use the OpenView SQL stuff at all. instead I can set the property directly using the Property() function. It works perfectly now.

One thing which is frustrating is the lack of good sample CA code in VbScript or Jscript. Yeah, the Windows SDK contains a bunch of scripts for manipulating an MSI database from the outside, but there seems to be no examples from MS which illustrate how to do things from inside the installer while it is running. For example, if one writes code to error-check what he's doing, how does one send an error message to the log currently being used by the MSI?

If there is such a stash of code, I'd sure like to find out about it. Most of us learn how to do something by observing what has worked well for others.

Regards,
ScottM


If SPFarm.Local Is Nothing Then
Property("CANACCESSFARM") = "False"
Else
Set oFarm = Nothing
Property("CANACCESSFARM") = "True"
End If

T. Scott Mayham
Senior Software Engineer - Innovations
678 319 8384
Scott.Mayham@Infor.com