Problem with custom action - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

RMcLeod
Posts: 4
Joined: Thu Jan 07, 2010 1:13 pm

Problem with custom action

I've written a VBScript that connects to a database and does a simple select query to see if a row exists, when run from the command line it works perfectly. However I'm struggling to get it to do exactly what I want without error in Advanced Installer.

Basically I need to pass it the required details to connect to the database, which I can do no problem if I set it up under InstallExecuteSequence -> Install. However if I set it up there trying to update a property in Advanced Installer with Session.Property("SOME_PROP"] = "Whatever" won't work, I'm assuming this is because it's too late in the sequence to update properties.

The next thing I tried was to set it up under UI Custom Actions and add it as a DoAction for one of my dialogs. The way I have done this is to setup the code of the VBScript as a function and then on the Custom Action Properties window added the function name with properties as arguments e.g. SomeFunction([SOME_PROP_1], [SOME_PROP_2]). However when I run the installer it fails at the DoAction. With the following in the log:

Code: Select all

MSI (c) (EC:C8) [11:54:24:687]: Doing action: adminId.vbs
Action 11:54:24: adminId.vbs. 
Action start 11:54:24: adminId.vbs.
Action ended 11:54:24: adminId.vbs. Return value 3.
DEBUG: Error 2896:  Executing action adminId.vbs failed.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Problem with custom action

Hi,
if I set it up there trying to update a property in Advanced Installer with Session.Property("SOME_PROP"] = "Whatever" won't work, I'm assuming this is because it's too late in the sequence to update properties.
Please note that only "Immediate" custom actions have access to installer properties. Custom actions created under "InstallExecuteSequence" -> "Install" are "Deferred" by default. You can change this option through the Custom Action Properties pane.
The way I have done this is to setup the code of the VBScript as a function and then on the Custom Action Properties window added the function name with properties as arguments e.g. SomeFunction([SOME_PROP_1], [SOME_PROP_2])
Please note that VBScript functions do not support parameters when used in Windows Installer custom actions. The correct approach is to retrieve information from installer properties by using "Session.Property" in your VBScript code. Also, the "Function Name" field in the "Custom Action Properties" pane should be set to the function name without parentheses or parameters:

Code: Select all

SomeFunction
Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
RMcLeod
Posts: 4
Joined: Thu Jan 07, 2010 1:13 pm

Re: Problem with custom action

Thanks for this. I have now kept the script as a DoAction, however I have removed the function from the script and also from the Function Name on the Custom Action screen and access the installer properties with Session.Property. This is still failing to run however.

Here is the script

Code: Select all

Dim Connection
Dim ConnectionString
Dim Recordset
Dim SQL
Dim file
Dim tokens

SQL = "SELECT id FROM MyTable WHERE username = '" & Session.Property("SOME_USER") & "'"

ConnString = "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=" & Session.Property("SERVER_PROP") & "; DATABASE=" & Session.Property("DATABASE_PROP") & "; " &_
"UID=" & Session.Property("USERNAME_PROP") & ";PASSWORD=" & Session.Property("PASSWORD_PROP") & "; OPTION=3"

Set Connection = CreateObject("ADODB.Connection")
Set Recordset = CreateObject("ADODB.Recordset")

Connection.Open ConnString

Recordset.Open SQL,Connection

If Recordset.EOF Then
Session.Property("ADMIN_ID") = "NULL"
Else
Do While NOT Recordset.Eof   
Session.Property("ADMIN_ID") = Recordset("id")  
Recordset.MoveNext    
Loop
End If

Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
Hopefully you can see what I'm trying to achieve and will be able to point me in the right direction if I'm going about this in the wrong way.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Problem with custom action

Hi,

Is the custom action set as "Immediate"? If so, can you please send us the .AIP (project) file you are using and a verbose log of the installation to support at advancedinstaller dot com so we can investigate them?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
RMcLeod
Posts: 4
Joined: Thu Jan 07, 2010 1:13 pm

Re: Problem with custom action

Hi,

Do I need to include the installation files as well? If so I can't send these as they contain Intellectual Property, is there any way around this?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Problem with custom action

Hi,

No, we need only the project file so we can see the settings you are using. If you cannot send it, please send us a sample test case which reproduces this behavior.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
RMcLeod
Posts: 4
Joined: Thu Jan 07, 2010 1:13 pm

Re: Problem with custom action

Okay thanks, I have sent the .aip and log file.

Return to “Common Problems”