ServiceController controller = new ServiceController();
controller.MachineName = ".";
controller.ServiceName = "IISADMIN";
Console.WriteLine(controller.Status.ToString());
if (controller.Status == ServiceControllerStatus.Running)
{
// Stop the service
controller.Stop();// Start the service
controller.WaitForStatus(ServiceControllerStatus.Stopped);
//controller.Start();
}
else if (controller.Status == ServiceControllerStatus.Stopped)
{
controller.Start();
//controller.WaitForStatus(ServiceControllerStatus.Running);
//controller.Stop();
}
0 comments:
Post a Comment