Restarting IIS programmatically

后端 未结 5 1117
闹比i
闹比i 2020-12-30 18:04

I need to restart IIS from a C#/.NET application. This seems like a trivial issue, but I haven\'t had success thus far, and none of the answers from this question have worke

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-30 18:51

    Another option to start the IIS:

    string serviceName = "W3SVC"; //W3SVC refers to IIS service
    ServiceController service = new ServiceController(serviceName);
    service.Start();
    service.WaitForStatus(ServiceControllerStatus.Running);// Wait till the service started and is running
    

提交回复
热议问题