WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());bool administrativeMode = principal.IsInRole(WindowsBuiltInRole.Administrator);if (!administrativeMode) { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.Verb = "runas"; startInfo.FileName = Assembly.GetExecutingAssembly().CodeBase; try { Process.Start(startInfo); Application.Exit(); } catch { //User denied access return; } return;}