cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jchristman
Level 8

vbscript combo box

I am trying to find a way to list all local installed IIS websites to a combobox on a custom dialog using a vbscript. I think I have the script correct but I am not for sure on how to setup and populate the combobox with vbscript information and when and how to call the script.
Labels (1)
0 Kudos
(13) Replies
jedimaster_mark
Level 7

You'll want to call the script as a custom action, obviously. You should sequence it anywhere before the dialog in which you want the combo box to display. Since you've already managed to enumerate the sites, the piece you'll need to know is this. To get it to display, you'll need to something like this:

Dim MsiDb
Dim MsiInstall
Dim MsiRecord
Dim MsiView

Set MsiDb = Session.Database
Set MsiInstall = Session.Installer
Set MsiView = MsiDb.OpenView("SELECT * FROM ComboBox")
Set MsiRecord = MsiInstall.CreateRecord(4)
MsiRecord.StringData(1) =
MsiRecord.IntegerData(2) =
MsiRecord.StringData(3) =
MsiRecord.StringData(4) =
Call MsiView.Execute(MsiRecord)
Call MsiView.Modify (7, MsiRecord)
Call MsiView.Close

And you'll want to iterate through the steps to populate the table once for each website your script finds, so you'll probably need to make use of a Count property or something similar on the IIS object, and use UBound on that value.
0 Kudos
jchristman
Level 8

thank you this worked great, Here is the code I used to get the list.


Dim objView
Dim objDB
Dim objInstaller
Dim objRecord
Dim objW3SVC, objIisWebSite
Dim lngOrder

Set objDB = Session.Database
Set objInstaller = Session.Installer
Set objView = objDB.OpenView("select * from ComboBox")
' enumerate webservers on localhost and populate ComboBox table
Set objW3SVC = GetObject("IIS://localhost/W3SVC")
lngOrder = 1
For Each objIisWebSite In objW3SVC
If objIisWebSite.Class = "IIsWebServer" Then
If LCase(objIisWebSite.ServerComment) <> "administration web site" Then
' add site name to ComboBox table (which is used by our dialog ComboBox)
Set objRecord = objInstaller.CreateRecord(4)
objRecord.StringData(1) = "SITELIST" ' property name
objRecord.IntegerData(2) = lngOrder ' order
objRecord.StringData(3) = objIisWebSite.Name ' value
objRecord.StringData(4) = objIisWebSite.ServerComment ' text
' now add the record to the table
Call objView.Execute(objRecord)
Call objView.Modify(7, objRecord) ' (7 = msiViewModifyInsertTemporary)
lngOrder = lngOrder + 1
End If
End If
Next
Call objView.Close


Now My next major thought I would like to display the selected sites information underneath the list. so on site select information populates text areas under the drop down displaying site information.
0 Kudos
jedimaster_mark
Level 7

This is a good deal trickier. It's easy to obtain the info you want, and of course you can concatenate these values into strings all you want. The trick is that the dialog itself gets its display values on loading. There is supposed to be a way to display this information dynamically, but I've never gotten it to work. What I find easiest is to create two identical dialogs, except for the controls on the object you want to control the "dynamic information" with. Then you associate a property change with that control, as well as a NewDialog control to open the identical dialog. Only now, since you've populated a dialog in between, the second dialog opens displaying the correct information.

Of course it's a hack, but I've had the best results with this.
0 Kudos
jchristman
Level 8

ok, I am learning as I go here so forgive all the questions. Could you please eliberate more on the property change and how I would do it.

Is this sort of what you mentioning to do. write a script of function in setup.rul and get the selected site then set all the properties using a doaction and have it run another custom action on the next button. If so could you provide a simple sample function.

I was also wondering about how I could add the more site information like the site port,ip,sitenumber and url

all of your help is greatly appreaciated.
0 Kudos
jedimaster_mark
Level 7

Now I am confused. Why do you have a setup.rul file? That would indicate InstallScript. InstallScript, however, wouldn't make use of MSI tables, so the previous code sample I gave you wouldn't work. Unless you're trying an InstallScript custom action, which is most likely a bad idea. Unless there's a specific reason you need to do your CA in InstallScript, 9 times out of 10 you're better off doing them in VBScript, C++, or the like.
0 Kudos
jchristman
Level 8

Sorry, no there is now reason to use install script for this. I was going to create a custom action using one if that was possible to handle this scenerio but thank you for the warning I will not I will stick with vbscript then. Could you please point me in the right direction to accomplishimg the task of populating some text field properties on a cloned dialog of the IIS listing dialog so it will display site information.
0 Kudos
jedimaster_mark
Level 7

On second thought... it would be a lot easier for you to not display this in a text box. Unless there's a reason you wouldn't want to do this, there's a much easier way. You'll note that one of the columns in the combo box table is called Text. This is the text that is displayed in the combo box. In the script where you enumerate sites, you could simply grab the info you want from the IIS properties, and place it all in a string that you then place in the text column. The information displayed to the user would be the useful human-readable information you want them to be able to see, but on the back end, you can fill the property they select with whatever data you need for your actions to work.
0 Kudos
jchristman
Level 8

That sounds good, i will do that, I can do the doaction on the next button and have it run a new script that would load the properties I need.

? not for sure how to get the property of the selected item in the combo box and then parse it out though or is there another way to do this.?
0 Kudos
jedimaster_mark
Level 7

It's automatic. That's how the combo box works. You specify what property it sets, and each entry has a value associated with it. Whatever the user selects, that is value your property will hold.
0 Kudos
jchristman
Level 8

Nice, I like that I was thinking I would have to parse out the index or something.

Thank you for your help. 🙂
0 Kudos
jchristman
Level 8

ok, I wrote the other script and I am trying to get the data from the property, but now I can not tell if it is my script or the way I setup the custom action or the way the dialog calls the script.

I created a custom action and set it to always execute. abscent from sequence. I then went to the dialog that displays the combo box and went to the execution of the next button and said do action "MyScript" condition 1
then newdialog the next dialog and condition 1 when testing it just sits there and does nothing any ideas on what i did wrong
0 Kudos
jchristman
Level 8

Ok, I am using my script from above and trying to use ojbIisWebSite.ServerBindings and it errors ever time. Could someone assist in helping me modify the script from above to parse out the portnumber, host, and ip address.
0 Kudos
priyankadas24
Level 2

can we run vbs using installscript?
0 Kudos