I am looking for a way to detect if WebView2 runtime is installed on the clients machines so that i can display using the old ie browser instead if they don't have it installed. I am using VB.NET.
Thanks
Check if WebView2 is already installed You can check for that by going to the Start Menu --> Add or Remove Programs and searching for WebView2.
Microsoft is automatically installing the WebView2 runtime on Windows 10 machines to support upcoming versions of the Microsoft 365 and Microsoft Office applications. Microsoft's WebView2 allows developers to embed and render web content directly in their native applications, including JavaScript, HTML, and CSS.
So, you don't need Microsoft Edge WebView2 Runtime installed on your Windows unless you want some of your Office 365 apps features, such as the Room Finder in Outlook, to provide a similar experience whether in the web or PC version.
To install WebView2 Runtime, go to the Microsoft web page Download the WebView2 Runtime (https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section). Under Evergreen Standalone Installer, click the x64 download button. Important: You must download the 64-bit version of the installer.
You can refer to this doc about how to check if the WebView2 Runtime is already installed. To verify, complete one of the following actions:
Inspect if the pv
(REG_SZ
) regkey exists and is not null or empty. Find pv (REG_SZ
) at the following location:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}
VB.NET code to check pv
regkey:
Dim readValue = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}", "pv", Nothing)
If readValue Is Nothing Then
'Key doesn't exist
Else
'Key existed, check value
End If
Run GetAvailableCoreWebView2BrowserVersionString
and ensure the versionInfo
is NULL
.
It uses C++ in the doc. For VB.NET, the corresponding method is GetAvailableBrowserVersionString(String)
. You can refer to the doc about how to use it in VB.NET.
I have implemented a working code example in C#. It uses the method CoreWebView2Environment.GetAvailableBrowserVersionString()
to get the version.
I have tested with the regkey solution, but it did not work with Edge Chromium Beta, Dev or Canary. It only work when WebView2 runtime were installed.
public static class WebView2Install
{
public static InstallInfo GetInfo()
{
var version = GetWebView2Version();
return new InstallInfo(version);
}
private static string GetWebView2Version()
{
try
{
return CoreWebView2Environment.GetAvailableBrowserVersionString();
}
catch (Exception) { return ""; }
}
}
public class InstallInfo
{
public InstallInfo(string version) => (Version) = (version);
public string Version { get; }
public InstallType InstallType => Version switch
{
var version when version.Contains("dev") => InstallType.EdgeChromiumDev,
var version when version.Contains("beta") => InstallType.EdgeChromiumBeta,
var version when version.Contains("canary") => InstallType.EdgeChromiumCanary,
var version when !string.IsNullOrEmpty(version) => InstallType.WebView2,
_ => InstallType.NotInstalled
};
}
public enum InstallType
{
WebView2, EdgeChromiumBeta, EdgeChromiumCanary, EdgeChromiumDev, NotInstalled
}
I also have made a WPF application that uses WebView2 on GitHub, it also show you the usage of the above code.
KioskBrowser (GitHub)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With