Hello,
Is there a sample anywhere that shows how to populate a combobox using a custom action...preferably a VBScript? I have looked all over and can't seem to find anything on that subject.
What I am trying to do is query IIS for a list of the WebSites currently on the machine and populate them in a combobox for the user to select. From what I have gathered so far, in order to do this, I would need a script like this (found from a WiX tutorial site):
Const ERROR_SUCCESS = 0
Const ERROR_INSTALL_FAILURE = 1603
Const msiViewModifyInsertTemporary = 7
Function GetSites()
Dim objIIS, oView, oSite, oServer, oReccombo
Dim r
On Error Resume Next
Set objIIS = GetObject("IIS://localhost/W3SVC")
If Err.Number <> 0 Then
MsgBox "Unable to open IIS W3SVC Root object - " & _
"please ensure that IIS is running" & vbCrLf & _
" - Error Details: " & Err.Description & " [Number:" & _
Hex(Err.Number) & "]", vbCritical, "Error"
GetSites = ERROR_INSTALL_FAILURE
Exit Function
Else
' open and execute a view to the ListBox table
Set oView = Session.Database.OpenView("SELECT * FROM `ComboBox`")
oView.Execute
r = 0
For Each oSite in objIIS
r = r + 1
If oSite.Class = "IIsWebServer" Then
Set oServer=GetObject(oSite.ADsPath)
' ComboBox record fields are Property, Order, Value, Text
Set oReccombo = Session.Installer.CreateRecord(4)
oReccombo.StringData(1) = "CLIENTSITE"
oReccombo.IntegerData(2) = r
oReccombo.StringData(3) = oSite.Name
oReccombo.StringData(4) = oServer.Get("ServerComment")
oView.Modify msiViewModifyInsertTemporary, oReccombo
Set oReccombo = Session.Installer.CreateRecord(4)
oReccombo.StringData(1) = "ADMINSITE"
oReccombo.IntegerData(2) = r
oReccombo.StringData(3) = oSite.Name
oReccombo.StringData(4) = oServer.Get("ServerComment")
oView.Modify msiViewModifyInsertTemporary, oReccombo
wscript.echo oServer.Get("ServerComment")
End If
Next
oView.Close
' return success to MSI
GetSites = ERROR_SUCCESS
End If
' clean up
Set objIIS = Nothing
Set oView = Nothing
End Function
This would populate the record ADMINSITE with the list of available websites. This functionality appears to be working ok. What I can't figure out is how to wire this to SUF. If I go into the dialog editor, and then to edit the .xml, I have tried many different variations of this:
<Control Id="AdmSiteCombo" Type="ComboBox" X="14" Y="31" Width="200" Height="17" Property="ADMINSITE" Text="Test" ComboList="yes" >
<ComboBox Property="ADMINSITE">
<ListItem Value="Test"/>
</ComboBox>
I have tried with and without list values, I have tried setting the property up ahead of time, not having the property at all, etc. No matter what I do, the combobox will show up empty, or not with the values that are being returned from my script.
However, I have discovered on important thing (may be a bug?) is that you need to add a "dummy" combobox somewhere in your UI so that the ComboBox table is created in the .msi. If this does not happen, then the SELECT statement above will fail.
Any ideas or examples would be greatly appreciated.
Is there a sample anywhere that shows how to populate a combobox using a custom action...preferably a VBScript? I have looked all over and can't seem to find anything on that subject.
What I am trying to do is query IIS for a list of the WebSites currently on the machine and populate them in a combobox for the user to select. From what I have gathered so far, in order to do this, I would need a script like this (found from a WiX tutorial site):
Const ERROR_SUCCESS = 0
Const ERROR_INSTALL_FAILURE = 1603
Const msiViewModifyInsertTemporary = 7
Function GetSites()
Dim objIIS, oView, oSite, oServer, oReccombo
Dim r
On Error Resume Next
Set objIIS = GetObject("IIS://localhost/W3SVC")
If Err.Number <> 0 Then
MsgBox "Unable to open IIS W3SVC Root object - " & _
"please ensure that IIS is running" & vbCrLf & _
" - Error Details: " & Err.Description & " [Number:" & _
Hex(Err.Number) & "]", vbCritical, "Error"
GetSites = ERROR_INSTALL_FAILURE
Exit Function
Else
' open and execute a view to the ListBox table
Set oView = Session.Database.OpenView("SELECT * FROM `ComboBox`")
oView.Execute
r = 0
For Each oSite in objIIS
r = r + 1
If oSite.Class = "IIsWebServer" Then
Set oServer=GetObject(oSite.ADsPath)
' ComboBox record fields are Property, Order, Value, Text
Set oReccombo = Session.Installer.CreateRecord(4)
oReccombo.StringData(1) = "CLIENTSITE"
oReccombo.IntegerData(2) = r
oReccombo.StringData(3) = oSite.Name
oReccombo.StringData(4) = oServer.Get("ServerComment")
oView.Modify msiViewModifyInsertTemporary, oReccombo
Set oReccombo = Session.Installer.CreateRecord(4)
oReccombo.StringData(1) = "ADMINSITE"
oReccombo.IntegerData(2) = r
oReccombo.StringData(3) = oSite.Name
oReccombo.StringData(4) = oServer.Get("ServerComment")
oView.Modify msiViewModifyInsertTemporary, oReccombo
wscript.echo oServer.Get("ServerComment")
End If
Next
oView.Close
' return success to MSI
GetSites = ERROR_SUCCESS
End If
' clean up
Set objIIS = Nothing
Set oView = Nothing
End Function
This would populate the record ADMINSITE with the list of available websites. This functionality appears to be working ok. What I can't figure out is how to wire this to SUF. If I go into the dialog editor, and then to edit the .xml, I have tried many different variations of this:
<Control Id="AdmSiteCombo" Type="ComboBox" X="14" Y="31" Width="200" Height="17" Property="ADMINSITE" Text="Test" ComboList="yes" >
<ComboBox Property="ADMINSITE">
<ListItem Value="Test"/>
</ComboBox>
I have tried with and without list values, I have tried setting the property up ahead of time, not having the property at all, etc. No matter what I do, the combobox will show up empty, or not with the values that are being returned from my script.
However, I have discovered on important thing (may be a bug?) is that you need to add a "dummy" combobox somewhere in your UI so that the ComboBox table is created in the .msi. If this does not happen, then the SELECT statement above will fail.
Any ideas or examples would be greatly appreciated.
Comment