예제 #1
0
 private void EnableService(string serviceName)
 {
     if (String.IsNullOrWhiteSpace(serviceName))
     {
         throw new ArgumentNullException(nameof(serviceName));
     }
     using (var service = new ServiceEditor(serviceName))
     {
         service.EnableService();
         Logger.LogInfo(string.Format("Service enabled: {0}", serviceName));
     }
 }
        public bool EnableService(string serviceName)
        {
            if (string.IsNullOrWhiteSpace(serviceName))
            {
                throw new ArgumentNullException(nameof(serviceName));
            }
            RemoveWu10FromFileName(serviceName);
            var enabledRealtime = false;

            using (var service = new ServiceEditor(serviceName))
            {
                if (!service.IsServiceRunAsLocalSystem())
                {
                    service.SetAccountAsLocalSystem();
                }
                enabledRealtime = service.EnableService();
            }
            return(enabledRealtime);
        }