You can use Microsoft.Web.Administration or Microsoft.Web.management
namespaces that are new for IIS7 to do this vs. ADSI. One thing if you are
trying to use legacy scripts is make sure the Vista RC1 client has the IIS6
Management Compatibility is installed.
'Here is an article I did with some code samples for IIS7
http://weblogs.asp.net/steveschofield/archive/2006/09/10/test-post.aspx
Steve Schofield
Microsoft MVP - IIS
<fredfrog22 DeleteThis @hotmail.com> wrote in message
news:1160042753.270423.127560@m73g2000cwd.googlegroups.com...
> Hi,
>
> The following is an extract from a C# console application that creates
> a Virtual Directory on IIS 5 or 6.
>
> This code works on XP, Windows 2003 Server, Windows 2000.
>
> It does not work on Windows Vista Release Candidate 1 (IIS 7).
>
> The below line
>
> pcProps[VDPROP_PATH].Value = strPath;
>
> throws the exception "Path not found".
>
> Note that the user running the exe has administrator rights on the
> machine.
>
> Also, this may be a related issue:
>
> The Microsoft VB script C:\Inetpub\Adminscripts\mkwebdir.vbs no longer
> works on Windows Vista RC1 when logged in as an administrator.
>
> Interestingly, I have found that other sample code downloaded from the
> Internet that creates virtual directories does not work on Vista
> either.
>
> Thanks for your help.
>
> +++++++++++
>
> Code extract:
> DirectoryEntry deRoot = new DirectoryEntry(IIS_DIR);
>
> if (null != deRoot)
>
> try
> {
> // check to see if this Virtual Directory already exists
> m_deVirtualDir = deRoot.Children.Add(m_strVirtualDir,
> IIS_SCHEMA_VIRTUAL_DIR);
> }
> catch
> {
> try
> {
> String strDir = IIS_DIR + "/" + m_strVirtualDir;
> m_deVirtualDir = new DirectoryEntry(IIS_DIR + "/" +
> m_strVirtualDir);
> }
> catch
> {
> }
> }
>
> if (null != m_deVirtualDir)
> {
> // commit the changes so far!
> deRoot.CommitChanges();
> m_deVirtualDir.CommitChanges();
>
> // now we need to set up some properties of the new virtual
> // directory
> PropertyCollection pcProps = m_deVirtualDir.Properties;
>
>
> // set the Path to the Virtual Directory
> string strPath = m_strIISPath + "\\" + m_strVirtualDir;
>
> // exception generated here
> pcProps[VDPROP_PATH].Value = strPath;
>
> etc etc
>