static void Main() { int RunAsMode = GetRegistrySetting(); bool RegNeedsSetting = false; if (RunAsMode < 0) { RegNeedsSetting = true; } WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); bool hasAdministrativeRight = principal.IsInRole(WindowsBuiltInRole.Administrator); if (RunAsMode == 1) { if (!hasAdministrativeRight) { if (RunElevated(Application.ExecutablePath)) { Application.Exit(); return; } } else { // let the old process finish System.Threading.Thread.Sleep(500); } } Process[] LauncherProcesses = Process.GetProcessesByName("ProjectSWG Launcher"); foreach (Process p in LauncherProcesses) { Debug.WriteLine(p.ToString() ); if (p.Id == Process.GetCurrentProcess().Id) { continue; } MessageBox.Show("ProjectSWG Launcher is already running. If it doesn't respond, close it manually through task manager. (Ctrl+Shift+Esc on some Windows versions).","ProjectSWG Launcher",MessageBoxButtons.OK); Application.Exit(); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); GuiController gc = new GuiController(RunAsMode); gc.ReadConfig(); gc.CheckScanNeeded(); gc.RunLauncher(); if (RegNeedsSetting) { gc.LaunchAdmSettings(); } Application.Run(); }