<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>IIS / Tools / Scripts</title>
        <link>http://blog.crowe.co.nz/blog/category/21.aspx</link>
        <description>IIS / Tools / Scripts</description>
        <language>en-NZ</language>
        <copyright>Chris Crowe</copyright>
        <managingEditor>blog@crowe.co.nz</managingEditor>
        <generator>Subtext Version 1.9.4.0</generator>
        <item>
            <title>Starting and Stopping a Web Site And Application Pool</title>
            <link>http://blog.crowe.co.nz/blog/archive/2007/08/20/Starting-and-Stopping-a-Web-Site-And-Application-Pool.aspx</link>
            <description>&lt;p&gt;I had a request last week for the following:&lt;/p&gt;
&lt;table cellspacing="0" cellpadding="5" summary="" border="1"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td bgcolor="#ffff99"&gt;
            &lt;p class="MsoPlainText"&gt;I'm trying to do the following:&lt;/p&gt;
            &lt;ol&gt;
                &lt;li&gt;
                &lt;div class="MsoPlainText"&gt;Stop a IIS website&lt;/div&gt;
                &lt;/li&gt;
                &lt;li&gt;
                &lt;div class="MsoPlainText"&gt;Stop an App Pool&lt;/div&gt;
                &lt;/li&gt;
                &lt;li&gt;
                &lt;div class="MsoPlainText"&gt;Start the App Pool&lt;/div&gt;
                &lt;/li&gt;
                &lt;li&gt;
                &lt;div class="MsoPlainText"&gt;Start the Website&lt;/div&gt;
                &lt;/li&gt;
            &lt;/ol&gt;
            &lt;p class="MsoPlainText"&gt;From what I can see here, I can use the example for the "starting an application pool" for the steps 2 &amp;amp; 3.&lt;/p&gt;
            &lt;p class="MsoPlainText"&gt;I have found that you can use iisweb.vbs to do steps 1 &amp;amp; 4.&lt;/p&gt;
            &lt;p class="MsoPlainText"&gt;&lt;o:p&gt; &lt;/o:p&gt;But how link them in the order above?&lt;/p&gt;
            &lt;p class="MsoPlainText"&gt;&lt;o:p&gt; &lt;/o:p&gt;Hope you can give me some pointers &lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
 
&lt;p&gt;The following code sample in VBScript allows you to do that with the following points of interest.&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;The Default Web Site is assumed - WebSiteID = 1, you can change this to any other web site by changing the ID with the ID of the other web site. There is a script called FindWeb.VBS or you can look at the log folder name and get the web site id from that - see &lt;font face="Arial"&gt;&lt;a href="http://blog.crowe.co.nz/archive/2007/08/04/IIS-Web-Site-Identifiers.aspx"&gt;http://blog.crowe.co.nz/archive/2007/08/04/IIS-Web-Site-Identifiers.aspx&lt;/a&gt;&lt;/font&gt;&lt;/li&gt;
    &lt;li&gt;There is only 1 site using the AppPool - well not technically true, if you run this and there is more than one web site using the app pool then it will be down while the app pool restarts. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is the code, save to StopAndStartSiteAndAppPool.VBS file and then run in a CMD.EXE prompt using the following syntax:&lt;/p&gt;
&lt;p&gt;cscript StopAndStartSiteAndAppPool.VBS&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;table cellspacing="0" cellpadding="5" summary="" border="1"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td bgcolor="#ffff99"&gt;
            &lt;p&gt;Option Explicit &lt;/p&gt;
            &lt;p&gt;Dim WebSiteID, objWebSite, ObjAppPool &lt;/p&gt;
            &lt;p&gt;WebSiteID = "1" &lt;br /&gt;
            Set objWebSite = GetObject("IIS://localhost/W3SVC/" &amp;amp; WebSiteID) &lt;br /&gt;
            WScript.Echo "Stopping Web Site : " &amp;amp; objWebSite.ServerComment \&lt;br /&gt;
            objWebSite.Stop() &lt;/p&gt;
            &lt;p&gt;wscript.echo "Stopping Application Pool : " &amp;amp; objWebSite.AppPoolID &lt;br /&gt;
            Set objAppPool = GetObject("IIS://localhost/W3SVC/AppPools/" &amp;amp; objWebSite.AppPoolID) &lt;br /&gt;
            objAppPool.Stop() &lt;/p&gt;
            &lt;p&gt;wscript.echo "Starting Application Pool : " &amp;amp; objWebSite.AppPoolID &lt;br /&gt;
            objAppPool.Start() &lt;/p&gt;
            &lt;p&gt;WScript.Echo "Starting Web Site : " &amp;amp; objWebSite.ServerComment &lt;br /&gt;
            objWebSite.Start() &lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;You can also view/save the script from &lt;a href="http://blog.crowe.co.nz/attachments/StopAndStartSiteAndAppPool.txt"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/757.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2007/08/20/Starting-and-Stopping-a-Web-Site-And-Application-Pool.aspx</guid>
            <pubDate>Tue, 21 Aug 2007 00:50:24 GMT</pubDate>
            <wfw:comment>http://blog.crowe.co.nz/blog/comments/757.aspx</wfw:comment>
            <comments>http://blog.crowe.co.nz/blog/archive/2007/08/20/Starting-and-Stopping-a-Web-Site-And-Application-Pool.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/757.aspx</wfw:commentRss>
        </item>
        <item>
            <title>IIS Web Site Identifiers</title>
            <link>http://blog.crowe.co.nz/blog/archive/2007/08/04/IIS-Web-Site-Identifiers.aspx</link>
            <description>&lt;p&gt;Normally you do not need to be concerned about web site identifiers, these are the actual ID's that reference the web site to IIS. Normally we just use the web site description such as Default Web Site or in my case blog.crowe.co.nz or something similar.&lt;/p&gt;
&lt;p&gt;But if you are interested in writing scripts you normally reference sites using the Web Site Instance ID.&lt;/p&gt;
&lt;p&gt;In IIS 6 the IIS Manager shows you a column called Idenfitier and this is the actual ID that references the web site. This was not visible in Windows 2000 (IIS 5) or Windows XP (IIS 5.1) and we had to use different methods to see the identifier.&lt;/p&gt;
&lt;p&gt;&lt;img height="248" alt="" width="772" src="/images/blog_crowe_co_nz/WebSiteIdentifiers.gif" /&gt;&lt;/p&gt;
&lt;p&gt;Using IIS 7 on Windows Vista you can see a column called ID which is the Web Site Instance ID&lt;/p&gt;
&lt;p&gt;&lt;img height="501" width="789" alt="" src="/images/blog_crowe_co_nz/WebSiteIdentifierIIS7.gif" /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Default Web Site&lt;/strong&gt; always has an identifier of &lt;strong&gt;1.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;All other web sites on IIS 6 have web site idenfieir's that look like random numbers. The fact is that this is not the case and the identifier is generated based on the description of the web site. This is so that if you have a server farm as long as the descripiton is the same you will end up with the same web site identifier. See this &lt;a href="http://blog.crowe.co.nz/archive/2005/12/08/346.aspx"&gt;article for more details &lt;/a&gt;on the way that these identifiers are generated.&lt;/p&gt;
&lt;p&gt; Another way to identify the web site instance id is to look at the Logging Properties of a particular web site. &lt;/p&gt;
&lt;p&gt;&lt;img height="553" alt="" width="594" src="/images/blog_crowe_co_nz/WebSiteIdentifierFromlogfile.gif" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see above the highlighted area shows the web site instance id. This is still a valid method for people using IIS 5 and IIS 5.1.&lt;/p&gt;
&lt;p&gt;IIS 7 on Windows Vista does not include a logging configuration option - did they just forget it?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How about if you want to use a script to identify a web site?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;IIS comes with a script called &lt;strong&gt;findweb.vbs&lt;/strong&gt; that you can use to find a particular web site. This script is stored in &lt;strong&gt;c:\inetpub\adminscripts&lt;/strong&gt; by default.&lt;/p&gt;
&lt;p&gt;To use it you need to open a &lt;strong&gt;CMD.EXE&lt;/strong&gt; command prompt and then use the &lt;strong&gt;cscript.exe&lt;/strong&gt; utility to run the script. You also need to specify parameters to get the script to do what you want.&lt;/p&gt;
&lt;p&gt;In this case I was interested in finding a web site called &lt;strong&gt;photos.crowe.co.nz&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img height="252" alt="" width="696" src="/images/blog_crowe_co_nz/findweb(1).gif" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How about writing your own VB Script to list the site and the instance id?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;img height="350" alt="" width="725" src="/images/blog_crowe_co_nz/findsites.gif" /&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Running the script above will display the web site Instance ID and the Description of the site.&lt;/p&gt;
&lt;p&gt;&lt;img height="359" alt="" width="695" src="/images/blog_crowe_co_nz/findsites1.gif" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/749.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2007/08/04/IIS-Web-Site-Identifiers.aspx</guid>
            <pubDate>Sat, 04 Aug 2007 17:15:12 GMT</pubDate>
            <wfw:comment>http://blog.crowe.co.nz/blog/comments/749.aspx</wfw:comment>
            <comments>http://blog.crowe.co.nz/blog/archive/2007/08/04/IIS-Web-Site-Identifiers.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/749.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Microsoft releases a new download center for IIS (everything in one place)</title>
            <link>http://blog.crowe.co.nz/blog/archive/2007/02/01/680.aspx</link>
            <description>&lt;IMG src="/images/IISDownloadCenter.gif" align=right&gt;
&lt;P&gt;&lt;SPAN lang=EN-US&gt;&lt;A href="http://www.iis.net/downloads/default.aspx?tabid=3" target=_blank&gt;DownloadCENTER&lt;/A&gt; for IIS.net has been released!&amp;nbsp;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN lang=EN-US&gt;The &lt;A href="http://www.iis.net/downloads/default.aspx?tabid=3"&gt;DownloadCENTER at IIS.net&lt;/A&gt;, is a community hotspot for discovering, sharing, reviewing and promoting IIS-related solutions in a single place.&amp;nbsp; Dozens of existing downloads, for all versions of IIS &amp;#8211; both from Microsoft and the community &amp;#8211; are already available in DownloadCENTER today.&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN lang=EN-US&gt;This new feature of IIS.net is particularly relevant with the release of IIS7 in Windows Vista.&amp;nbsp; The latest release of Microsoft&amp;#8217;s Web server has a completely &lt;A href="http://www.iis.net/default.aspx?tabid=7&amp;amp;subtabid=71" target=_blank&gt;modular&lt;/A&gt; architecture which features over &lt;A href="http://www.iis.net/default.aspx?tabid=7&amp;amp;subtabid=74" target=_blank&gt;forty pluggable components&lt;/A&gt; that can be easily added, removed or even replaced with custom implementations.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN lang=EN-US&gt;This powerful &lt;A href="http://www.iis.net/default.aspx?tabid=2&amp;amp;subtabid=25&amp;amp;i=1076" target=_blank&gt;extensibility&lt;/A&gt; support is available to both .NET and C/C++ developers.&amp;nbsp; In the future, DownloadCENTER is expected to house a large number of IIS7 extensions submitted by not only the IIS team but the developers and partner ISVs of the IIS community as well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN lang=EN-US&gt;To learn more about the DownloadCenter, read IIS Product Unit Manager, Bill Staples&amp;#8217; &lt;A href="http://blogs.iis.net/bills/archive/2007/01/28/iis-net-downloadcenter-is-now-live.aspx"&gt;blog post&lt;/A&gt; about it or check it out yourself today!&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/680.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2007/02/01/680.aspx</guid>
            <pubDate>Thu, 01 Feb 2007 19:36:00 GMT</pubDate>
            <wfw:comment>http://blog.crowe.co.nz/blog/comments/680.aspx</wfw:comment>
            <comments>http://blog.crowe.co.nz/blog/archive/2007/02/01/680.aspx#feedback</comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/680.aspx</wfw:commentRss>
        </item>
        <item>
            <title>VBScript - Check if multiple version of the .NET framework are assigned to an application pool</title>
            <link>http://blog.crowe.co.nz/blog/archive/2006/08/15/676.aspx</link>
            <description>&lt;P&gt;This code will allow you to check if there are&amp;nbsp;IIS&amp;nbsp;applications which&amp;nbsp;are configured to use multiple version of the&amp;nbsp;.NET framework.&lt;/P&gt;
&lt;P&gt;The code enumerates all the&amp;nbsp;Application Pools and then find all&amp;nbsp;of the applications&amp;nbsp;in that pool. It then checks for the version of the .NET framework which handles the .ASPX file extension.&lt;/P&gt;
&lt;P&gt;It saves the unique versions of the&amp;nbsp;.NET Framework found and if it finds multiple versions installed will list all of the applications using that Application Poll and display the path and the version being used. This will allow you to find a potential problem which could be hard to track down normally.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Calling Usage&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cscript CheckForMultipleVersionsOfDotNetFramework.vbs&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Example Output&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;AppPool #1&lt;BR&gt;No applications using this pool!&lt;/P&gt;
&lt;P&gt;DefaultAppPool&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Warning multiple version of the .NET framework detected!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Found references to v1.1.4322&lt;BR&gt;&amp;nbsp;Found references to v2.0.50727&lt;/P&gt;
&lt;P&gt;&amp;nbsp;//localhost/W3SVC/1/ROO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - v1.1.4322&lt;BR&gt;&amp;nbsp;//localhost/W3SVC/1198258389/ROO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- v1.1.4322&lt;BR&gt;&amp;nbsp;//localhost/W3SVC/1280263431/ROO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- v1.1.4322&lt;BR&gt;&amp;nbsp;//localhost/W3SVC/1388032739/ROO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- v1.1.4322&lt;BR&gt;&amp;nbsp;//localhost/W3SVC/1849151055/ROO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- v1.1.4322&lt;BR&gt;&amp;nbsp;//localhost/W3SVC/1957176745/ROO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- v1.1.4322&lt;BR&gt;&amp;nbsp;//localhost/W3SVC/4/ROO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - v1.1.4322&lt;BR&gt;&amp;nbsp;//localhost/W3SVC/415889539/ROO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- v1.1.4322&lt;BR&gt;&amp;nbsp;//localhost/W3SVC/1/ROOT/Monito&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- v2.0.50727&lt;BR&gt;&amp;nbsp;//localhost/W3SVC/1/ROOT/Monitorin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- v1.1.4322&lt;BR&gt;&amp;nbsp;//localhost/W3SVC/1/ROOT/NetTracke&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- v1.1.4322&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;ExchangeApplicationPool&lt;BR&gt;Found references to v1.1.4322&lt;/P&gt;
&lt;P&gt;ExchangeMobileBrowseApplicationPool&lt;BR&gt;Found references to v1.1.4322&lt;/P&gt;
&lt;P&gt;MSSharePointAppPool&lt;BR&gt;Found references to v1.1.4322&lt;/P&gt;
&lt;P&gt;MyAppPool1&lt;BR&gt;No applications using this pool!&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Source Code&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You can download the source code &lt;A href="http://blog.crowe.co.nz/Attachments/CheckForMultipleVersionsOfDotNetFramework.txt"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;option&lt;/SPAN&gt; explicit
&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; AppsInPool, objAppPool, index, IISObj, IISPath, Version, pos
&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; Versions(), objAppPools
&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt; FindASPXScriptMapVersion(ScriptMaps)
 &lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; pos, ScriptMap
 &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; pos = lbound(ScriptMaps) &lt;SPAN style="COLOR: blue"&gt;to&lt;/SPAN&gt; UBOund(ScriptMaps)
   ScriptMap = lcase(ScriptMaps(POS))
   &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (left(ScriptMap, &lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;) = &lt;SPAN style="COLOR: maroon"&gt;".aspx"&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;
    FindASPXScriptMapVersion = mid(ScriptMap, &lt;SPAN style="COLOR: maroon"&gt;42&lt;/SPAN&gt;)
    FindASPXScriptMapVersion = left(FindASPXScriptMapVersion, _
     instr(FindASPXScriptMapVersion, &lt;SPAN style="COLOR: maroon"&gt;"\"&lt;/SPAN&gt;)-&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
    &lt;SPAN style="COLOR: blue"&gt;exit&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;
   &lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
 &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt; 
 FindASPXScriptMapVersion = &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt; AddVersion(Version, Path)
 &lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; Found, pos
 Found = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;
 &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; pos = lbound(Versions) &lt;SPAN style="COLOR: blue"&gt;to&lt;/SPAN&gt; UBound(Versions)-&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (Versions(pos) = Version) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;
   Found = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
 &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
 &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (Found = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: blue"&gt;redim&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;preserve&lt;/SPAN&gt; Versions(ubound(Versions)+&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
  Versions(ubound(Versions)-&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)= Version
 &lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; objAppPools = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/W3SVC/AppPools"&lt;/SPAN&gt;)
&lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;each&lt;/SPAN&gt; objAppPool &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; objAppPools
 &lt;SPAN style="COLOR: blue"&gt;Redim&lt;/SPAN&gt; Versions(&lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;)
 &lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; objAppPool = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/W3SVC/AppPools/"&lt;/SPAN&gt; &amp;amp; objAppPool.Name )
 WScript.echo objAppPool.Name 
 AppsInPool= objAppPool.EnumAppsInPool()
 &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ubound(AppsInPool) = -&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;
  WScript.echo vbtab  &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"No applications using this pool!"&lt;/SPAN&gt;
 &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; index = lbound(AppsInPool) &lt;SPAN style="COLOR: blue"&gt;to&lt;/SPAN&gt; UBound(AppsInPool)
   IISPath = AppsInPool(index)
   IISPath = &lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/"&lt;/SPAN&gt; &amp;amp; mid(IISPath,&lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;, len(IISPath)-&lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;)
   &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; IISObj = GetObject(IISPath)
   Version = FindASPXScriptMapVersion(IISObj.ScriptMaps)
   &lt;SPAN style="COLOR: blue"&gt;call&lt;/SPAN&gt; AddVersion(Version, mid(IISPath,&lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;, len(IISPath)-&lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;))
  &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ubound(Versions)&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;
   WScript.Echo vbcrlf &amp;amp; vbtab &amp;amp; _
    &lt;SPAN style="COLOR: maroon"&gt;"Warning multiple version of the .NET framework detected!"&lt;/SPAN&gt; &amp;amp; vbcrlf
   
   &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; pos = lbound(Versions) &lt;SPAN style="COLOR: blue"&gt;to&lt;/SPAN&gt; ubound(Versions)-&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
    WScript.echo vbtab &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"Found references to "&lt;/SPAN&gt; &amp;amp;  Versions(pos) 
   &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
   WScript.echo &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
   &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; index = lbound(AppsInPool) &lt;SPAN style="COLOR: blue"&gt;to&lt;/SPAN&gt; UBound(AppsInPool)
    IISPath = AppsInPool(index)
    IISPath = &lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/"&lt;/SPAN&gt; &amp;amp; mid(IISPath,&lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;, len(IISPath)-&lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;)
    &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; IISObj = GetObject(IISPath)
    Version = FindASPXScriptMapVersion(IISObj.ScriptMaps)
    WScript.echo vbtab &amp;amp; mid(IISPath,&lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;, len(IISPath)-&lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;) &amp;amp; _
     space(&lt;SPAN style="COLOR: maroon"&gt;70&lt;/SPAN&gt; - len(IISpath)) &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" - "&lt;/SPAN&gt; &amp;amp; Version
   &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;
   &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; pos = lbound(Versions) &lt;SPAN style="COLOR: blue"&gt;to&lt;/SPAN&gt; ubound(Versions)-&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
    WScript.echo vbtab &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"Found references to "&lt;/SPAN&gt; &amp;amp;  Versions(pos) 
   &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;  
  &lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
 &lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
 WScript.echo &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/676.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2006/08/15/676.aspx</guid>
            <pubDate>Tue, 15 Aug 2006 20:31:00 GMT</pubDate>
            <wfw:comment>http://blog.crowe.co.nz/blog/comments/676.aspx</wfw:comment>
            <comments>http://blog.crowe.co.nz/blog/archive/2006/08/15/676.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/676.aspx</wfw:commentRss>
        </item>
        <item>
            <title>IIS 6 - Creating an application and setting the application pool using ADSI</title>
            <link>http://blog.crowe.co.nz/blog/archive/2006/07/30/672.aspx</link>
            <description>I received a request from visitor to my blog on how to set an application pool to a new folder he created. 
&lt;P&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV style="BORDER-RIGHT: 1px outset; PADDING-RIGHT: 5px; BORDER-TOP: 1px outset; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: 1px outset; PADDING-TOP: 5px; BORDER-BOTTOM: 1px outset; BACKGROUND-COLOR: #ffffcc"&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=2&gt;I have a small web server running IIS 6 and I host small sites for friends and family all under one domain. To keep them separate I put each of their sites into a subfolder and drop it into different pools.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;To date I've been doing this manually.&amp;nbsp; I've been trying to get my mind wrapped around this ADSI stuff to automate this process a bit but I'm coming up short.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Here's what I do now.. if you have a few moments can you tell me how I might go about automating this process?&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT size=2&gt;I make a subfolder (call it &lt;B&gt;Test&lt;/B&gt;) in the root of my website.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT size=2&gt;I go into IIS Manager, expand the website, then right click on Test / Properties.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT size=2&gt;I click Create to make it into an application.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT size=2&gt;I change the application pool from Default to "familypool" then Apply.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following code will allow you to create an application and assign the application pool "familypool" to the new directory. Note the application pool &amp;#8220;familypool&amp;#8220; must already have been created.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;option&lt;/SPAN&gt; explicit

&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; IIsWebVDirObj
&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; IIsWebVDirRootObj
&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; NewFolderName

NewFolderName = &lt;SPAN style="COLOR: maroon"&gt;"Test"&lt;/SPAN&gt;

&lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; CreateNewApplicationPool = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; UseExistingApplicationPool = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;


&lt;SPAN style="COLOR: green"&gt;' Create the Metabase entry
&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; IIsWebVDirRootObj = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://LocalHost/W3SVC/1/Root"&lt;/SPAN&gt;)
&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; IIsWebVDirObj = IIsWebVDirRootObj.Create(&lt;SPAN style="COLOR: maroon"&gt;"IIsWebDirectory"&lt;/SPAN&gt;, NewFolderName)

IIsWebVDirObj.AppCreate3 &lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;" familypool"&lt;/SPAN&gt;, UseExistingApplicationPool
IIsWebVDirObj.AppFriendlyName = &lt;SPAN style="COLOR: maroon"&gt;"My App Friendly Name"&lt;/SPAN&gt;
IIsWebVDirObj.SetInfo
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the code above we have made some assumptions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The web site we are assigning it to is the default web site. This has an instance ID of 1. 
&lt;LI&gt;The IISWebDirectory does not exist in the Metabase. If it does it will cause an error as would be the case if you run the code twice.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;In the case of the 2nd assumption above we would need to change the code from&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; IIsWebVDirRootObj = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://LocalHost/W3SVC/1/Root"&lt;/SPAN&gt;)&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; IIsWebVDirObj = IIsWebVDirRootObj.Create(&lt;SPAN style="COLOR: maroon"&gt;"IIsWebDirectory"&lt;/SPAN&gt;, NewFolderName)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN style="COLOR: green"&gt;' Load the Metabase entry if it does exist&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; IIsWebVDirObj = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/W3SVC/1/Root/"&lt;/SPAN&gt; &amp;amp; NewFolderName) &lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/672.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2006/07/30/672.aspx</guid>
            <pubDate>Sun, 30 Jul 2006 07:06:00 GMT</pubDate>
            <wfw:comment>http://blog.crowe.co.nz/blog/comments/672.aspx</wfw:comment>
            <comments>http://blog.crowe.co.nz/blog/archive/2006/07/30/672.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/672.aspx</wfw:commentRss>
        </item>
        <item>
            <title>IIS 6 Application Pools and ADSI</title>
            <link>http://blog.crowe.co.nz/blog/archive/2006/07/11/669.aspx</link>
            <description>&lt;P&gt;An application pool provides you with a way of isolating Web sites and Directories from each other even though they are being hosted on a common server. Each application pool is given its own set of server resources and can be configured with different identities. That way, if a Web site crashes, it won&amp;#8217;t effect sites in other application pools. &lt;/P&gt;
&lt;P&gt;A example of this is a Web site which has a memory leak. If all of the Web sites hosted on a particular server were to share the system resources as was the case with IIS 5.1 and earlier and one of the Web sites had a memory leak, it could potentially take memory away from the other hosted sites. &lt;/P&gt;
&lt;P&gt;If the leaky site were in its own application pool though, the memory leak would not effect any other site because each application pool has its own server resources including memory.&lt;/P&gt;
&lt;P&gt;On earlier versions of IIS you could only configure your sites to run either Low ( In Process ) with the IIS Engine, Medium ( Pooled ) where all applications shared a pool of memory, and High (Out Of Process). The problem with this is that a bad application could depending on the isolation level take down the IIS server, or all other sites in the Medium ( Pooled ) model.&lt;/P&gt;
&lt;P&gt;Each application pool can be recycled based on a memory limit, the time of day, a number of requests or just after a period of time. Each application pool can also run with its own identity which can be either Local System, Local Service, Network Service or a custom credential.&lt;/P&gt;
&lt;P&gt;Application pools are available only when IIS is running in worker process isolation mode (this is the default). If you are running IIS in IIS 5 isolation mode, then the application pools will not be accessible to you.&lt;/P&gt;
&lt;P&gt;There is only one application pool by default called DefaultAppPool. When you create new Web sites, the newly created sites by default will use the DefaultAppPool unless you reconfigure the site after it is created. IIS does not automatically create a separate application pool for each Web site.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Note&lt;/B&gt;: If you are running ASP.NET 1.1 and 2.0 then they must run in two different application pools as you can only load one version of the .NET framework into an application pool.&lt;/P&gt;
&lt;P&gt;Below are a number of very simple scripts that you could use to view / add and edit application pools.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Note: &lt;/B&gt;Application Pools are only supported on IIS 6 and later.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Enumerating Application Pools&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;This simple script will simply display the name of each application pool on the local server.&lt;/P&gt;
&lt;TABLE id=table1 style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=5 width="100%" bgColor=#ffffcc border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;option&lt;/SPAN&gt; explicit

&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; objAppPools, objAppPool

&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; objAppPools = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/W3SVC/AppPools"&lt;/SPAN&gt;)
&lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;each&lt;/SPAN&gt; objAppPool &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; objAppPools
	WScript.echo objAppPool.Name 
&lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Enumerating Applications in an Application Pool&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;This script will display the web sites / directories that are using the DefaultAppPool&lt;/P&gt;
&lt;TABLE id=table2 style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=5 width="100%" bgColor=#ffffcc border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;option&lt;/SPAN&gt; explicit

&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; Applications, objAppPool, index

&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; objAppPool = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/W3SVC/AppPools/DefaultAppPool"&lt;/SPAN&gt;)
WScript.echo objAppPool.Name 

Applications = objAppPool.EnumAppsInPool()
&lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; index = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;to&lt;/SPAN&gt; UBound(Applications)
	WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"   "&lt;/SPAN&gt; &amp;amp; Applications(index)
&lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Enumerating Application Pool Properties&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;This script will display all properties of an application pool by looking at the Schema object for an Application Pool.&lt;/P&gt;
&lt;TABLE id=table3 style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=5 width="100%" bgColor=#ffffcc border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;option&lt;/SPAN&gt; explicit

&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; Applications, objAppPools, objAppPool, index, IIsSchemaObject
&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; PropertyName, IIsAppPoolObject, ValueList

&lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; IIsSchemaObject = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/schema/IIsApplicationPool"&lt;/SPAN&gt;)
&lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; IIsAppPoolObject = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/W3SVC/AppPools/DefaultAppPool"&lt;/SPAN&gt;)

&lt;SPAN style="COLOR: blue"&gt;on&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;error&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;resume&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;

&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Each&lt;/SPAN&gt; PropertyName &lt;SPAN style="COLOR: blue"&gt;In&lt;/SPAN&gt; IIsSchemaObject.MandatoryProperties
	WScript.echo PropertyName
&lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;

&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Each&lt;/SPAN&gt; PropertyName &lt;SPAN style="COLOR: blue"&gt;In&lt;/SPAN&gt; IIsSchemaObject.OptionalProperties
	WScript.echo PropertyName
	ValueList = IIsAppPoolObject.&lt;SPAN style="COLOR: blue"&gt;Get&lt;/SPAN&gt;(PropertyName)
	&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (isArray(ValueList) = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;
		&lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; index = lbound(ValueList) &lt;SPAN style="COLOR: blue"&gt;to&lt;/SPAN&gt; ubound(ValueList)
			WScript.echo &lt;SPAN style="COLOR: maroon"&gt;" "&lt;/SPAN&gt; &amp;amp; index &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" - "&lt;/SPAN&gt; &amp;amp; ValueList(index)
		&lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
	&lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;
		WScript.echo &lt;SPAN style="COLOR: maroon"&gt;" "&lt;/SPAN&gt; &amp;amp; ValueList
	&lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Enumerating the Periodic Recycling of all Application Pools&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;This script will display the recycling settings of all application pools. You may find that your application stops briefly and that could be caused by the application pool being recycled every 1740 minutes ( every 29 hours) which is the default.&lt;/P&gt;
&lt;TABLE id=table5 style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=5 width="100%" bgColor=#ffffcc border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;option&lt;/SPAN&gt; explicit

&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; objAppPools, objAppPool, Schedule

&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; objAppPools = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/W3SVC/AppPools"&lt;/SPAN&gt;)
&lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;each&lt;/SPAN&gt; objAppPool &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; objAppPools
	WScript.echo objAppPool.Name
	WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"  Restart Time           : "&lt;/SPAN&gt; &amp;amp; objAppPool.PeriodicRestartTime &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" seconds"&lt;/SPAN&gt;
	WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"  Restart Requests       : "&lt;/SPAN&gt; &amp;amp; objAppPool.PeriodicRestartRequests
	WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"  Restart Memory         : "&lt;/SPAN&gt; &amp;amp; objAppPool.PeriodicRestartMemory
	WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"  Restart Private Memory : "&lt;/SPAN&gt; &amp;amp; objAppPool.PeriodicRestartPrivateMemory
	WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"  Restart Requests       : "&lt;/SPAN&gt; &amp;amp; objAppPool.PeriodicRestartRequests
	&lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;each&lt;/SPAN&gt; Schedule &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; objAppPool.PeriodicRestartSchedule
		WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"  Restart At             : "&lt;/SPAN&gt; &amp;amp; Schedule
	&lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
	WScript.echo
&lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Creating an Application Pool&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;This script will create a new application pool using the defaults.&lt;/P&gt;
&lt;TABLE id=table4 style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=5 width="100%" bgColor=#ffffcc border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;PRE&gt;strAppPool = &lt;SPAN style="COLOR: maroon"&gt;"MyAppPool1"&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; objAppPools = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/W3SVC/AppPools"&lt;/SPAN&gt;)
&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; objAppPool = objAppPools.Create(&lt;SPAN style="COLOR: maroon"&gt;"IIsApplicationPool"&lt;/SPAN&gt;, strAppPool)
objAppPool.SetInfo&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Creating an Application Pool to run with a specific identity&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;This script will create a new application pool to run as a custom identity. This custom identity could be a local or domain account. You will need to add the user account into the &lt;B&gt;IIS_WPG&lt;/B&gt; group on the IIS server. This is because this group has been assigned permissions that the application pool will need to run properly.&lt;/P&gt;
&lt;TABLE id=table4 style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=5 width="100%" bgColor=#ffffcc border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;PRE&gt;strAppPool = &lt;SPAN style="COLOR: maroon"&gt;"MyAppPool2"&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; objAppPools = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/W3SVC/AppPools"&lt;/SPAN&gt;)
&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; objAppPool = objAppPools.Create(&lt;SPAN style="COLOR: maroon"&gt;"IIsApplicationPool"&lt;/SPAN&gt;, strAppPool)

&lt;SPAN style="COLOR: green"&gt;' 0 = Local System&lt;/SPAN&gt;
&lt;SPAN style="COLOR: green"&gt;' 1 = Local Service&lt;/SPAN&gt;
&lt;SPAN style="COLOR: green"&gt;' 2 = Network Service&lt;/SPAN&gt;
&lt;SPAN style="COLOR: green"&gt;' 3 = Custom Identity -&amp;gt; a&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;lso set WAMUserName and WAMUserPass&lt;/SPAN&gt;
objAppPool.AppPoolIdentityType = &lt;SPAN style="COLOR: maroon"&gt;3
&lt;/SPAN&gt;
&lt;SPAN style="COLOR: green"&gt;' Note: WamUserName must be added to the IIS_WPG group to have correct security rights&lt;/SPAN&gt;
objAppPool.WAMUserName = &lt;SPAN style="COLOR: maroon"&gt;"DOMAIN\Username"&lt;/SPAN&gt;
objAppPool.WAMUserPass = &lt;SPAN style="COLOR: maroon"&gt;"Password"
&lt;/SPAN&gt;
objAppPool.SetInfo&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Starting an Application Pool&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;This script will allow you to start an application pool. You can also specify &lt;B&gt;Stop&lt;/B&gt;() and &lt;B&gt;Recycle&lt;/B&gt;()&amp;nbsp; instead of Start().&lt;/P&gt;
&lt;TABLE id=table6 style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=5 width="100%" bgColor=#ffffcc border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;option&lt;/SPAN&gt; explicit

&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; objAppPool

&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; objAppPool = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://localhost/W3SVC/AppPools/DefaultAppPool"&lt;/SPAN&gt;)
objAppPool.Start()
&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully these simple scripts will show you how easy Application Pools are to create and enumerate.&lt;/P&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/669.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2006/07/11/669.aspx</guid>
            <pubDate>Wed, 12 Jul 2006 04:43:00 GMT</pubDate>
            <wfw:comment>http://blog.crowe.co.nz/blog/comments/669.aspx</wfw:comment>
            <comments>http://blog.crowe.co.nz/blog/archive/2006/07/11/669.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/669.aspx</wfw:commentRss>
        </item>
        <item>
            <title>VBScript - Modified version of Mk3Site.vbs</title>
            <link>http://blog.crowe.co.nz/blog/archive/2006/07/11/668.aspx</link>
            <description>&lt;P&gt;This script is a modified version of the IIS 5 Mk3Site.vbs script.&lt;/P&gt;
&lt;P&gt;I had a request to do some work and the customer would pay me to re-write the script to support some additional features.&lt;/P&gt;
&lt;P&gt;I decided to do the work for free and donate the script to the community. It may have some use for some people.&lt;/P&gt;
&lt;P&gt;The new features are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Ability to set the application protection to Low, Medium or High 
&lt;LI&gt;Ability to set the Execute options to None, Scripts or Executables 
&lt;LI&gt;Ability to change the log file period 
&lt;LI&gt;Ability to change the log directory&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;This script was updated from a previously updated script I wrote back in 2001 and is available from &lt;A href="http://www.iisfaq.com/"&gt;www.iisfaq.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The new features of that script were:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Ability to setup URL redirection while creating the site.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;IMG src="/skins/KJC/images/icon-titledoc.gif"&gt;&amp;nbsp;You can download the script from &lt;A href="http://blog.crowe.co.nz/attachments/mk3site.txt"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;PRE&gt;'------------------------------------------------------------------------------------------------
'
' This &lt;SPAN style="COLOR: blue"&gt;is&lt;/SPAN&gt; a simple script to create a &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;virtual&lt;/SPAN&gt; web server.
'
' Usage: MakeWebSite      &amp;lt;--RootDirectory|-r ROOT DIRECTORY&amp;gt;
'                         &amp;lt;--Comment|-t SERVER COMMENT&amp;gt;
'                         [--computer|-c COMPUTER1[,COMPUTER2...]]
'                         [--HostName|-h HOST NAME[,HOSTNAME2...]]
'                         [--port|-o PORT NUM]
'                         [--IPAddress|-i IP ADDRESS]
'                         [--SiteNumber|-n SITENUMBER]
'                         [--DontStart]
'                         [--verbose|-v]
'                         [--Write]"
'                         [--Execute { NONE, SCRIPTS, EXECUTABLES } ]"
'                         [--AppProtection { LOW, MEDIUM, HIGH } ]"
'                         [--AppName Name]"
'                         [--LogPeriod { DAILY, WEEKLY, MONTHLY, HOURLY} ]"
'                         [--LogFolder LogFileDirectory]"
'                         [--URL Redirectionpath]
'                         [--URLExact]
'                         [--URLChildOnly]
'                         [--URLPermanent]
'                         [--help|-?]
'
' IP ADDRESS            The IP Address to assign to the &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; server.  Optional.
' HOST NAME             The host name of the web site &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; host headers.
'      WARNING: Only use Host Name &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; DNS &lt;SPAN style="COLOR: blue"&gt;is&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; up find the server.
' PORT NUM              The port to which the server should bind
' ROOT DIRECTORY        Full path to the root directory &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; the &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; server.
' SERVER COMMENT        The server comment -- &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;is&lt;/SPAN&gt; the name that appers &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; the MMC.
' SITENUMBER      The Site Number &lt;SPAN style="COLOR: blue"&gt;is&lt;/SPAN&gt; the number &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; the path that the web server
'      will be created at.  i.e. w3svc/&lt;SPAN style="COLOR: maroon"&gt;3&lt;/SPAN&gt;
'
' Example &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;: MakeWebSite.vbs -r D:\Roots\Company11 --DontStart -t &lt;SPAN style="COLOR: maroon"&gt;"My Company Site"&lt;/SPAN&gt;
' Example &lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;: MakeWebSite.vbs -r C:\Inetpub\wwwroot -t Test -o &lt;SPAN style="COLOR: maroon"&gt;8080&lt;/SPAN&gt;
'
'
' Modified by chris crowe - www.iisfaq.com to support multiple host headers and URL Redirection
'------------------------------------------------------------------------------------------------

' Force &lt;SPAN style="COLOR: blue"&gt;explicit&lt;/SPAN&gt; declaration of all variables
Option Explicit
'On Error Resume Next
Dim ArgIPAddress, ArgRootDirectory, ArgServerComment, ArgSkeletalDir, ArgHostName, ArgPort
Dim ArgComputers, ArgStart
Dim ArgSiteNumber
Dim oArgs, ArgNum
Dim verbose, FSO
' Chris Crowe - blog.crowe.co.nz
dim ArgLogFolder
dim ArgLogFilePeriod
dim ArgAppFriendlyName
dim ArgAppProtection
dim ArgExecute
dim ArgExecuteScripts
dim ArgExecuteExecutables 
dim ArgWrite
&lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; MD_LOGFILE_PERIOD_MAXSIZE = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt; ' Create &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; log file after reaching maximum size. 
&lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; MD_LOGFILE_PERIOD_DAILY   = &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt; ' Create &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; log file daily. 
&lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; MD_LOGFILE_PERIOD_WEEKLY  = &lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt; ' Create &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; log file weekly. 
&lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; MD_LOGFILE_PERIOD_MONTHLY = &lt;SPAN style="COLOR: maroon"&gt;3&lt;/SPAN&gt; ' Create &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; log file monthly. 
&lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; MD_LOGFILE_PERIOD_HOURLY  = &lt;SPAN style="COLOR: maroon"&gt;4&lt;/SPAN&gt; ' Create a &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; log file hourly. 
' Chris Crowe - iisfaq.com
Dim ArgURL, ArgURLExact, ArgURLChildOnly, ArgURLPermanent
ArgIPAddress = &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
ArgHostName = &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
ArgPort = &lt;SPAN style="COLOR: maroon"&gt;80&lt;/SPAN&gt;
ArgStart = True
ArgComputers = Array(&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
ArgComputers(&lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) = &lt;SPAN style="COLOR: maroon"&gt;"LocalHost"&lt;/SPAN&gt;
ArgSiteNumber = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;
verbose = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;
' Chris Crowe - blog.crowe.co.nz
ArgLogFolder            = &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
ArgLogFilePeriod        = &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
ArgAppFriendlyName      = &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
ArgAppProtection        = &lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;
ArgExecute              = &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
ArgWrite                = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;
' Chris Crowe - iisfaq.com
ArgURL = &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
ArgURLChildonly = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;
ArgURLExact = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;
ArgURLPermanent = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;
Set oArgs = WScript.Arguments
ArgNum = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;
While ArgNum &amp;lt; oArgs.Count
 Select Case LCase(oArgs(ArgNum))
  Case &lt;SPAN style="COLOR: maroon"&gt;"--port"&lt;/SPAN&gt;,&lt;SPAN style="COLOR: maroon"&gt;"-o"&lt;/SPAN&gt;:
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgPort = oArgs(ArgNum) 
  Case &lt;SPAN style="COLOR: maroon"&gt;"--ipaddress"&lt;/SPAN&gt;,&lt;SPAN style="COLOR: maroon"&gt;"-i"&lt;/SPAN&gt;:
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgIPAddress = oArgs(ArgNum)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--rootdirectory"&lt;/SPAN&gt;,&lt;SPAN style="COLOR: maroon"&gt;"-r"&lt;/SPAN&gt;: 
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgRootDirectory = oArgs(ArgNum)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--comment"&lt;/SPAN&gt;,&lt;SPAN style="COLOR: maroon"&gt;"-t"&lt;/SPAN&gt;:
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgServerComment = oArgs(ArgNum)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--hostname"&lt;/SPAN&gt;,&lt;SPAN style="COLOR: maroon"&gt;"-h"&lt;/SPAN&gt;:
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgHostName = oArgs(ArgNum)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--computer"&lt;/SPAN&gt;,&lt;SPAN style="COLOR: maroon"&gt;"-c"&lt;/SPAN&gt;:
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgComputers = Split(oArgs(ArgNum), &lt;SPAN style="COLOR: maroon"&gt;","&lt;/SPAN&gt;, -&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--sitenumber"&lt;/SPAN&gt;,&lt;SPAN style="COLOR: maroon"&gt;"-n"&lt;/SPAN&gt;:
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgSiteNumber = CLng(oArgs(ArgNum))
        ' Chris Crowe - blog.crowe.co.nz
  Case &lt;SPAN style="COLOR: maroon"&gt;"--logfolder"&lt;/SPAN&gt;: 
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgLogFolder = oArgs(ArgNum)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--logperiod"&lt;/SPAN&gt;: 
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgLogFilePeriod = oArgs(ArgNum)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--appname"&lt;/SPAN&gt;: 
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgAppFriendlyName = oArgs(ArgNum)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--appprotection"&lt;/SPAN&gt;: 
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgAppProtection= oArgs(ArgNum)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--execute"&lt;/SPAN&gt;: 
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgExecute = oArgs(ArgNum)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--write"&lt;/SPAN&gt;
   ArgWrite = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
  
  ' Chris Crowe - iisfaq.com
  Case &lt;SPAN style="COLOR: maroon"&gt;"--url"&lt;/SPAN&gt;,&lt;SPAN style="COLOR: maroon"&gt;"-u"&lt;/SPAN&gt;: 
   ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
   ArgURL = oArgs(ArgNum)
  Case &lt;SPAN style="COLOR: maroon"&gt;"--urlexact"&lt;/SPAN&gt;
   ArgURLEXACT = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
  Case &lt;SPAN style="COLOR: maroon"&gt;"--urlchildonly"&lt;/SPAN&gt;
   ArgURLChildOnly = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
  Case &lt;SPAN style="COLOR: maroon"&gt;"--urlpermanent"&lt;/SPAN&gt;
   ArgURLPERMANENT = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
   
  Case &lt;SPAN style="COLOR: maroon"&gt;"--dontstart"&lt;/SPAN&gt;:
   ArgStart = False
  Case &lt;SPAN style="COLOR: maroon"&gt;"--help"&lt;/SPAN&gt;,&lt;SPAN style="COLOR: maroon"&gt;"-?"&lt;/SPAN&gt;:
   Call DisplayUsage
  Case &lt;SPAN style="COLOR: maroon"&gt;"--verbose"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;"-v"&lt;/SPAN&gt;:
   verbose = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
  Case Else:
   WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Unknown argument "&lt;/SPAN&gt;&amp;amp; oArgs(ArgNum)
   Call DisplayUsage
 End Select 
 ArgNum = ArgNum + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
Wend
' Chris Crowe - iisfaq.com
If (ArgRootDirectory = &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) Then
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Missing Root Directory (Required even with URL redirection path)"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
 Call DisplayUsage
 WScript.Quit(&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
End If
' Check &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; the root directory exists
Set FSO = WScript.CreateObject(&lt;SPAN style="COLOR: maroon"&gt;"Scripting.FileSystemObject"&lt;/SPAN&gt;)
  &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (FSO.FolderExists(ArgRootDirectory) = False) then
    WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"The specified root directory does not exist : '"&lt;/SPAN&gt; &amp;amp; ArgRootDirectory &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"'"&lt;/SPAN&gt;
    WScript.Quit(&lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;)
  end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
  
  
  ' Chris Crowe - July &lt;SPAN style="COLOR: maroon"&gt;2006&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgLogFolder &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
      &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (FSO.FolderExists(ArgLogFolder) = False) then
        WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"The specified LogFolder directory does not exist : "&lt;/SPAN&gt; &amp;amp; ArgLogFolder
        WScript.Quit(&lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;)
      end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
  end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;  
  
Set FSO = Nothing

' Chris Crowe - July &lt;SPAN style="COLOR: maroon"&gt;2006&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgExecute&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
    ArgExecute = ucase(ArgExecute)
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgExecute = &lt;SPAN style="COLOR: maroon"&gt;"NONE"&lt;/SPAN&gt;) then 
        ArgExecuteScripts = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;
        ArgExecuteExecutables = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;
    elseif (ArgExecute = &lt;SPAN style="COLOR: maroon"&gt;"SCRIPTS"&lt;/SPAN&gt;) then 
        ArgExecuteScripts = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
        ArgExecuteExecutables = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;
    elseif (ArgExecute = &lt;SPAN style="COLOR: maroon"&gt;"EXECUTABLES"&lt;/SPAN&gt;) then 
        ArgExecuteScripts = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
        ArgExecuteExecutables = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;
      WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"The specified Execute value is invalid : "&lt;/SPAN&gt; &amp;amp; ArgAppProtection
      WScript.Quit(&lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;)
    end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgAppProtection &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
    ArgAppProtection = ucase(ArgAppProtection)
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;"LOW"&lt;/SPAN&gt;) then ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;"INPROCESS"&lt;/SPAN&gt;) then ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;
    
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;"HIGH"&lt;/SPAN&gt;) then ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;"OUTOFPROCESS"&lt;/SPAN&gt;) then ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
    
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;"MEDIUM"&lt;/SPAN&gt;) then ArgAppProtection= &lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;"POOLED"&lt;/SPAN&gt;) then ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;
    
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; ((ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) or (ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;) or (ArgAppProtection = &lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;)) then
    &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;
      WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"The specified AppProtection value is invalid : "&lt;/SPAN&gt; &amp;amp; ArgAppProtection
      WScript.Quit(&lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;)
    end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;  
&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgLogFilePeriod &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
    ArgLogFilePeriod = ucase(ArgLogFilePeriod)
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgLogFilePeriod = &lt;SPAN style="COLOR: maroon"&gt;"DAILY"&lt;/SPAN&gt;) then ArgLogFilePeriod = &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgLogFilePeriod = &lt;SPAN style="COLOR: maroon"&gt;"WEEKLY"&lt;/SPAN&gt;) then ArgLogFilePeriod = &lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;   
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgLogFilePeriod = &lt;SPAN style="COLOR: maroon"&gt;"MONTHLY"&lt;/SPAN&gt;) then ArgLogFilePeriod = &lt;SPAN style="COLOR: maroon"&gt;3&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgLogFilePeriod = &lt;SPAN style="COLOR: maroon"&gt;"HOURLY"&lt;/SPAN&gt;) then ArgLogFilePeriod = &lt;SPAN style="COLOR: maroon"&gt;4&lt;/SPAN&gt;
    
    &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; ((ArgLogFilePeriod= &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) or (ArgLogFilePeriod= &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;) or (ArgLogFilePeriod= &lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;) or (ArgLogFilePeriod= &lt;SPAN style="COLOR: maroon"&gt;3&lt;/SPAN&gt;)) then
    &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;
      WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"The specified LogFilePeriod is invalid : "&lt;/SPAN&gt; &amp;amp; ArgLogFilePeriod
      WScript.Quit(&lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;)
    end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;  

If (ArgServerComment = &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) Then
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Missing Server Comment"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
 Call DisplayUsage
 WScript.Quit(&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
End If
' end - chris Crowe - iisfaq.com
' chris Crowe - iisfaq.com
Call ASTCreateWebSite(ArgIPAddress, ArgRootDirectory, ArgURL, ArgURLEXACT, ArgURLCHILDONLY, ArgURLPERMANENT, &lt;BR&gt;                      ArgServerComment, ArgHostName, ArgPort, ArgComputers, ArgStart)
' chris Crowe - iisfaq.com
Sub ASTCreateWebSite(IPAddress, RootDirectory, URL, ArgURLEXACT, ArgURLCHILDONLY, ArgURLPERMANENT, &lt;BR&gt;                     ServerComment, HostName, PortNum, Computers, Start)
 Dim w3svc, WebServer, NewWebServer, NewDir, Bindings, BindingString, NewBindings, ComputerIndex&lt;BR&gt; Dim Index, SiteObj, bDone
 Dim comp, BindingIndex, HostNameINdex, HostNames
 
   'Chris Crowe - www.iisfaq.com
 Dim URLOPTIONS 
 
 On Error Resume Next
 hostNames = Split(HostName,&lt;SPAN style="COLOR: maroon"&gt;","&lt;/SPAN&gt;)
 For ComputerIndex = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt; To UBound(Computers)
  comp = Computers(ComputerIndex)
  If ComputerIndex &amp;lt;&amp;gt; UBound(Computers) Then
   Trace &lt;SPAN style="COLOR: maroon"&gt;"Creating web site on "&lt;/SPAN&gt; &amp;amp; comp &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"."&lt;/SPAN&gt;
  End If
  ' Grab the web service &lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt;
  Err.Clear
  Set w3svc = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://"&lt;/SPAN&gt; &amp;amp; comp &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"/w3svc"&lt;/SPAN&gt;)
  If Err.Number &amp;lt;&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt; Then
   Display &lt;SPAN style="COLOR: maroon"&gt;"Unable to open: "&lt;/SPAN&gt;&amp;amp;&lt;SPAN style="COLOR: maroon"&gt;"IIS://"&lt;/SPAN&gt; &amp;amp; comp &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"/w3svc"&lt;/SPAN&gt;
  End If
  Trace &lt;SPAN style="COLOR: maroon"&gt;"Making sure this web server doesn't conflict with another..."&lt;/SPAN&gt;
  For Each WebServer &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; w3svc
   If WebServer.Class = &lt;SPAN style="COLOR: maroon"&gt;"IIsWebServer"&lt;/SPAN&gt; Then
    Bindings = WebServer.ServerBindings
    For HostNameINdex = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt; To UBound(HostNames)
     &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; BindingIndex = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt; to Ubound(Bindings)
      BindingString = IpAddress &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;":"&lt;/SPAN&gt; &amp;amp; PortNum &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;":"&lt;/SPAN&gt; &amp;amp; HostNames(HostNameINdex)
      If (BindingString = bindings(BindingIndex)) Then
       Trace &lt;SPAN style="COLOR: maroon"&gt;"The server bindings you specified are duplicated in another virtual web server."&lt;/SPAN&gt;
       Trace &lt;SPAN style="COLOR: maroon"&gt;"The Web Server name is ["&lt;/SPAN&gt; &amp;amp; WebServer.ServerComment &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"], Instance ID ["&lt;/SPAN&gt; &amp;amp; WebServer.name &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"]"&lt;/SPAN&gt;
       Trace &lt;SPAN style="COLOR: maroon"&gt;"The Conflicting Bindings are at index ["&lt;/SPAN&gt; &amp;amp; bindingIndex &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"], ["&lt;/SPAN&gt; &amp;amp; bindings(BindingIndex) &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"]"&lt;/SPAN&gt;
       WScript.Quit (&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
      End If
     next
    next
   End If
  Next
  Index = &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
  bDone = False
  Trace &lt;SPAN style="COLOR: maroon"&gt;"Creating new web server..."&lt;/SPAN&gt;
  ' If the user specified a SiteNumber, then use that.  Otherwise,
  ' test successive numbers under w3svc until an unoccupied slot &lt;SPAN style="COLOR: blue"&gt;is&lt;/SPAN&gt; found
  If ArgSiteNumber &amp;lt;&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt; Then
   Set NewWebServer = w3svc.Create(&lt;SPAN style="COLOR: maroon"&gt;"IIsWebServer"&lt;/SPAN&gt;, ArgSiteNumber)
   NewWebServer.SetInfo
   If (Err.Number &amp;lt;&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) Then
    WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Couldn't create a web site with the specified number: "&lt;/SPAN&gt; &amp;amp; ArgSiteNumber
    WScript.Quit (&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
   Else
    Err.Clear
    ' Verify that the newly created site can be retrieved
    Set SiteObj = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://"&lt;/SPAN&gt;&amp;amp;comp&amp;amp;&lt;SPAN style="COLOR: maroon"&gt;"/w3svc/"&lt;/SPAN&gt; &amp;amp; ArgSiteNumber)
    If (Err.Number = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) Then
     bDone = True
     Trace &lt;SPAN style="COLOR: maroon"&gt;"Web server created. Path is - "&lt;/SPAN&gt;&amp;amp;&lt;SPAN style="COLOR: maroon"&gt;"IIS://"&lt;/SPAN&gt;&amp;amp;comp&amp;amp;&lt;SPAN style="COLOR: maroon"&gt;"/w3svc/"&lt;/SPAN&gt; &amp;amp; ArgSiteNumber
    Else
     WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Couldn't create a web site with the specified number: "&lt;/SPAN&gt; &amp;amp; ArgSiteNumber
     WScript.Quit (&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
    End If
   End If
  Else
   While (Not bDone)
    Err.Clear
    Set SiteObj = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://"&lt;/SPAN&gt;&amp;amp;comp&amp;amp;&lt;SPAN style="COLOR: maroon"&gt;"/w3svc/"&lt;/SPAN&gt; &amp;amp; Index)
    If (Err.Number = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) Then
     ' A web server &lt;SPAN style="COLOR: blue"&gt;is&lt;/SPAN&gt; already defined at &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt; position so increment
     Index = Index + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
    Else
     Err.Clear
     Set NewWebServer = w3svc.Create(&lt;SPAN style="COLOR: maroon"&gt;"IIsWebServer"&lt;/SPAN&gt;, Index)
     NewWebServer.SetInfo
     If (Err.Number &amp;lt;&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) Then
      ' If call to Create failed then &lt;SPAN style="COLOR: blue"&gt;try&lt;/SPAN&gt; the next number
      Index = Index + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
     Else
      Err.Clear
      ' Verify that the newly created site can be retrieved
      Set SiteObj = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://"&lt;/SPAN&gt;&amp;amp;comp&amp;amp;&lt;SPAN style="COLOR: maroon"&gt;"/w3svc/"&lt;/SPAN&gt; &amp;amp; Index)
      If (Err.Number = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) Then
       bDone = True
       Trace &lt;SPAN style="COLOR: maroon"&gt;"Web server created. Path is - "&lt;/SPAN&gt;&amp;amp;&lt;SPAN style="COLOR: maroon"&gt;"IIS://"&lt;/SPAN&gt;&amp;amp;comp&amp;amp;&lt;SPAN style="COLOR: maroon"&gt;"/w3svc/"&lt;/SPAN&gt; &amp;amp; Index
      Else
       Index = Index + &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;
      End If
     End If
    End If
    ' sanity check
    If (Index &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;10000&lt;/SPAN&gt;) Then
     Trace &lt;SPAN style="COLOR: maroon"&gt;"Seem to be unable to create new web server.  Server number is "&lt;/SPAN&gt;&amp;amp;Index&amp;amp;&lt;SPAN style="COLOR: maroon"&gt;"."&lt;/SPAN&gt;
     WScript.Quit (&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
    End If
   Wend
  End If
on error &lt;SPAN style="COLOR: blue"&gt;goto&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;
  redim NewBindings (ubound(HostNames))
  For HostNameINdex = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt; To UBound(HostNames)
   BindingString = IpAddress &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;":"&lt;/SPAN&gt; &amp;amp; PortNum &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;":"&lt;/SPAN&gt; &amp;amp; HostNames(HostNameINdex)
   Trace &lt;SPAN style="COLOR: maroon"&gt;"Binding = "&lt;/SPAN&gt; &amp;amp; BindingString 
   NewBindings(HostNameINdex) = BindingString
  next
        ' Modified by Chris Crowe - July &lt;SPAN style="COLOR: maroon"&gt;2006&lt;/SPAN&gt; (Start)
  
  &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgLogFolder &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
      NewWebServer.LogFileDirectory = ArgLogFolder
  end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
  
  &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgLogFilePeriod &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
         NewWebServer.LogFilePeriod = ArgLogFilePeriod
  end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
  
  ' Modified by Chris Crowe - July &lt;SPAN style="COLOR: maroon"&gt;2006&lt;/SPAN&gt; (End)
  NewWebServer.ServerBindings = NewBindings
  NewWebServer.ServerComment = ServerComment
  NewWebServer.SetInfo
  ' Now create the root directory &lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt;.
  Trace &lt;SPAN style="COLOR: maroon"&gt;"Setting the home directory..."&lt;/SPAN&gt;
  Set NewDir = NewWebServer.Create(&lt;SPAN style="COLOR: maroon"&gt;"IIsWebVirtualDir"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;"ROOT"&lt;/SPAN&gt;)
  NewDir.Path = RootDirectory
  NewDir.AccessRead = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
  ' Chris Crowe - July &lt;SPAN style="COLOR: maroon"&gt;2006&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgWrite = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;) then
      NewDir.AccessWrite = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;
  end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgExecute &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
      NewDir.AccessScript = ArgExecuteScripts
      NewDir.AccessExecute = ArgExecuteExecutables
  end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
  
  ' Modified by Chris crowe - January &lt;SPAN style="COLOR: maroon"&gt;2002&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (URL &amp;lt;&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
     trace &lt;SPAN style="COLOR: maroon"&gt;"Redirection to a URL: "&lt;/SPAN&gt; &amp;amp; URL
     URLOPTIONS= &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
     &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgURLEXACT = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;) then
     URLOPTIONS = &lt;SPAN style="COLOR: maroon"&gt;", EXACT_DESTINATION"&lt;/SPAN&gt;
     end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
     &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgURLCHILDONLY = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;) then
   &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (URLOPTIONS &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
    URLOPTIONS = URLOPTIONS &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;", CHILD_ONLY"&lt;/SPAN&gt; 
   &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;
      URLOPTIONS = &lt;SPAN style="COLOR: maroon"&gt;", CHILD_ONLY"&lt;/SPAN&gt; 
   end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
     end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
     &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgURLPERMANENT = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;) then
   &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (URLOPTIONS &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
    URLOPTIONS = URLOPTIONS &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;", PERMANENT"&lt;/SPAN&gt; 
   &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;
      URLOPTIONS = &lt;SPAN style="COLOR: maroon"&gt;", PERMANENT"&lt;/SPAN&gt; 
   end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
     end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
     trace &lt;SPAN style="COLOR: maroon"&gt;"Redirection Flags : "&lt;/SPAN&gt; &amp;amp; URLOPTIONS
        newDir.httpredirect= URL &amp;amp; URLOPTIONS
  end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
  ' Modified by Chris crowe - January &lt;SPAN style="COLOR: maroon"&gt;2002&lt;/SPAN&gt;
      
  
  Err.Clear
  NewDir.SetInfo
  ' Chris Crowe - July &lt;SPAN style="COLOR: maroon"&gt;2006&lt;/SPAN&gt;
  NewDir.AppCreate2 (ArgAppProtection)
  
  &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ArgAppFriendlyName &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;) then
      NewDir.AppFriendlyName = ArgAppFriendlyName
      NewDir.SetInfo
  end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
  If (Err.Number = &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) Then
   Trace &lt;SPAN style="COLOR: maroon"&gt;"Home directory set."&lt;/SPAN&gt;
  Else
   Display &lt;SPAN style="COLOR: maroon"&gt;"Error setting home directory."&lt;/SPAN&gt;
  End If
  Trace &lt;SPAN style="COLOR: maroon"&gt;"Web site created!"&lt;/SPAN&gt;
  If Start = True Then
   Trace &lt;SPAN style="COLOR: maroon"&gt;"Attempting to start new web server..."&lt;/SPAN&gt;
   Err.Clear
   Set NewWebServer = GetObject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://"&lt;/SPAN&gt; &amp;amp; comp &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;"/w3svc/"&lt;/SPAN&gt; &amp;amp; Index)
   NewWebServer.Start
   If Err.Number &amp;lt;&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt; Then
    Display &lt;SPAN style="COLOR: maroon"&gt;"Error starting web server!"&lt;/SPAN&gt;
    Err.Clear
   Else
    Trace &lt;SPAN style="COLOR: maroon"&gt;"Web server started succesfully!"&lt;/SPAN&gt;
   End If
  End If
 Next
End Sub

' Display the usage message
Sub DisplayUsage
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Usage: MakeWebSite &amp;lt;--RootDirectory|-r ROOT DIRECTORY&amp;gt;"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   &amp;lt;--Comment|-t SERVER COMMENT&amp;gt;"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--computer|-c COMPUTER1[,COMPUTER2...]]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--port|-o PORT NUM]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--IPAddress|-i IP ADDRESS]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--HostName|-h HOST NAME[,HOSTNAME2...]]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--SiteNumber|-n SITENUMBER]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--AppProtection Level { LOW, MEDIUM, HIGH } ]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--AppName Name]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--Write]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--Execute { NONE, SCRIPTS, EXECUTABLES } ]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--LogPeriod LogFilePeriod { DAILY, WEEKLY, MONTHLY, HOURLY}]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--LogFolder LogFileDirectory]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--URL RedirectionPath]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--URLExact]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--URLChildOnly]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--URLPermanent]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--DontStart]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--verbose|-v]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"                   [--help|-?]"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"WARNING: Only use Host Name if DNS is set up find the server."&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Example 1: MakeWebSite.vbs -r D:\Roots\Company11 --DontStart -t "&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;"My Company Site"&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Example 2: MakeWebSite.vbs -r D:\Roots\Company11 -h "&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;"www.iisfaq.com,www.iis.com"&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;" --DontStart &lt;BR&gt;                          -t "&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;"My Company Site"&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Example 3: MakeWebSite.vbs -r D:\Roots\Company11 -i 192.168.0.1 -t "&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;"My Company Site"&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;" &lt;BR&gt;                          --URL http://www.iisfaq.com --URLExact --URLPermanent"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Example 4: MakeWebSite.vbs -r D:\Roots\Company11 --DontStart -t "&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;"My Company Site"&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;" &lt;BR&gt;                          --LogPeriod MONTHLY --LogFolder c:\Root\Company1"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Example 5: MakeWebSite.vbs -r D:\Roots\Company11 --DontStart -t "&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;"My Company Site"&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;" &lt;BR&gt;                          &lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;--AppName XYZ --LogFolder c:\Root\Company1"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"Note: URLRedirection requires a HTTP:// prefix and a root directory also!"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;"      Write enables write access to the directory"&lt;/SPAN&gt;
 WScript.Echo &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;
 WScript.Quit (&lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt;)
End Sub
Sub Display(Msg)
 WScript.Echo Now &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;". Error Code: "&lt;/SPAN&gt; &amp;amp; Hex(Err) &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" - "&lt;/SPAN&gt; &amp;amp; err.Description &amp;amp;  &lt;SPAN style="COLOR: maroon"&gt;" - "&lt;/SPAN&gt; &amp;amp; Msg
End Sub
Sub Trace(Msg)
 &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; verbose = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt; then
  WScript.Echo Now &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" : "&lt;/SPAN&gt; &amp;amp; Msg 
 end &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
End Sub
&lt;/PRE&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/668.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2006/07/11/668.aspx</guid>
            <pubDate>Tue, 11 Jul 2006 06:37:00 GMT</pubDate>
            <wfw:comment>http://blog.crowe.co.nz/blog/comments/668.aspx</wfw:comment>
            <comments>http://blog.crowe.co.nz/blog/archive/2006/07/11/668.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/668.aspx</wfw:commentRss>
        </item>
        <item>
            <title>VBScript - How to search all sites and host headers for a particular string of characters?</title>
            <link>http://blog.crowe.co.nz/blog/archive/2006/07/08/666.aspx</link>
            <description>&lt;P&gt;The following script will allow you to search the local web server for all virtual servers that have been configured for a particular host header value. &lt;/P&gt;
&lt;P&gt;The script requires you to specify a value to seach for as a command line parameter.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Example&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;cscript EnumByHostHeader.vbs SearchString&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Where SearchString is some text to search for such as &lt;STRONG&gt;crowe&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;cscript EnumByHostHeader.vbs &lt;STRONG&gt;crowe&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The expected result is something like the following&lt;/P&gt;
&lt;TABLE cellSpacing=0 cellPadding=5 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;Searching for &lt;STRONG&gt;CROWE &lt;/STRONG&gt;in the host headers&lt;/P&gt;
&lt;P&gt;Web Site Instance ID - Server Comment - Host Header&lt;BR&gt;126606719 - photos.crowe.co.nz - PHOTOS.CROWE.CO.NZ&lt;BR&gt;1849151055 - rotties.crowe.co.nz - ROTTIES.CROWE.CO.NZ&lt;BR&gt;2021379493 - Blog (Maintenance) - BLOG.CROWE.CO.NZ&lt;BR&gt;415889539 - fish.crowe.co.nz - FISH.CROWE.CO.NZ&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;on&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;error&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;resume&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; Contains&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;Set&lt;/SPAN&gt; ArgObj = WScript.Arguments&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; ArgObj.Count &amp;lt; &lt;SPAN style="COLOR: maroon"&gt;1&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Then&lt;/SPAN&gt;&lt;BR&gt;Wscript.echo &lt;SPAN style="COLOR: maroon"&gt;"Please specify the name or part name to look for in the host header field!"&lt;/SPAN&gt;&lt;BR&gt;Wscript.echo &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;&lt;BR&gt;Wscript.echo &lt;SPAN style="COLOR: maroon"&gt;"Example"&lt;/SPAN&gt;&lt;BR&gt;Wscript.echo &lt;SPAN style="COLOR: maroon"&gt;"&amp;nbsp; cscript EnumByHostHeader.vbs ccrowe"&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;&lt;BR&gt;Contains = ucase(ArgObj.Item(&lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;))&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; websrv, site&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; Found&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; webinfo&lt;BR&gt;Found = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;&lt;BR&gt;WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"Searching for "&lt;/SPAN&gt; &amp;amp; Contains &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" in the host headers"&lt;/SPAN&gt;&lt;BR&gt;WScript.echo &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"Web Site Instance ID - Server Comment - Host Header"&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; websrv = getobject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://Localhost/W3SVC"&lt;/SPAN&gt;)&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (err &amp;lt;&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp; err.Clear&lt;BR&gt;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;each&lt;/SPAN&gt; site &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; websrv&lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (site.classname = &lt;SPAN style="COLOR: maroon"&gt;"IIsWebServer"&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bindings = Site.ServerBindings&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; Index = LBound(bindings) &lt;SPAN style="COLOR: blue"&gt;To&lt;/SPAN&gt; UBound(bindings)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Values = split(bindings(Index), &lt;SPAN style="COLOR: maroon"&gt;":"&lt;/SPAN&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HostHeader = ucase(Values(&lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (instr(HostHeader, Contains) &amp;gt; &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Found = &lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WScript.echo site.Name &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" - "&lt;/SPAN&gt; &amp;amp; _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; site.ServerComment &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" - "&lt;/SPAN&gt; &amp;amp; _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HostHeader&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (Found = &lt;SPAN style="COLOR: maroon"&gt;false&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp; WScript.echo &lt;SPAN style="COLOR: maroon"&gt;"The search term "&lt;/SPAN&gt; &amp;amp; Contains &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" was not found!"&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/666.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2006/07/08/666.aspx</guid>
            <pubDate>Sat, 08 Jul 2006 22:15:00 GMT</pubDate>
            <wfw:comment>http://blog.crowe.co.nz/blog/comments/666.aspx</wfw:comment>
            <comments>http://blog.crowe.co.nz/blog/archive/2006/07/08/666.aspx#feedback</comments>
            <slash:comments>24</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/666.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Some examples of scripting of IIS using ADSI, WMI from VB and C# including the new Microsoft.Web.Administration namespace</title>
            <link>http://blog.crowe.co.nz/blog/archive/2006/07/04/663.aspx</link>
            <description>&lt;P&gt;Below are some simple examples of how to talk to IIS via ADSI, WMI and the new IIS 7 only .NET Managed Provider. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;The IIS ADSI Provider&lt;/B&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The IIS ADSI provider exposes COM Automation objects that you can use within command-line scripts, ASP pages, or custom applications to change IIS configuration values stored in the IIS metabase. IIS ADSI objects can be accessed and manipulated by any language that supports automation, such as Microsoft&amp;#174; Visual Basic&amp;#174; Scripting Edition (VBScript), Microsoft JScript&amp;#174;, Perl, Microsoft Active Server Pages (ASP), Visual Basic, Java, or Microsoft C++.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;B&gt;The IIS WMI Provider&lt;/B&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Windows Management Instrumentation (WMI) is a technology that allows administrators to programmatically manage and configure the Windows operating system and Windows applications. Beginning with IIS 6.0, IIS includes a WMI provider that exposes programming interfaces that can be used to query and configure the IIS metabase.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;B&gt;The Microsoft.Web.Administration namespace in IIS 7&lt;/B&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;This is a new .NET managed namespace that will allow you to talk to IIS 7 and configure all aspects of the server. This API is designed to be simple to code against in an &amp;#8220;intellisense-driven&amp;#8221; sort of way. At the root level a class called ServerManager exposes all the functionality you will need. At this time it appears that this will not be able to be used from Windows XP but by the time Vista &amp;amp; Windows Server are released this may have been ported to run on a Windows XP client.&lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For more details on these technologies see the following resources:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;Active Directory Service Interfaces Overview&lt;/B&gt;&lt;BR&gt;&lt;A href="http://www.microsoft.com/windows2000/techinfo/howitworks/activedirectory/adsilinks.asp"&gt;http://www.microsoft.com/windows2000/techinfo/howitworks/activedirectory/adsilinks.asp&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;WMI - Windows Management Instrumentation&lt;BR&gt;&lt;/B&gt;&lt;A href="http://www.microsoft.com/whdc/system/pnppwr/wmi/default.mspx"&gt;http://www.microsoft.com/whdc/system/pnppwr/wmi/default.mspx&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;Administering IIS Programmatically (IIS 6.0)&lt;/B&gt;&lt;BR&gt;&lt;A href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/9041b0a5-c314-46d9-8f56-01506687f357.mspx"&gt;http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/9041b0a5-c314-46d9-8f56-01506687f357.mspx&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;Pre-release documentation on Microsoft.Web.Administration&lt;/B&gt;&lt;BR&gt;&lt;A href="http://windowssdk.msdn.microsoft.com/en-us/library/microsoft.web.administration.aspx"&gt;http://windowssdk.msdn.microsoft.com/en-us/library/microsoft.web.administration.aspx&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;HR&gt;

&lt;H2&gt;C# -Using System.DirectoryServices and ADSI&lt;/H2&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System;
&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Collections.Generic;
&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Text;
&lt;SPAN style="COLOR: green"&gt;// Must be specified and a reference added to System.DirectoryServices&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.DirectoryServices;

&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; Console_EnumSites_ADSI_CSharp
{
    &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; Program
    {
        &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)
        {
            DirectoryEntry entry = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; DirectoryEntry(&lt;SPAN style="COLOR: maroon"&gt;"IIS://LocalHost/W3SVC"&lt;/SPAN&gt;);
            &lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (DirectoryEntry site &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; entry.Children)
            {
                &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (site.SchemaClassName == &lt;SPAN style="COLOR: maroon"&gt;"IIsWebServer"&lt;/SPAN&gt;)
                {
                    &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; ServerComment = site.Properties[&lt;SPAN style="COLOR: maroon"&gt;"ServerComment"&lt;/SPAN&gt;].Value.ToString();
                    Console.WriteLine(ServerComment + &lt;SPAN style="COLOR: maroon"&gt;" ("&lt;/SPAN&gt; + site.Name + &lt;SPAN style="COLOR: maroon"&gt;")"&lt;/SPAN&gt;);
                }
            }
        }
    }
}
&lt;/PRE&gt;
&lt;HR&gt;

&lt;H2&gt;VB -Using ADSI&lt;/H2&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;on&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;error&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;resume&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;

&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; websrv, site
&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; webinfo

&lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; websrv = getobject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://Localhost/W3SVC"&lt;/SPAN&gt;)
&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (err &amp;lt;&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;
    err.Clear
    &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;each&lt;/SPAN&gt; site &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; websrv
        &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (site.classname = &lt;SPAN style="COLOR: maroon"&gt;"IIsWebServer"&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;
            WScript.echo Site.ServerComment &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" ("&lt;/SPAN&gt; &amp;amp; Site.Name &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;")"&lt;/SPAN&gt;
        &lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;HR&gt;

&lt;H2&gt;C# -Using System.Managment and WMI&lt;/H2&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; Console_EnumSites_WMI_CSharp
{
    &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; Program
    {
        &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; void Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)
        {
            ManagementScope oms = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ManagementScope(@&lt;SPAN style="COLOR: maroon"&gt;"\\.\root\MicrosoftIISv2"&lt;/SPAN&gt;);
            oms.Connect();

            ObjectQuery oQuery = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ObjectQuery(&lt;SPAN style="COLOR: maroon"&gt;"select * from IISWebServerSetting"&lt;/SPAN&gt;);
            ManagementObjectSearcher oSearcher = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ManagementObjectSearcher(oms, oQuery);
            foreach (ManagementObject oreturn &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; oSearcher.&lt;SPAN style="COLOR: blue"&gt;Get&lt;/SPAN&gt;())
            {
                Console.WriteLine(oreturn[&lt;SPAN style="COLOR: maroon"&gt;"ServerComment"&lt;/SPAN&gt;]+&lt;SPAN style="COLOR: maroon"&gt;" ("&lt;/SPAN&gt;+oreturn[&lt;SPAN style="COLOR: maroon"&gt;"Name"&lt;/SPAN&gt;]+&lt;SPAN style="COLOR: maroon"&gt;")"&lt;/SPAN&gt;);
            }
            Console.Read();
        }
    }
}
&lt;/PRE&gt;
&lt;HR&gt;

&lt;H2&gt;C# -Using Microsoft.Web.Administration ( II7 Only )&lt;/H2&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;

&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; Console_EnumSites
{
    &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; Program
    {
        &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; void Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)
        {
            ServerManager iisManager = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ServerManager();

            Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"Display IIS Sites in IIS 7"&lt;/SPAN&gt;);
            Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;.PadLeft(&lt;SPAN style="COLOR: maroon"&gt;40&lt;/SPAN&gt;,&lt;SPAN style="COLOR: green"&gt;'-'));&lt;/SPAN&gt;
            foreach(Site site &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; iisManager.Sites)
            {
                Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"{0} {1}"&lt;/SPAN&gt;, site.Id.ToString().PadRight(&lt;SPAN style="COLOR: maroon"&gt;12&lt;/SPAN&gt;), site.Name);                
            }
            Console.Read();
        }
    }
}
&lt;/PRE&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/663.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2006/07/04/663.aspx</guid>
            <pubDate>Tue, 04 Jul 2006 09:18:00 GMT</pubDate>
            <wfw:comment>http://blog.crowe.co.nz/blog/comments/663.aspx</wfw:comment>
            <comments>http://blog.crowe.co.nz/blog/archive/2006/07/04/663.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/663.aspx</wfw:commentRss>
        </item>
        <item>
            <title>c# - How to display the HttpExpires property and display its meaning...</title>
            <link>http://blog.crowe.co.nz/blog/archive/2006/06/30/661.aspx</link>
            <description>&lt;P&gt;The HttpExpires property is documented at the following URL.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/3e1d9fbb-6910-4648-a2bb-11a945ca7980.mspx?mfr=true"&gt;http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/3e1d9fbb-6910-4648-a2bb-11a945ca7980.mspx?mfr=true&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This simple c# console application will display the settings for the HttpExpires property at the root level of the default web site.&lt;/P&gt;
&lt;P&gt;Basically the value is encoded as follows:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If the value is a blank string then there is no content expiry.&lt;BR&gt;&lt;/LI&gt;
&lt;LI&gt;If the value starts with a &lt;STRONG&gt;D&lt;/STRONG&gt;, then it is using a dynamic expiration period. This period is appended after the D and is stored as the number of seconds in hexidecimal format.&lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;Example: &amp;#8220;D, 0x15180&amp;#8221;&amp;nbsp;&amp;nbsp;&amp;nbsp; - this 0x15180 is the same as 86,400 seconds or 1 day.&lt;BR&gt;&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;If the value starts with an &lt;STRONG&gt;S&lt;/STRONG&gt; then the following value is a GMT time of when the expiration will take place.&lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;Example:&amp;nbsp;&amp;#8220;S, Sat, 08 Jul 2006 12:00:00 GMT&amp;#8221;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Collections.Generic;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Text;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.DirectoryServices;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; IISHTTPExpires&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; Program&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"IIS HTTP Expires - c#"&lt;/SPAN&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Serve to connect to...&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; ServerName = &lt;SPAN style="COLOR: maroon"&gt;"LocalHost"&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Define the path to the metabase&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; MetabasePath = &lt;SPAN style="COLOR: maroon"&gt;"IIS://"&lt;/SPAN&gt; + ServerName + &lt;SPAN style="COLOR: maroon"&gt;"/W3SVC/1/ROOT"&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;try&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Talk to the IIS Metabase to read the MimeMap Metabase key&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DirectoryEntry Entry = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; DirectoryEntry(MetabasePath);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Get the Mime Types as a collection&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PropertyValueCollection pvc = Entry.Properties[&lt;SPAN style="COLOR: maroon"&gt;"HTTPExpires"&lt;/SPAN&gt;];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; HttpExpires = pvc.Value.ToString();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (HttpExpires.Length == &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"HttpExpires is not enabled!"&lt;/SPAN&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;char&lt;/SPAN&gt; HttpExpiresType = HttpExpires[&lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;switch&lt;/SPAN&gt; (HttpExpiresType)
                    {
                        &lt;SPAN style="COLOR: blue"&gt;case&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;'D'&lt;/SPAN&gt;:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; Seconds = HttpExpires.Substring(&lt;SPAN style="COLOR: maroon"&gt;3&lt;/SPAN&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (Seconds == &lt;SPAN style="COLOR: maroon"&gt;"0"&lt;/SPAN&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Seconds = &lt;SPAN style="COLOR: maroon"&gt;"Immediately"&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (Seconds.StartsWith(&lt;SPAN style="COLOR: maroon"&gt;"0x"&lt;/SPAN&gt;)==&lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Seconds = &lt;SPAN style="COLOR: maroon"&gt;"in "&lt;/SPAN&gt; + &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;.Parse(HttpExpires.Substring(&lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;), &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Globalization.NumberStyles.HexNumber).ToString() + &lt;SPAN style="COLOR: maroon"&gt;" Seconds"&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Seconds = &lt;SPAN style="COLOR: maroon"&gt;"in "&lt;/SPAN&gt; + Seconds + &lt;SPAN style="COLOR: maroon"&gt;" Seconds"&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"HttpExpires {0}"&lt;/SPAN&gt;, Seconds);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;case&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;'S'&lt;/SPAN&gt;:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"HttpExpires {0}"&lt;/SPAN&gt;, HttpExpires.Substring(&lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;default&lt;/SPAN&gt;:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"Unknown HttpExpires Type : {0}"&lt;/SPAN&gt;, HttpExpiresType);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;catch&lt;/SPAN&gt; (Exception ex)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"Failed to read HttpExpires property with the following exception: \n{0}"&lt;/SPAN&gt;,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ex.Message);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;finally&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.Read();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/661.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2006/06/30/661.aspx</guid>
            <pubDate>Fri, 30 Jun 2006 10:38:00 GMT</pubDate>
            <wfw:comment>http://blog.crowe.co.nz/blog/comments/661.aspx</wfw:comment>
            <comments>http://blog.crowe.co.nz/blog/archive/2006/06/30/661.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/661.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>