Does InstallBuilder allow integration with Microsoft IIS (Internet Information Services) web server?

Can it create a new application pool and/or virtual directories?

asked 05 Mar '12, 08:12

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%


InstallBuilder does not provide built-in actions for this purpose, however, it is easy to do this using <runProgram> action.

For Microsoft Internet Information Services 7, the appcmd.exe binary that is deployed as part of IIS can be used. The following is an example of creating an application pool and virtual directory for IIS 7:

<postInstallationActionList>
  <setInstallerVariable>
    <name>appcmd</name>
    <value>${env(SystemRoot)}\\system32\\inetsrv\\appcmd.exe</value>
  </setInstallerVariable>
  <writeFile>
    <path>${installdir}/configure_iis.bat</path>
    <text>@echo off
"${appcmd}" add apppool /name:"${iis_site_name}"
"${appcmd}" add vdir /app.name:"${iis_site_name}/" /path:/${iis_virtualdir_name} /physicalPath:"${iis_virtualdir}"
</text>
  </writeFile>
  <runProgram>
    <program>${installdir}/configure_iis.bat</program>
    <programArguments></programArguments>
  </runProgram>
  <deleteFile>
    <path>${installdir}/configure_iis.bat</path>
  </deleteFile>
</postInstallationActionList>

The script creates an application pool and virtual directory, where:

${appcmd} refers to the appcmd.exe path that is set in first action. ${iis_site_name} could be 'Default Web Site' or any other web site. ${iis_virtualdir_name} would be the virtual directory ${iis_virtualdir} would be the physical path.

Additional information about appcmd.exe can be found in the following Microsoft documentation:

Create a Virtual Directory (IIS 7)

Appcmd.exe documentation

Microsoft Internet Information Services 6 does not provide equivalent of appcmd.exe binary. However, it is possible to interact with it using VBS scripts. For example the script below deletes a virtual directory in IIS 6:

  <writeFile path="${installdir}\\${iis_virtualdir_script}">
    <text>On Error Resume Next
Set IISObject = GetObject("IIS://LocalHost/W3SVC/1/ROOT/${iis_virtualdir_name}")
IISObject.AppDelete
If (Err.Number &lt;> 0) Then
  WScript.Quit (Err.Number)
End If

Set IISObject = GetObject("IIS://LocalHost/W3SVC/1/ROOT")
IIsObject.Delete "IIsWebVirtualDir", "${iis_virtualdir_name}"
If (Err.Number &lt;> 0) Then
  Wscript.Quit (Err.Number)
End If

</text>
  </writeFile>
  <runProgram>
    <program>cscript</program>
    <programArguments>"${installdir}/${iis_virtualdir_script}"</programArguments>
    <showMessageOnError>0</showMessageOnError>
    <abortOnError>0</abortOnError>
  </runProgram>

Additional information about automating IIS 6 can be found below:

HOWTO: Create Custom Application Pool from Commandline

Using the Adsutil.vbs Administration Script (IIS 6.0)

link

answered 05 Mar '12, 08:19

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×4
×1

Asked: 05 Mar '12, 08:12

Seen: 1,977 times

Last updated: 05 Mar '12, 08:19