private static void AddRegistryContext() { if (!OperatingSystem.IsWindows()) { return; } Patcher window = Patcher; window.WriteLine("Do you want to add TML.Patcher.Frontend to your file context menu? Please ensure that this program is located in a location it will not move from."); window.WriteLine("<y/n> (or 'p' to skip for now and preserve the prompt for later)"); ConsoleKeyInfo pressedKey = Console.ReadKey(); window.WriteLine(); if (pressedKey.Key == ConsoleKey.P) { return; } if (pressedKey.Key != ConsoleKey.Y) { Configuration.ShowRegistryAdditionPrompt = false; return; } try { RegistryKey open = Registry.ClassesRoot.CreateSubKey("*\\shell\\Open with TML.Patcher"); RegistryKey command = open.CreateSubKey("command"); open.SetValue(null, "Open with TML.Patcher"); open.SetValue("icon", Path.Combine(ExePath, "TML.Patcher.Frontend.exe")); command.SetValue(null, $"{Path.Combine(ExePath, "TML.Patcher.Frontend.exe")} \"%1\""); } catch (UnauthorizedAccessException) { Console.WriteLine("Insufficient permissions to modify the registry. Please re-launch with admin permissions to add to your context menu, otherwise press any key to continue."); Console.ReadKey(); } Configuration.ShowRegistryAdditionPrompt = false; }
public static void Main(string[] args) { Console.Title = "TMLPatcher - by convicted tomatophile"; Thread.CurrentThread.Name = "Main"; Instance = new Patcher(); ConsoleAPI.Window = Instance; ConsoleAPI.Initialize(); ConsoleAPI.ParseParameters(args); Patcher.InitializeConsoleOptions(); Patcher.InitializeProgramOptions(); if (Configuration.ShowIlSpyCmdInstallPrompt) { InstallILSpyCMD(); } Instance.WriteStaticText(false); Instance.CheckForUndefinedPath(); ConsoleAPI.SelectedOptionSet.ListForOption(); }