Exemple #1
0
        static void Main(string[] args) // Entry point
        {
            List <ServiceController> sc = null;

            try
            {
                if (args.Length == 0)
                {
                    throw new Exception();
                }
                sc = (from i in ArgsProcessing.ScsFrom(args) select new ServiceController(i)).ToList();
                sc = sc.Where(n => n.Status.ToString().Equals("Stopped")).ToList();
                if (sc.Count != 0)
                {
                    ArgsProcessing.IsServices = true;
                }
                else
                {
                    throw new Exception();
                }
            }
            catch { sc = null; }
            if (ArgsProcessing.IsServices)
            {
                RunProcessing.ServiceProcessing(sc, args);
            }
            if (args.Length > 0)
            {
                RunProcessing.Start(ArgsProcessing.FileFrom(args), ArgsProcessing.ArgsFrom(args));
            }
        }
 public static void ServiceProcessing(List <ServiceController> scs, string[] args) // Launch services
 {
     if (scs.Count() != 0)
     {
         if (!IsAdmin())
         {
             Runas(ArgsProcessing.ArgsToStr(args));
         }
         foreach (var i in scs)
         {
             try
             {
                 i.Start();
                 i.Refresh();
                 while (i.Status == ServiceControllerStatus.StartPending)
                 {
                     Thread.Sleep(500);
                     i.Refresh();
                 }
             }
             catch { continue; }
         }
     }
 }