sramesh
Posts: 20
Joined: Sat Mar 08, 2008 8:23 pm

Call a vbscript function from UI Custom Action

Hi,

How do I call a function defined in my vbscript using the Custom Action.

I am trying to get the databases from the sqlserver and would like to populate my combobox with property DBCOMBO_PROP with the list of databases.

I tried using the new attached custom action.
Source path: C:\test\PopulateDBList.vbs
Source type : Visual basic Script (*.vbs)
Function Name: GetDatabaseNames

the Install fails when executing this custom action.
If I leave the function name blank, then the install executes the custom action but my retur code is 0. and no value shows up in my combo.

Please help.

Thanks in advance.

following is my vbscript PopulateDBList.vbs.
-------------------------

Const msiViewModifyInsertTemporary = 7
Const IDOK = 1

Function GetDatabaseNames( )

Dim srv
Dim objDB
Set srv = CreateObject("SQLDMO.SQLServer")
srv.LoginTimeout = 15
srv.Connect "shylajar3\GP10", "sa", "wstest" 'Session.Property("SELSERVER_PROP"), "sa" , Session.Property("SAPASSWORD_PROP")

Set objDB = CreateObject("SQLDMO.Database")

Set viewlist = Database.OpenView("SELECT * FROM `ComboBox` WHERE `Property` ='DBCOMBO_PROP'")
viewlist.Execute

Set reclist = viewlist.Fetch

' delete any existing records
While Not (reclist Is Nothing)
viewlist.Modify 6, reclist ' 6 = delete
Set reclist = viewlist.Fetch
Wend

viewlist.Close

' open and execute a view to the ListBox table
'Set viewlist = Database.OpenView("SELECT * FROM `ComboBox` WHERE `Property` ='DBCOMBO_PROP'")
'viewlist.Execute

r = 0
For Each objDB In srv.Databases
If objDB.SystemObject = False Then
' ListBox record fields are Property, Order, Value, Text
'Set reclist = Installer.CreateRecord(4)
r = r + 1
'reclist.StringData(1) = "DBCOMBO_PROP"
'reclist.IntegerData(2) = r
'reclist.StringData(3) = objDB.Name
'reclist.StringData(4) = objDB.Name
' insert the temporary ListBox record
'viewlist.Modify msiViewModifyInsertTemporary, reclist

SQLCmd = "INSERT INTO `ComboBox` (`Property`,`Order`,`Value`,`Text`)"
SQLCmd = SQLCmd & " VALUES ('DBCOMBO_PROP','" & r & "','" & objDB.Name & "','"
SQLCmd = SQLCmd & objDB.Name & "') TEMPORARY"
Set viewlist = Database.OpenView( SQLCmd )
viewlist.Execute
viewlist.Close
End If
Next

' return success to MSI
GetDatabaseNames = IDOK

End Function
------------------------------------
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Re: Call a vbscript function from UI Custom Action

Hi,

You can create a verbose log (using either the "Run and Log" option in AI or the command below) in order to obtain more information regarding the Custom Action failure:

Code: Select all

msiexec /I package.msi /L*V C:\package.log
If there are no VBScript compilation errors, the only way to debug your script is through MsgBox function calls.

If you still encounter problems, please send a simplified test case (AIP, VBScript and additional files required to build the project) to support at advancedinstaller dot com.

Regards,
Ionut
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”