Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

C# How to get iis version

Back to Forum: Tech Off
  • User profile image
    shax

    I need to show the iis version using C# that works under server 2003, i'm having some troubles using the System.DirectoryServices and the property "MajorIIsVersionNumber" (>= IIS 6.0 )
    Can anyone help me? tkns

  • User profile image
    ben2004uk

    What I did with this was to check the OS Version. 2000 can only have IIS5 XP can only have IIS5.1 2003 can only have IIS6 Vista can only have IIS7 So when I wanted to make sure the version of IIS installed supports Application Pooling, I did a check to make sure the OS was above 5.1 (XP). Hope this will help. Ben

  • User profile image
    shax

    done but only works under Windows Server 2003.


    using System.Management;

    ConnectionOptions co = new ConnectionOptions();
    co.Username = user;
    co.Password = password;

    ManagementScope ms = new ManagementScope("\\\\" + host + "\\root\\MicrosoftIISv2", co);

    ObjectQuery oq = new ObjectQuery("SELECT * FROM " + "IIsWebInfo");
    ManagementObjectSearcher query = new ManagementObjectSearcher(ms, oq);
    ManagementObjectCollection queryCollection = query.Get();

    foreach (ManagementObject mo in queryCollection)
    {
             Console.WriteLine(mo["MajorIIsVersionNumber"].ToString());
             Console.WriteLine(mo["MinorIIsVersionNumber"].ToString());
    }

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.