Answers for "iis restart c#"

2

restart IIS

iisreset /stop /timeout:60
taskkill /F /FI "SERVICES eq was"
iisreset /start
Posted by: Guest on August-12-2021
0

IIS RESTART c#

public static void RestartService(string serviceName, int timeoutMilliseconds)
{
  ServiceController service = new ServiceController(serviceName);
  try
  {
    int millisec1 = Environment.TickCount;
    TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);

    service.Stop();
    service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);

    // count the rest of the timeout
    int millisec2 = Environment.TickCount;
    timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds - (millisec2-millisec1));

    service.Start();
    service.WaitForStatus(ServiceControllerStatus.Running, timeout);
  }
  catch
  {
    // ...
  }
}
Posted by: Guest on April-13-2022

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language