diff --git a/widget/windows/ShellHeaderOnlyUtils.h b/widget/windows/ShellHeaderOnlyUtils.h index 0727b8a0eb33..fccb46e1a10a 100644 --- a/widget/windows/ShellHeaderOnlyUtils.h +++ b/widget/windows/ShellHeaderOnlyUtils.h @@ -126,6 +126,12 @@ inline LauncherVoidResult ShellExecuteByExplorer(const _bstr_t& aPath, return LAUNCHER_ERROR_FROM_HRESULT(hr); } + // Passing the foreground privilege so that the shell can launch an + // application in the foreground. If CoAllowSetForegroundWindow fails, + // we continue because it's not fatal. + hr = ::CoAllowSetForegroundWindow(shellDisp, nullptr); + MOZ_ASSERT(SUCCEEDED(hr)); + // shellapi.h macros interfere with the correct naming of the method being // called on IShellDispatch2. Temporarily remove that definition. #if defined(ShellExecute)