« Previous Next »

Thread: I want to use appcmd to put <clear /> element into defaultDocument

Last post 10-29-2009 9:15 AM by brewbill03. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 10-28-2009, 4:19 PM

    I want to use appcmd to put <clear /> element into defaultDocument

    I am trying to set up the same web site on multiple computers.  I want to use a bat file to configure default documents.  The site has several applications in different virtual directories that are directly under wwwroot.  I am using appcmd like this:

      "%windir%\system32\inetsrv\appcmd.exe" set config "Default Web Site/Mytest" -section:defaultDocument /+files.[@start,value='index.php'] /commit:"Default web site"

      "%windir%\system32\inetsrv\appcmd.exe" set config "Default Web Site/Yourtest" -section:defaultDocument /+files.[@start,value='index.php'] /commit:"Default web site"

     to set up two apps.  This gives me the following web.config under wwwroot:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <location path="Mytest">
            <system.webServer>
                <defaultDocument>
                    <files>
                        <add value="start.php" />
                    </files>
                </defaultDocument>
            </system.webServer>
        </location>
        <location path="Yourtest">
            <system.webServer>
                <defaultDocument>
                    <files>
                        <add value="index.php" />
                    </files>
                </defaultDocument>
            </system.webServer>
        </location>
    </configuration>

    Slick (took me forever to get this far).  ALMOST what I'm looking for.  I could live with this but I'd like to add a clear element:

                    <files>

                        <clear />
                        <add value="index.php" />
                    </files>


    to the config.  Can anyone tell me how to do this using appcmd?

  • 10-28-2009, 5:40 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: I want to use appcmd to put <clear /> element into defaultDocument

    "%windir%\system32\inetsrv\appcmd.exe" clear config "Default Web Site/Mytest" -section:defaultDocument /commit:"Default Web Site"

    will do the <clear/> - you can then run the other command to add your default-doc.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 10-28-2009, 7:59 PM In reply to

    Re: I want to use appcmd to put <clear /> element into defaultDocument

    If you are using Windows Server 2008 R2 or Windows 7 there is a new feature that allows you to do that:

    http://blogs.iis.net/ksingla/archive/2009/03/25/new-features-in-configuration-system-and-appcmd-in-iis-7-5.aspx

    However it is not available in Win2008 other than what Anil mentions above except AFAIK has a little bit different semantics (subtle).

    Appcmd now has ability to add <clear/> tag in the collections using '~'. Command to clear <error> collection entries in httpErrors section will be following.
    appcmd set config /section:httpErrors /~

  • 10-29-2009, 9:15 AM In reply to

    Re: I want to use appcmd to put <clear /> element into defaultDocument

    Using the clear command isn't quite what I wanted.  It clears the defaultDocument list, but I want to put the <clear /> tag into the web.config.  Otherwise I still get all the inherited documents.  The ~ attribute looks like just what I want.  I'll check it as soon as I can get a test machine set up with R2.

    For machines that are not R2, removing the inherited documents is mainly just a matter of looking neater.  Functionally, the document at the top of the list is going to be what I want.

    Thanks to everyone for their help.

Page 1 of 1 (4 items)
Microsoft Communities