start browser discovery code for Windows
Former-commit-id: d77e531867
Former-commit-id: de03ded79998a505ae61c57a9d2a62087b4af833
This commit is contained in:
@ -56,20 +56,12 @@ public class I2PGenericUnsafeBrowser {
|
||||
Process process = Runtime.getRuntime().exec("REG QUERY HKEY_CLASSES_ROOT\\http\\shell\\open\\command");
|
||||
Scanner kb = new Scanner(process.getInputStream());
|
||||
while (kb.hasNextLine()) {
|
||||
// Get output from the terminal, and replace all '\' with '/' (makes regex a bit more manageable)
|
||||
String registry = (kb.nextLine()).replaceAll("\\\\", "/").trim();
|
||||
// Extract the default browser
|
||||
Matcher matcher = Pattern.compile("/(?=[^/]*$)(.+?)").matcher(registry);
|
||||
if (matcher.find())
|
||||
{
|
||||
// Scanner is no longer needed if match is found, so close it
|
||||
kb.close();
|
||||
String defaultBrowser = matcher.toString();//group(1);
|
||||
//group(1);
|
||||
// Capitalize first letter and return String
|
||||
//defaultBrowser = defaultBrowser.substring(0, 1).toUpperCase() + defaultBrowser.substring(1, defaultBrowser.length());
|
||||
return defaultBrowser;
|
||||
String line = kb.nextLine();
|
||||
if (line.contains("(Default")){
|
||||
String[] splitLine = line.split("\\s+");
|
||||
return splitLine[splitLine.length]
|
||||
}
|
||||
|
||||
}
|
||||
// Match wasn't found, still need to close Scanner
|
||||
kb.close();
|
||||
|
Reference in New Issue
Block a user