MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Deploying WebView2Runtime

Open
#2,473 6 comments 0 reactions 1 assignee View on GitHub

@LiangTheDev is already working on this.

Since May 24, 2022.

bug tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

This is how I run time installer that gets downloaded if required. I followed the official guidelines:

if (bWebView2RuntimeNeeded) then
begin
	if Exec(ExpandConstant(strWebView2RuntimePath), '/silent /install', '',
			SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin
		{ Handle success if necessary; ResultCode contains the exit code }
		Log('WebView2Runtime installer exit code = ' + IntToStr(ResultCode));
		if ResultCode = 3010 then
		begin
		  Log('Need restart');
		  bNeedsRestart := True;
		end
		  else
		if ResultCode <> 0 then
		begin
		  MsgBox(
			ExpandConstant('{cm:InstallFailed,WebView2 Runtime}'),
			mbInformation, MB_OK);
		  Abort();
		end;
	end
	else begin
		{ The execution failed for some reason }
		Log('WebView2 Runtime installer exit code = ' + IntToStr(ResultCode));
		MsgBox(SysErrorMessage(ResultCode), mbInformation, MB_OK);
		Abort();
	end;
end;

The if test there is from my existing code for the Visual Studio Runtime.

  • Does the Webview2Runtime have return error codes?
  • Does a specific code indicate if a restart is needed?

This is the URL I download from:

strWebView2RuntimeURL = 'https://go.microsoft.com/fwlink/p/?LinkId=2124703';

Also, this is how I currently test if the runtime is installed:

function IsWebView2RuntimeNeeded(): boolean;
var
	Version: string;
	RuntimeNeeded: boolean;
	VerifyRuntime: boolean;
begin
	{ See: https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#detect-if-a-suitable-webview2-runtime-is-already-installed }

	RuntimeNeeded := true;
	VerifyRuntime := false;

	{ Since we are using an elevated installer I am not checking HKCU }
	if (IsWin64) then
	begin
		{ Test x64 }
		if (RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}', 'pv', Version)) then
		begin
			{ We need to verify }
			VerifyRuntime := true;
		end
	else
	begin
		{ Test x32 }
		if (RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}', 'pv', Version)) then
		begin
			{ We need to verify }
			VerifyRuntime := true;
		end;
	end;

	{ Verify the version information }
	if (VerifyRuntime) then
	begin
		if (Version <> '') and (Version <> '0.0.0.0') then
		begin
			Log('WebView2 Runtime is installed');
			RuntimeNeeded := false;
		end
		else
			Log('WebView2 Runtime needs to be downloaded and installed');
		end;
	end;

	Result := RuntimeNeeded;
end;

Do I need to actually ensure that the version number is greater than or equal to the version that I am using when compiling the project?

AB#39730709

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.