6

I'm writing a windows form application (c#) and I need to detect whether the user have "Microsoft-Edge" installed in his/her machine or not.

I'm currently using this registry location:

[HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages\Microsoft.MicrosoftEdge_20.10240.16384.0_neutral__8wekyb3d8bbwe]
"Path"="C:\\Windows\\SystemApps\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe"

With a regex after the "Microsoft.MicrosoftEdge". If the "path" exist then I know edge is installed.

Is there a better way to detect edge? would it be better if I detect that I'm running on Windows 10 and by default Win10 come with edge? What is the best way for that?

Arghya C
  • 9,805
  • 2
  • 47
  • 66
Aviram Fireberger
  • 3,910
  • 5
  • 50
  • 69
  • 2
    Yes, Windows 10 comes with Microsoft Edge and I don't think you can uninstall Edge from it, and you definitely can't install it in previous versions of Windows – sebagomez Nov 08 '15 at 14:24
  • 2
    I was looking for a way to doing exactly what you wanted to do. And I found that your method is for me by far the best. If future versions of Windows drop Edge, your code will still work. Presuming of the presence of a feature based on the version of the OS is really not better than testing the existence of the feature itself. I just hope this key is the best one ;) Cheers. – iannakin Feb 16 '16 at 11:30
  • I'm happy to hear that. Please update if you find a better one :) – Aviram Fireberger Feb 17 '16 at 12:56
  • 1
    You actually can uninstall Microsoft Edge. It's a package app like everything else. [http://news.softpedia.com/news/how-to-remove-microsoft-edge-from-windows-10-491534.shtml](http://news.softpedia.com/news/how-to-remove-microsoft-edge-from-windows-10-491534.shtml) – BeanFlicker May 11 '16 at 00:40

4 Answers4

3

In case you want to have a small program getting that version number:

static void Main(string[] args)
    {
        string EdgeVersion = string.Empty;
        //open the registry and parse through the keys until you find Microsoft.MicrosoftEdge
        RegistryKey reg = Registry.ClassesRoot.OpenSubKey(@"Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages");
        if (reg != null)
        {
            foreach (string subkey in reg.GetSubKeyNames())
            {
                if (subkey.StartsWith("Microsoft.MicrosoftEdge"))
                {
                    //RegEx: (Microsoft.MicrosoftEdge_)(\d +\.\d +\.\d +\.\d +)(_neutral__8wekyb3d8bbwe])
                    Match rxEdgeVersion = null;
                    rxEdgeVersion = Regex.Match(subkey, @"(Microsoft.MicrosoftEdge_)(?<version>\d+\.\d+\.\d+\.\d+)(_neutral__8wekyb3d8bbwe)");
                    //just after that value, you need to use RegEx to find the version number of the value in the registry
                    if ( rxEdgeVersion.Success )
                        EdgeVersion = rxEdgeVersion.Groups["version"].Value;
                }
            }
        }

        Console.WriteLine("Edge Version(empty means not found): {0}", EdgeVersion);
        Console.ReadLine();
    }

Thank you for the registry link for finding the version number.

R Mimick
  • 31
  • 3
  • A direct paste of this code worked fine for me on getting the edge version. Microsoft Edge version=41.16299.492.0 – Bill Tarbell Jul 30 '18 at 19:05
  • I just tested this on Windows 10. It did return `Edge Version(empty means not found): 44.19041.423.0`. But, when I start Microsoft Edge (Chromium) and check the About window it says: `Version 86.0.622.56 (Official build) (64-bit)`. So I am confused. – Andrew Truckle Oct 30 '20 at 21:41
2

If you're on the desktop or mobile version of Windows 10 then Edge is pre-installed and can't be uninstalled.

To detect if running on Windows 10 use the System.Environment.OSVersion property or the Version Helper functions. (See also https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx)

If you want to detect the default browser you should see How to determine the Windows default browser (at the top of the start menu)

Community
  • 1
  • 1
Matt Lacey
  • 65,560
  • 11
  • 91
  • 143
  • [Here](https://referencesource.microsoft.com/#WindowsBase/Shared/System/Windows/InterOp/OSVersionHelper.cs,d648c1ad87b92a5e) is some interesting reference to detect Windows version. – Vizor Apr 24 '17 at 16:07
0

Relevant to 15.11.2016:

The only way that I found working is to use this registry location:

[HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages\Microsoft.MicrosoftEdge_20.10240.16384.0_neutral__8wekyb3d8bbwe]
"Path"="C:\\Windows\\SystemApps\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe"

With a regex after the "Microsoft.MicrosoftEdge".

If the "path" exist then I know edge is installed.

Aviram Fireberger
  • 3,910
  • 5
  • 50
  • 69
0

In reference to other answers: my installation of Windows 10 does not have this key: Microsoft.MicrosoftEdge_20.10240.16384.0_neutral__8wekyb3d8bbwe

In:

[HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages\]

Instead, it has the following keys:

Microsoft.MicrosoftEdge_38.14393.0.0_neutral__8wekyb3d8bbwe
Microsoft.MicrosoftEdge_40.15063.674.0_neutral__8wekyb3d8bbwe

The following code could be used to detect if Edge is installed:

class Program
{
    static void Main(string[] args)
    {
        var edgeFound = false;
        using (var key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(@"Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages\"))
        {
            if (key != null)
            {
                foreach (var subkey in key.GetSubKeyNames())
                {
                    if (subkey.StartsWith("Microsoft.MicrosoftEdge_"))
                    {
                        edgeFound = true;
                        break;
                    }
                }
            }
        }
        Console.Write(edgeFound);
        Console.ReadLine();
    }
}
Tom Andraszek
  • 1,793
  • 1
  • 23
  • 30