public static List <Browser> find() { List <Browser> browsers = new List <Browser>(); //special case , firefox+firefox developer both installed //(only works if firefox installed in default directory) var ff_path = Path.Combine( Program.ProgramFilesx86(), @"Mozilla Firefox\firefox.exe"); if (File.Exists(ff_path)) { browsers.Add(new Browser() { name = "FireFox", exec = ff_path, icon = IconExtractor.fromFile(ff_path) }); } //special case , Edge var edge_path = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe"); if (File.Exists(edge_path)) { browsers.Add(new Browser() { name = "Edge", //exec=edge_path, // http://answers.microsoft.com/en-us/insider/forum/insider_internet-insider_spartan/how-to-start-microsoft-edge-from-command-line/25d0ba93-4e8b-41cb-adde-461d8fb58ec1 exec = "edge", icon = IconExtractor.fromFile(edge_path) }); } //gather browsers from registry using (RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) browsers.AddRange(find(hklm)); using (RegistryKey hkcu = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32)) browsers.AddRange(find(hkcu)); //remove myself browsers = browsers.Where(x => Path.GetFileName(x.exec).ToLower() != Path.GetFileName(Application.ExecutablePath).ToLower()).ToList(); //remove duplicates browsers = browsers.GroupBy(browser => browser.exec) .Select(group => group.First()).ToList(); return(browsers); }
public static List <Browser> find(bool update = false) { List <Browser> browsers = new List <Browser>(); if (Properties.Settings.Default.BrowserList != "" && !update) { browsers = JsonConvert.DeserializeObject <List <Browser> >(Properties.Settings.Default.BrowserList); } else { //special case , firefox+firefox developer both installed //(only works if firefox installed in default directory) var ff_path = Path.Combine( Program.ProgramFilesx86(), @"Mozilla Firefox\firefox.exe"); if (File.Exists(ff_path)) { browsers.Add(new Browser() { name = "FireFox", exec = ff_path, icon = icon2String(IconExtractor.fromFile(ff_path)) }); } //special case , Edge var edge_path = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe"); if (File.Exists(edge_path)) { browsers.Add(new Browser() { name = "Edge", // #34 exec = "shell:AppsFolder\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge", icon = icon2String(IconExtractor.fromFile(edge_path)) }); } //gather browsers from registry using (RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) browsers.AddRange(find(hklm)); using (RegistryKey hkcu = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32)) browsers.AddRange(find(hkcu)); //remove myself browsers = browsers.Where(x => Path.GetFileName(x.exec).ToLower() != Path.GetFileName(Application.ExecutablePath).ToLower()).ToList(); //remove duplicates browsers = browsers.GroupBy(browser => browser.exec) .Select(group => group.First()).ToList(); //check for edge chromium profiles AddChromeProfiles(browsers, "Microsoft Edge", @"Microsoft\Edge\User Data", "Edge Profile.ico"); //Check for Chrome Profiles AddChromeProfiles(browsers, "Google Chrome", @"Google\Chrome\User Data", "Google Profile.ico"); System.Diagnostics.Debug.WriteLine(JsonConvert.SerializeObject(browsers)); Properties.Settings.Default.BrowserList = JsonConvert.SerializeObject(browsers); Properties.Settings.Default.Save(); } return(browsers); }
public static List <Browser> find(bool update = false) { List <Browser> browsers = new List <Browser>(); if (Properties.Settings.Default.BrowserList != "" && !update) { browsers = JsonConvert.DeserializeObject <List <Browser> >(Properties.Settings.Default.BrowserList); } else { //special case , firefox+firefox developer both installed //(only works if firefox installed in default directory) var ff_path = Path.Combine( Program.ProgramFilesx86(), @"Mozilla Firefox\firefox.exe"); if (File.Exists(ff_path)) { browsers.Add(new Browser() { name = "FireFox", exec = ff_path, icon = icon2String(IconExtractor.fromFile(ff_path)) }); } //special case , Edge var edge_path = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe"); if (File.Exists(edge_path)) { browsers.Add(new Browser() { name = "Edge", // #34 exec = "shell:AppsFolder\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge", icon = icon2String(IconExtractor.fromFile(edge_path)) }); } //gather browsers from registry using (RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) browsers.AddRange(find(hklm)); using (RegistryKey hkcu = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32)) browsers.AddRange(find(hkcu)); //remove myself browsers = browsers.Where(x => Path.GetFileName(x.exec).ToLower() != Path.GetFileName(Application.ExecutablePath).ToLower()).ToList(); //remove duplicates browsers = browsers.GroupBy(browser => browser.exec) .Select(group => group.First()).ToList(); //Check for Chrome Profiles Browser BrowserChrome = browsers.FirstOrDefault(x => x.name == "Google Chrome"); if (BrowserChrome != null) { string ChromeUserDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Google\Chrome\User Data"); List <string> ChromeProfiles = FindChromeProfiles(ChromeUserDataDir); if (ChromeProfiles.Count > 1) { //add the Chrome instances and remove the default one foreach (string Profile in ChromeProfiles) { browsers.Add(new Browser() { name = "Chrome (" + GetChromeProfileName(ChromeUserDataDir + "\\" + Profile) + ")", exec = BrowserChrome.exec, icon = icon2String(IconExtractor.fromFile(ChromeUserDataDir + "\\" + Profile + "\\Google Profile.ico")), additionalArgs = String.Format("--profile-directory={0}", Profile) }); } browsers.Remove(BrowserChrome); browsers = browsers.OrderBy(x => x.name).ToList(); } } System.Diagnostics.Debug.WriteLine(JsonConvert.SerializeObject(browsers)); Properties.Settings.Default.BrowserList = JsonConvert.SerializeObject(browsers); Properties.Settings.Default.Save(); } return(browsers); }