I need to be able to Start/Stop the IIS in C#. I've been tasked with creating this module by my manager. The following is my attempt:
ServiceController service = new ServiceController("w3svc");
service.Stop();
I am getting the following exception:
Cannot open w3svc service on computer '.'.
I am writing the code to stop the IIS on the local machine.
I also tried IISAdmin
as the servicename, but IISAdmin
could not be found on my computer.