/// <summary> /// Close the app and run the selected one /// </summary> public static void RunAsAdmin(IAdminForm app, string arguments) { // Do nothing if (HasAdminPrivileges()) { return; } //Vista or higher check if (Environment.OSVersion.Version.Major >= 6) { // Get path string path = app.GetAppPath(); Console.WriteLine(path); Process p = new Process(); ProcessStartInfo psi = new ProcessStartInfo(path, arguments); p.StartInfo = psi; if (p.StartInfo.Verb == string.Empty) { p.StartInfo.Verb = "runas"; } else { p.StartInfo.Verb += "runas"; } p.Start(); Application.Exit(); } else { throw new SystemException("OS version not supported"); } }