carlldev
I use a subroutine to do the actual insert:
Sub AddToComboBox(ByVal ComboProp, ByVal ComboOrder, ByVal ComboValue, ByVal
ComboText)
Dim query
Dim view
query = "INSERT INTO `ComboBox` " _
& "(`Property`, `Order`, `Value`, `Text`) " _
& "VALUES ('" & ComboProp & "', " & ComboOrder _
& ", '" & ComboValue & "', '" & ComboText & "') TEMPORARY"
'
' Creates the view object based on our query
'
set view = Session.Database.OpenView(query)
'
' Invoke the query to add the combo value
'
view.Execute
End Sub
and invoke it like so:
function InitializeWebserverCombo()
Dim ThisServer
Dim Website
dim i
dim s
Set ThisServer = GetObject("IIS://localhost/W3SVC")
i = 1
For Each Website In ThisServer
If Website.Class = "IIsWebServer" Then
call AddToComboBox("WEBSITE", i, Website.Name,
Website.ServerComment)
i = i + 1
End If
Next
End Function
Regards
Rob
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of carlldev
Sent: Wednesday, January 31, 2007 1:12 PM
To: [email protected]
Subject: [WiX-users] Adding records to MSI on the fly
(Wix3, WIN2K3)
Sorry if this is posting a duplicate, but I can't get the solutions from any
of the posts to work...
I'm trying to add the details of installed Websites to a combobox on the
fly. I can see the custom action being executed, but the records are not
being added to the table. I know this because the combobox still only has
the one value ("_DEF_").
The vbscript works too, I have tested it with msgbox's and they return the
correct values.
Can anyone help? Thanks in advance...
<!-- CUSTOM ACTIONS -->
=================================================================
The Custom action, property and binary entries in product.wxs
=================================================================
<CustomAction Id="CAGETWEBSITES" BinaryKey="GETSITESSCRIPT"
Execute="immediate" VBScriptCall="GetWebSites" Return="check" /> <Binary
Id="GETSITESSCRIPT" SourceFile="SCRIPTS.VBS" /> <Property
Id="TARGETWEBCOMBO" Value="_DEF_" />
=================================================================
The dialog with the combobox
=================================================================
<Dialog Id="ConfigureWebsiteDlg" X="50" Y="50" Width="370" Height="270"
Title="[ProductName] Setup">
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0"
Width="370"
Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Title" Type="Text" X="15" Y="6"
Width="200" Height="15"
TabSkip="yes" Transparent="yes" Text="{\WixUI_Font_Title}Configure Website"
/>
<Control Id="Description" Type="Text" X="25" Y="23"
Width="280"
Height="10" TabSkip="yes" Transparent="yes" Text="Web site configuration" />
<Control Id="lineTopDivider" Type="Line" X="0"
Y="44" Width="370"
Height="2" />
<Control Id="Description2" Type="Text" X="20" Y="60"
Width="304"
Height="25" TabSkip="yes" Text="Choose the Web Site under which to install
the Web Service. Leave blank for the Default Web Site." />
<Control Id="Description3" Type="Text" X="20" Y="84"
Width="304"
Height="33" TabSkip="yes" Text="Also, you may enter the User and Password to
be used for anonymous access to the Web Service. Leave blank to use the
default account or use the syntax domain\user or .\localuser" />
<Control Id="lblWebsite" Type="Text" X="57" Y="132"
Width="70"
Height="16" TabSkip="yes" Text="Website" />
<Control Id="cmbWebsite" Type="ComboBox" X="132"
Y="130" Width="124"
Height="16" TabSkip="no" Property="TARGETWEBCOMBO">
<ComboBox Property="TARGETWEBCOMBO">
<ListItem Text="_DEF_" Value="_DEF_"
/>
</ComboBox>
</Control>
<Control Id="lblUsername" Type="Text" X="57" Y="152"
Width="70"
Height="15" TabSkip="yes" Text="Username" />
<Control Id="txtUsername" Type="Edit" X="132"
Y="150" Width="124"
Height="15" TabSkip="no" Property="WS_BATCHNUMBERS_USER" />
<Control Id="lblPassword" Type="Text" X="57" Y="173"
Width="70"
Height="15" TabSkip="yes" Text="Password" />
<Control Id="txtPassword" Type="Edit" X="132"
Y="170" Width="124"
Height="15" TabSkip="no" Password="yes" Property="WS_BATCHNUMBERS_PASS" />
<Control Id="lineBottomDivider" Type="Line" X="0"
Y="234" Width="370"
Height="2" />
<Control Id="Back" Type="PushButton" X="180"
Y="243" Width="56"
Height="17" Text="&Back" />
<Control Id="Next" Type="PushButton" X="236"
Y="243" Width="56"
Height="17" Text="&Next" />
<Control Id="Cancel" Type="PushButton" X="304"
Y="243" Width="56"
Height="17" Text="Cancel" Cancel="yes" >
<Publish Event="SpawnDialog"
Value="CancelDlg">1</Publish>
</Control>
</Dialog>
=================================================================
SCRIPT.VBS
=================================================================
Const ERROR_SUCCESS = 0
Const ERROR_INSTALL_FAILURE = 1603
Const msiViewModifyInsert = 1
Const msiViewModifyInsertTemporary = 7
Const IDOK = 1
Function GetWebSites()
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"
GetWebSites = 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 = 1
' ITERATE THROUGH THE SITES
For Each oSite in objIIS
If oSite.Class = "IIsWebServer" Then
r = r + 1
'get the properties
description = oSite.ServerComment
For Each item in oSite.ServerBindings
strServerBinding = item
BindingArray = Split(strServerBinding, ":", -1, 1)
ipaddress = BindingArray(0)
port = BindingArray(1)
' only do it for the first item (don't know how to get
it without "for")
Exit For
Next
path = oSite.ADsPath
props = description & ";" + path & ";" & port & ";" & ip
'msgbox props
' make the first site the default
if r = 1 Then
Session.Property("TARGETWEBCOMBO") = description
End if
'
' ComboBox record fields are Property, Order, Value, Text
'
Set oReccombo = Installer.CreateRecord(4)
oReccombo.StringData(1) = "TARGETWEBCOMBO"
oReccombo.IntegerData(2) = r
oReccombo.StringData(3) = props
oReccombo.StringData(4) = description
oView.Modify msiViewModifyInsertTemporary, oReccombo
Database.Commit
End If
Next
oView.Close
'return success to MSI
GetWebSites = ERROR_SUCCESS
End If
'clean up
Set objIIS = Nothing
Set oView = Nothing
End Function
--
View this message in context:
http://www.nabble.com/Adding-records-to-MSI-on-the-fly-tf3150241.html#a87341
73
Sent from the wix-users mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users