Exemplo n.º 1
0
 private void AfterInstallEventHandler(object sender, InstallEventArgs e)
 {
     serviceController1 = new System.ServiceProcess.ServiceController(SERVICE_NAME);
     serviceController1.Start();
     serviceController1.WaitForStatus(
         System.ServiceProcess.ServiceControllerStatus.Running,
         TimeSpan.FromMinutes(1));
     serviceController1.Close();
 }
Exemplo n.º 2
0
        public static bool StopService(string serviceName, TimeSpan timeSpan)
        {
            if (!ExistService(serviceName))
            {
                return(false);
            }
            System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController(serviceName);
            if (sc.Status != System.ServiceProcess.ServiceControllerStatus.Stopped && sc.Status != System.ServiceProcess.ServiceControllerStatus.StopPending)
            {
                sc.Stop();
            }
            sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Stopped, timeSpan);
            var isok = sc.Status == System.ServiceProcess.ServiceControllerStatus.Stopped;

            sc.Close();
            sc.Dispose();
            return(isok);
        }
Exemplo n.º 3
0
		private void AfterInstallEventHandler(object sender, InstallEventArgs e)
		{
			serviceController1 = new System.ServiceProcess.ServiceController(SERVICE_NAME);
			serviceController1.Start();
			serviceController1.WaitForStatus(
				System.ServiceProcess.ServiceControllerStatus.Running,
				TimeSpan.FromMinutes(1));
			serviceController1.Close();
		}