public static void RunContextMenuIntegration(string option) { switch (option) { case OPT_ADD: string fullPath = RuntimeInfo.ExeLocation; if (!RuntimeInfo.IsExeInAppFolder) { bool v = CliOutput.ReadConfirm("Could not find exe in system path. Add now?"); if (v) { RuntimeInfo.Setup(); return; } } // Add command string[] commandCode = { "@echo off", String.Format("reg.exe add {0} /ve /d \"{1} \"\"%%1\"\"\" /f >nul", RuntimeInfo.REG_SHELL_CMD, fullPath) }; Cli.CreateRunBatchFile("add_to_menu.bat", commandCode); // Add icon string[] iconCode = { "@echo off", String.Format("reg.exe add {0} /v Icon /d \"{1}\" /f >nul",RuntimeInfo.REG_SHELL, fullPath) }; Cli.CreateRunBatchFile("add_icon_to_menu.bat", iconCode); break; case OPT_REM: // reg delete HKEY_CLASSES_ROOT\*\shell\SmartImage // const string DEL = @"reg delete HKEY_CLASSES_ROOT\*\shell\SmartImage"; string[] code = { "@echo off", String.Format(@"reg.exe delete {0} /f >nul", RuntimeInfo.REG_SHELL) }; Cli.CreateRunBatchFile("rem_from_menu.bat", code); break; } }
private static bool IsFileValid(string img) { if (!File.Exists(img)) { CliOutput.WriteError("File does not exist: {0}", img); return(false); } bool extOkay = ImageExtensions.Any(img.EndsWith); if (!extOkay) { return(CliOutput.ReadConfirm("File extension is not recognized as a common image format. Continue?")); } return(true); }
public static void Add() { string fullPath = RuntimeInfo.ExeLocation; if (!RuntimeInfo.IsExeInAppFolder) { bool v = CliOutput.ReadConfirm("Could not find exe in system path. Add now?"); if (v) { PathCommand.Add(); return; } if (fullPath == null) { throw new ApplicationException(); } } // Add command string[] commandCode = { "@echo off", String.Format("reg.exe add {0} /ve /d \"{1} \"\"%%1\"\"\" /f >nul",RuntimeInfo.REG_SHELL_CMD, fullPath) }; Cli.CreateRunBatchFile("add_to_menu.bat", commandCode); // Add icon string[] iconCode = { "@echo off", String.Format("reg.exe add {0} /v Icon /d \"{1}\" /f >nul",RuntimeInfo.REG_SHELL, fullPath), }; Cli.CreateRunBatchFile("add_icon_to_menu.bat", iconCode); }