Esempio n. 1
0
 public static void Create(string path, bool elevated)
 {
     if (Directory.Exists(path))
     {
         throw new AlreadyExistsException();
     }
     try
     {
         Directory.CreateDirectory(path);
     }
     catch (UnauthorizedAccessException)
     {
         if (elevated || !ElevatedOperation.CreateFolder(path))
         {
             throw;
         }
     }
 }
Esempio n. 2
0
 public static void StopServices(string[] services)
 {
     if (!AdminRights.IsAdmin())
     {
         ElevatedOperation.StopServices(services);
     }
     else
     {
         foreach (var service in services)
         {
             try
             {
                 var controller = new ServiceController(service);
                 controller.Stop();
             }
             catch { }
         }
     }
 }