Check if an IIS website exists with C#

        /// <summary>
        /// Check if a website on the given server exist.
        /// Check on websitename (ServerComment) is case insensitive.
        /// </summary>
        /// <param name="serverName">Name of the IIS server e.g. localhost</param>
        /// <param name="websiteName">Name of the website e.g. test</param>
        /// <returns></returns>
        public bool DoesWebsiteExist(string serverName, string websiteName)
            bool result = false;

            DirectoryEntry w3svc = new DirectoryEntry(string.Format("IIS://{0}/w3svc", serverName));

            foreach (DirectoryEntry site in w3svc.Children)
                if (site.Properties["ServerComment"] != null)
                    if (site.Properties["ServerComment"].Value != null)
                        if (string.Compare(site.Properties["ServerComment"].Value.ToString(), websiteName, false) == 0)
                            result = true;

            return result;

NANT: Build Microsoft VisualStudio solutions and configure environments

I use NANT to build Microsoft VisualStudio solutions and after deploying software with msi packages, I use NANT to configure the environment (Creating WebSite, Virtual Directories, Custom Eventlogs, register services, create folders, create shares etc)

More information on NANT can be found, here:, including documentation for task, types and functions.

I use Edirot4NANT as an GUI tool to run NANT tasks:

Using quotes in XML

To use quotes in xml, use “&quot;

<exec program="CMD.EXE"
              commandline="/C &quot;${installPath}\DatabaseInstallation.cmd&quot;"
            <arg value="${Database_DataSource}" />