Populating a user selection control at runtime - InstallShield...
Hi all,
This is kind of an offshoot of a recent IS post of mine. Since InstallShield doesn't appear to handle installing a web application to an existing web site, I have to work around it somehow.
What I would like to do is create a custom action .dll that will query the web site names on a target machine. I would then like to take this return and populate a UI dialog control with the list for user choice. Does anyone know how I can attack populating these choices in the dialog at runtime, if possible at all. I'm not to concerned with the mechanism of grabbing the web site names, but rather the broader concept of just populating a control with list returned from a .dll custom action.
Also, can such a custom action be written in VB.NET or do I have to or should I use C.
Maybe there is a Windows Installer property that is already being populated with this information. ?? That would be very sweet.
Any help with this would be greatly appreciated.
This is kind of an offshoot of a recent IS post of mine. Since InstallShield doesn't appear to handle installing a web application to an existing web site, I have to work around it somehow.
What I would like to do is create a custom action .dll that will query the web site names on a target machine. I would then like to take this return and populate a UI dialog control with the list for user choice. Does anyone know how I can attack populating these choices in the dialog at runtime, if possible at all. I'm not to concerned with the mechanism of grabbing the web site names, but rather the broader concept of just populating a control with list returned from a .dll custom action.
Also, can such a custom action be written in VB.NET or do I have to or should I use C.
Maybe there is a Windows Installer property that is already being populated with this information. ?? That would be very sweet.
Any help with this would be greatly appreciated.
0 Comments
[ + ] Show comments
Answers (16)
Please log in to answer
Posted by:
Superfreak3
13 years ago
Posted by:
jmcfadyen
13 years ago
Posted by:
AngelD
13 years ago
Posted by:
jmcfadyen
13 years ago
most people tend to create a new table by the name of ComboBox and load the results of your IIS metabase lookup into the ComboBox table as a temporary store.
I will have samples of the entire process in vbs somewhere.
My advice would be to do it in C++. If you download the WiX source files and crack open the WiXCA project you will have plenty of samples of how to write the code in C++
They typically follow a pattern of
schedule
execute
commit / rollback
Where schedule will typically handle the CAD transfer across to the deferred phase etc. (your case you wont need the schedule)
But it will at least describe how to read / write the data into various locations.
As far the metabase loading goes you do not commit the MSI that is written and as such the combobox table will not be updated for the next use. It acts in a temporary storage capacity.
I will try to dig up the code tonight for the metabase etc in vbs.
I will have samples of the entire process in vbs somewhere.
My advice would be to do it in C++. If you download the WiX source files and crack open the WiXCA project you will have plenty of samples of how to write the code in C++
They typically follow a pattern of
schedule
execute
commit / rollback
Where schedule will typically handle the CAD transfer across to the deferred phase etc. (your case you wont need the schedule)
But it will at least describe how to read / write the data into various locations.
As far the metabase loading goes you do not commit the MSI that is written and as such the combobox table will not be updated for the next use. It acts in a temporary storage capacity.
I will try to dig up the code tonight for the metabase etc in vbs.
Posted by:
jmcfadyen
13 years ago
I did a quick google on the combobox method and found these for you.
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Website-selection-from-combo-box-creates-virtual-directory-always-in-the-default-website-td700890.html
http://stackoverflow.com/questions/5791457/custom-actions-for-iis-installation-comboxbox-empty-issue
I tend to do all my web based delivery via WiX I find its much easier than IS.
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Website-selection-from-combo-box-creates-virtual-directory-always-in-the-default-website-td700890.html
http://stackoverflow.com/questions/5791457/custom-actions-for-iis-installation-comboxbox-empty-issue
I tend to do all my web based delivery via WiX I find its much easier than IS.
Posted by:
Superfreak3
13 years ago
I'm actually using the WiX VB.NET Custom Action project type to code the custom action. What I'm currently trying to do is just use a dummy array as source for the ListBox table. I'll go back later and cycle through the web sites later (baby steps [:D]). However, my current code is failing with a 1723 error and I can't really debug it. As soon as it hits the action it blows out. Here is the code if anyone can see a problem....
Public Shared Function GetSites(ByVal session As Session) As ActionResult
Dim recListBox As Record
Dim intIndex As Integer
Dim sqlView As View
Dim strTest As String() = {"One", "Two", "Three"}
Try
session.Log("Populating Web Stite List...")
sqlView = session.Database.OpenView("SELECT * FROM 'ListBox'")
sqlView.Execute()
For intIndex = LBound(strTest) To UBound(strTest)
recListBox = session.Database.CreateRecord(4)
recListBox.SetString(1, "WEBSITECHOICES2")
recListBox.SetInteger(2, intIndex + 1)
recListBox.SetString(3, strTest(intIndex))
recListBox.SetString(4, strTest(intIndex))
sqlView.Modify(ViewModifyMode.InsertTemporary, recListBox)
Next
sqlView.Close()
session.Log("Web Site List populated successfully.")
'Everything good...
Return (ActionResult.Success)
Catch ex As Exception
session.Log("Error: There was a problem populating web site list.")
Return (ActionResult.Failure)
End Try
End Function
Posted by:
Superfreak3
13 years ago
I think I may have found some of my problem…
I didn’t have <CustomAction()> _ above the function I send earlier. Also, in my query I had ‘ListBox’ instead of `ListBox`.
So, after making the above changes I can see my array element values in the list box.
Now it’s off to cycling through the web sites to see if I can get that to work. Once all that is up and running, I may inquire as to the high level steps of creating a virtual directory/application installation in WiX. After I get these UI changes squared away my plan is to dump the files and do all of the messy IIS setup (to handle IIS 6 & 7) in a custom action at the end of the install. Is that basically the high level goals of doing this with WiX?
Thanks for the help so far!!
I didn’t have <CustomAction()> _ above the function I send earlier. Also, in my query I had ‘ListBox’ instead of `ListBox`.
So, after making the above changes I can see my array element values in the list box.
Now it’s off to cycling through the web sites to see if I can get that to work. Once all that is up and running, I may inquire as to the high level steps of creating a virtual directory/application installation in WiX. After I get these UI changes squared away my plan is to dump the files and do all of the messy IIS setup (to handle IIS 6 & 7) in a custom action at the end of the install. Is that basically the high level goals of doing this with WiX?
Thanks for the help so far!!
Posted by:
Superfreak3
13 years ago
Posted by:
Superfreak3
13 years ago
Trying to code the site name grab now, but whatever I try I receive an “Unknown error (0x80005000).
Here’s the most recent code I’ve tried….
I’ve created my setup as an .exe requiring Admin rights because I saw that this stuff may need that requirement.
Here’s the most recent code I’ve tried….
Try
Dim deIIS As New DirectoryEntry("IIS://localhost/W3SVC")
deIIS = New DirectoryEntry("IIS://localhost/W3SVC")
For Each site As DirectoryEntry In deIIS.Children
If site.SchemaClassName = "IIsWebServer" Then
MsgBox(site.Name)
MsgBox(site.Properties("ServerComment").Value.ToString)
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
I’ve created my setup as an .exe requiring Admin rights because I saw that this stuff may need that requirement.
Posted by:
AngelD
13 years ago
Posted by:
AngelD
13 years ago
Posted by:
Superfreak3
13 years ago
Posted by:
Superfreak3
13 years ago
Posted by:
AngelD
13 years ago
ORIGINAL: Superfreak3
Thanks AngelD.
The CA is currently executed from the Next button of the Welcome dialog just for testing. I don't know if this will be the final resting place for it or not. It is synchronous/immediate.
Matt,
I've read that others has problem with the session.log method while executing the CA with DoAction which is used during Dialog "clicking" ;)
So see if you can use the C++ code instead or a wrapper for C++ API calls; http://stackoverflow.com/questions/1682462/wix-customaction-session-log-not-working
Posted by:
Superfreak3
13 years ago
I've got all the code working, finally!! My custom action now handles the grabbing of sites for the ListBox control for IIS 6 & 7. One little thing I did notice deals with the situation where only one web site is found. If this is the case, I set the property associated with the ListBox to the name of the lone site. When I do this traversing the IIS 7 code, the lone website does appear in the ListBox and is highlighted. However, when I test on IIS 6, the name is not highlighted in the ListBox. I do however know that the property has been set properly becasue I am able to get to the next dialog. I conditionally check that a site was selected. This however is a small issue that I can live with I guess. I just wonder why in one instance the individual site is highlighted and not in the other case.
I will check the logging stuff by first maybe setting it to run outside of a dialog. If that doesn't work I'll hit your C++ links.
Oh and I did want to mention that your VB syntax suggestion solved my problem of the Unknown Exception. While it worked either way from a standalone .exe, it had to be written the way you suggested for it to function properly in the confines of the Custom Action. Beats me, but I'll take it! Thanks much for that!!!
After logging, I'll just use install my files with InstallShield and do all the IIS configuration and other config file edits through Deferred CA's.
Thanks for the help so far!!!
I will check the logging stuff by first maybe setting it to run outside of a dialog. If that doesn't work I'll hit your C++ links.
Oh and I did want to mention that your VB syntax suggestion solved my problem of the Unknown Exception. While it worked either way from a standalone .exe, it had to be written the way you suggested for it to function properly in the confines of the Custom Action. Beats me, but I'll take it! Thanks much for that!!!
After logging, I'll just use install my files with InstallShield and do all the IIS configuration and other config file edits through Deferred CA's.
Thanks for the help so far!!!
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.