cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ruskin_dantra
Level 3

Showing User a list of Application Pools

Hi,
I have InstallShield 2010 professional edition and was hoping that I could allow the end-user to see a list of already existing Application Pools within IIS and then from there they could potentially select one application pool onto which they would want to install the web application on. Currently I cannot find any way of doing this.

I have found solutions which allow me to create an application pool etc but none to show the user a list of these.

I want something similar to what the Visual Studio Installer does by showing users a list of application pools when it creates a web setup project.

Any help will be appreciated.

Regards,
Ruskin
Labels (1)
0 Kudos
(6) Replies
cbragg
Level 7

I did something similar myself but I got the user to select a website instead. I ran this custom action script that i created before displaying the dialog with the drop down combobox (call it from the next button of the previous dialog so a user can press back, create another app pool and press next to have the list refresh)

Here's the script I used:


Option Explicit
On Error Resume Next

Dim objIIS: Set objIIS = GetObject("IIS://localhost/W3SVC")
Dim objWebsite
Dim intCounter: intCounter = 0
For Each objWebsite In objIIS
If objWebsite.Class = "IIsWebServer" Then
intCounter = intCounter + 1
if intCounter = 1 Then Session.Property("SELECTEDWEBSITE") = objWebsite.ServerComment
Dim objQuery: Set objQuery = Database.OpenView("INSERT INTO `ComboBox` " & _
"(`Property`,`Order`,`Value`,`Text`) VALUES('SELECTEDWEBSITE'," & _
intCounter & ",'" & objWebsite.ServerComment & "','" & objWebsite.ServerComment & _
"') temporary")
objQuery.Execute
End If
Next



Note that it has to write temporarily to the tables at runtime. The user selects the entry in the combobox you can reference that combobox property elsewhere in the package. All you need to do now is to work out the code for application pools instead of websites. A bit of googling should do it but I think you want something like this:

Option Explicit
On Error Resume Next

Dim objIIS: Set objIIS = GetObject("IIS://localhost/W3SVC/AppPools")
Dim objWebsite
Dim intCounter: intCounter = 0
For Each objAppPool In objIIS
intCounter = intCounter + 1
if intCounter = 1 Then Session.Property("SELECTEDAPPPOOL") = objAppPool.Name
Dim objQuery: Set objQuery = Database.OpenView("INSERT INTO `ComboBox` " & _
"(`Property`,`Order`,`Value`,`Text`) VALUES('SELECTEDAPPPOOL'," & _
intCounter & ",'" & objAppPool.Name & "','" & objAppPool.Name & _
"') temporary")
objQuery.Execute
End If
Next
0 Kudos
ruskin_dantra
Level 3

Hi Cbragg,
To start simple I simply tried a simple edit box entry for the default web site to mactch your example but my webservice didn't install in that site. I have created that new web site on my IIS, anything else I need to do?

Regards,
Ruskin
0 Kudos
ruskin_dantra
Level 3

I tried the following code to populate websites but the combobox is still empty 😞

Option Explicit
On Error Resume Next

Dim objIIS: Set objIIS = GetObject("IIS://localhost/W3SVC")

Dim objWebsite
Dim intCounter: intCounter = 0

For Each objWebsite In objIIS
If objWebsite.Class = "IIsWebServer" Then
intCounter = intCounter + 1
if intCounter = 1 Then
Session.Property("SELECTEDWEBSITE") = objWebsite.ServerComment

Dim objQuery: Set objQuery = Database.OpenView("INSERT INTO 'WebSiteComboBox' " & _
"('Property', 'Order','Value','Text') VALUES('SELECTEDWEBSITE'," & _
intCounter & ",'" & objWebsite.ServerComment & "','" & objWebsite.ServerComment & _
"') temporary")
objQuery.Execute
End If
End If
Next
0 Kudos
ruskin_dantra
Level 3

0 Kudos
cbragg
Level 7

Ok firstly i'll reply to the combo box being empty:

Has your combobox been associated with the property SELECTEDWEBSITE because this is the property you are populating into the combobox table at runtime. Secondly you need to run this script from the next button of the previous dialog (doaction)

Also I noticed your script had a double end if at the end of your script and my original post didn't so you may want to copy it again.

As for the installing to that website, this is where it gets tricky, because if the site id is different it will create a new site or if the port is different it will install to the same site but change the port it was set at. So you need to run this script during the install execute sequence before costfinalize to convert the user selected website into site id and port numbers and to get the folder that the website is installed into



Option Explicit
On Error Resume Next

Dim objIIS: Set objIIS = GetObject("IIS://localhost/W3SVC")
Dim objWebsite, strBinding, objSpecifiedSite
Dim intCounter: intCounter = 0
Dim RegEx : Set RegEx = New RegExp
RegEx.Pattern = "^.*:(.+):.*$"
RegEx.IgnoreCase = True


For Each objWebsite In objIIS
If objWebsite.Class = "IIsWebServer" Then
If objWebsite.ServerComment = Session.Property("SELECTEDWEBSITE") Then
Session.Property("SITEID") = objWebsite.Name
Set objSpecifiedSite = GetObject(objWebsite.AdsPath & "/Root")
Session.Property("WEBSITEPATH") = objSpecifiedSite.Path
For Each strBinding In objWebsite.ServerBindings
Session.Property("SITEPORT") = RegEx.Execute(strBinding).Item(0).Submatches.Item(0)
Exit For
Next
End If
End If
Next


Then you need to create a new webisite in InstallShield, called anything you like because it'll get redirected at runtime anyway. But set the site id to [SITEID] and set the port to [SITEPORT]. Both of these were generated by the above script.

Now you can get even more clever and instead of installing your virtual directory to the generic location inetpub\wwwroot\ you can install to the same path that the administrator used when he set up the website. All you need to do is use a set directory property and set installdir or whatever your website directory is to something like [WEBSITEPATH]MyVirtualDirectory. The WEBSITEPATH property is generated from the above script

If you want to use lockpermissions for your folder for the anonymous logon account for that machine then you can obtain that information from this script:

Option Explicit
Dim objIIS: Set objIIS = getObject("IIS://LocalHost/W3SVC")
Session.Property("IUSR") = objIIS.Get("AnonymousUserName")

The lockpermissions table can then refer to a blank domain name and the user can be set to the property IUSR


It's all quite complicated to do in Installshield really because that only decently supports creating new sites rather than using what's already there


As for your application pool, it's usually safer to create your own one, that way you can tinker with any settings like application pool identities and ASP.NET versions etc wihout messing up another site also using that application pool
0 Kudos
Kelter
Level 10

I am doing something similar, but less dynamic. I want to install a web app to the web site with a specific name, and in my IIS settings in IS I i put the web app under that specific web site, but at install time, it installs under Default Web Site instead. This appears to be a fault of the IS IISInstall logic which installs to the first site it finds that matches the port. so obviously it's ignoring the Site name when it selects where to put the web app. i need this to work whether or not the site is already set up.

Any thoughts?
0 Kudos