public static int Main(string[] args) { MutexLock.Lock(); try { XmlTool.FixXml(); ExternalFunctionalityManager.Init(Functions); RootCommand rootCommand = new RootCommand(); PackageManagement.RegisterCommands(rootCommand); CacheManagement.RegisterCommands(rootCommand); ReposManagement.RegisterCommands(rootCommand); Other.RegisterCommands(rootCommand); return(rootCommand.InvokeAsync(args).Result); } catch (Exception e) { Console.WriteLine($"FAILED: {e}"); return(1); } finally { MutexLock.Unlock(); } }
public static int Main(string[] args) { Thread.Sleep(2000); MutexLock.Lock(); try { ExternalFunctionalityManager.Init(new UtLibFunctions()); RootCommand rootCommand = new RootCommand(); Command install = new Command("install", "Install UpTool") { new Option <bool>(new[] { "--noPrep", "-p" }, "Doesn't initialize repos. Use with caution!") }; install.AddAlias("-i"); install.AddAlias("i"); install.Handler = CommandHandler.Create <bool>(Install); rootCommand.AddCommand(install); return(rootCommand.InvokeAsync(args).Result); } catch (Exception e) { Console.WriteLine($"FAILED: {e}"); return(1); } finally { MutexLock.Unlock(); } }
public InstallerForm() { ExternalFunctionalityManager.Init(new UtLibFunctionsGui(Log)); InitializeComponent(); Step(0, "Initialized"); _log = _log.TrimStart(Environment.NewLine.ToCharArray()); _rkApp = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true); pathBox.Checked = !File.Exists(PathTool.InfoXml) || Path.Content.Contains(Path.GetName(PathTool.GetRelative("Install"))); startupBox.Checked = pathBox.Checked && _rkApp.GetValue(AppName) != null; updateAppsBox.Checked = pathBox.Checked && startupBox.Checked && (string)_rkApp.GetValue(AppName) == "uptool dist-upgrade"; }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); BuildSplash(); Splash.Show(); //new Thread(() => { Splash.ShowDialog(); }).Start(); try { MutexLock.Lock(); } catch (MutexLockLockedException) { Console.WriteLine("Mutex property of other process, quitting"); Process[] processes = Process.GetProcessesByName("UpTool2"); if (processes.Length > 0) { WindowHelper.BringProcessToFront(Process.GetProcessesByName("UpTool2")[0]); } return; } #if !DEBUG try { #endif ExternalFunctionalityManager.Init(new UtLibFunctions()); SetSplash(1, "Initializing paths"); if (!Directory.Exists(PathTool.Dir)) { Directory.CreateDirectory(PathTool.Dir); } FixXml(); SetSplash(2, "Performing checks"); try { UpToolLib.UpdateCheck.Reload(); Online = true; } catch { Online = false; } if (Application.ExecutablePath != PathTool.GetRelative("Install", "UpTool2.dll")) { Splash.Invoke((Action)(() => MessageBox.Show(Splash, $"WARNING!{Environment.NewLine}Running from outside the install directory is not recommended!") )); } if (!Directory.Exists(PathTool.GetRelative("Apps"))) { Directory.CreateDirectory(PathTool.GetRelative("Apps")); } if (!Online) { SetSplash(7, "Opening"); } if (!Online || UpdateCheck()) { Application.Run(new MainForm()); } #if !DEBUG } catch (Exception e1) { try { Splash.Invoke((Action)Splash.Hide); } catch { Console.WriteLine("Failed to hide splash"); } MessageBox.Show(e1.ToString()); } finally { MutexLock.Unlock(); } #endif }