Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I access remote IIS server by c# code.
Like in I am in my local machine and I login to my remote server machine ABC001 where my .net application is deployed.

Now how do I access that IIS(ABC001) from my local machine and Start/Stop the IIS through C# code.


What I have tried:

string path = "IIS://{yourservername}/W3SVC";

        using (DirectoryEntry w3svc = new DirectoryEntry(path))
        {
            foreach (DirectoryEntry entry in w3svc.Children)
            {
                if (entry.SchemaClassName == "IIsWebServer")
                {
                    string websiteName = (string)entry.Properties["ServerComment"].Value;
                }
            }
        }
Posted
Comments
David_Wimbley 14-Feb-18 13:43pm    
I think you need to look into powershell remoting or something like psexec rather than doing this through c#. I've never seen a protocal of "IIS://" before so im not even sure what you are attempting.

But psexec was built for stuff like this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900