How can InstallBuilder be used to create IIS application pools and virtual directories?



1 comment

  • Avatar

    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:

        <text>@echo off
    "${appcmd}" add apppool /name:"${iis_site_name}"
    "${appcmd}" add vdir /"${iis_site_name}/" /path:/${iis_virtualdir_name} /physicalPath:"${iis_virtualdir}"

    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}")
    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

    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)

Please sign in to leave a comment.