public static void SetPermisions() { if (!IsAdmin()) { var exeName = Process.GetCurrentProcess().MainModule.FileName; ProcessStartInfo startInfo = new ProcessStartInfo(exeName); startInfo.Verb = "runas"; startInfo.UseShellExecute = true; Process.Start(startInfo); return; } else { Console.WriteLine("WE have Admin rights"); } } public static bool IsAdmin() { WindowsIdentity id = WindowsIdentity.GetCurrent(); //get the current identity of the current user WindowsPrincipal p = new WindowsPrincipal(id); //setup a new principal opbject with the above id return p.IsInRole(WindowsBuiltInRole.Administrator); //return the state of the above principal objects role }