@@ -29,6 +29,8 @@ ${StrLoc}
2929!include " {{installer_hooks}}"
3030{{/if}}
3131
32+ !define WEBVIEW2APPGUID " {F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
33+
3234!define MANUFACTURER " {{manufacturer}}"
3335!define PRODUCTNAME " {{product_name}}"
3436!define VERSION " {{version}}"
@@ -53,6 +55,7 @@ ${StrLoc}
5355!define WEBVIEW2INSTALLERARGS " {{webview2_installer_args}}"
5456!define WEBVIEW2BOOTSTRAPPERPATH " {{webview2_bootstrapper_path}}"
5557!define WEBVIEW2INSTALLERPATH " {{webview2_installer_path}}"
58+ !define MINIMUMWEBVIEW2VERSION " {{minimum_webview2_version}}"
5659!define UNINSTKEY " Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}"
5760!define MANUPRODUCTKEY " Software\${MANUFACTURER}\${PRODUCTNAME}"
5861!define UNINSTALLERSIGNCOMMAND " {{uninstaller_sign_cmd}}"
@@ -493,63 +496,92 @@ SectionEnd
493496Section WebView2
494497 ; Check if Webview2 is already installed and skip this section
495498 ${If} ${RunningX64}
496- ReadRegStr $4 HKLM " SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5 }" " pv"
499+ ReadRegStr $4 HKLM " SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID }" " pv"
497500 ${Else}
498- ReadRegStr $4 HKLM " SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" " pv"
501+ ReadRegStr $4 HKLM " SOFTWARE\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" " pv"
502+ ${EndIf}
503+ ${If} $4 == " "
504+ ReadRegStr $4 HKCU " SOFTWARE\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" " pv"
499505 ${EndIf}
500- ReadRegStr $5 HKCU " SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" " pv"
501-
502- StrCmp $4 " " 0 webview2_done
503- StrCmp $5 " " 0 webview2_done
504506
505- ; Webview2 installation
506- ;
507- ; Skip if updating
508- ${If} $UpdateMode <> 1
509- !if " ${INSTALLWEBVIEW2MODE}" == " downloadBootstrapper"
510- Delete " $TEMP\MicrosoftEdgeWebview2Setup.exe"
511- DetailPrint " $(webview2Downloading)"
512- NSISdl::download " https://go.microsoft.com/fwlink/p/?LinkId=2124703" " $TEMP\MicrosoftEdgeWebview2Setup.exe"
513- Pop $0
514- ${If} $0 = 0
515- DetailPrint " $(webview2DownloadSuccess)"
516- ${Else}
517- DetailPrint " $(webview2DownloadError)"
518- Abort " $(webview2AbortError)"
507+ ${If} $4 == " "
508+ ; Webview2 installation
509+ ;
510+ ; Skip if updating
511+ ${If} $UpdateMode <> 1
512+ !if " ${INSTALLWEBVIEW2MODE}" == " downloadBootstrapper"
513+ Delete " $TEMP\MicrosoftEdgeWebview2Setup.exe"
514+ DetailPrint " $(webview2Downloading)"
515+ NSISdl::download " https://go.microsoft.com/fwlink/p/?LinkId=2124703" " $TEMP\MicrosoftEdgeWebview2Setup.exe"
516+ Pop $0
517+ ${If} $0 = 0
518+ DetailPrint " $(webview2DownloadSuccess)"
519+ ${Else}
520+ DetailPrint " $(webview2DownloadError)"
521+ Abort " $(webview2AbortError)"
522+ ${EndIf}
523+ StrCpy $6 " $TEMP\MicrosoftEdgeWebview2Setup.exe"
524+ Goto install_webview2
525+ !endif
526+
527+ !if " ${INSTALLWEBVIEW2MODE}" == " embedBootstrapper"
528+ Delete " $TEMP\MicrosoftEdgeWebview2Setup.exe"
529+ File " /oname=$TEMP\MicrosoftEdgeWebview2Setup.exe" " ${WEBVIEW2BOOTSTRAPPERPATH}"
530+ DetailPrint " $(installingWebview2)"
531+ StrCpy $6 " $TEMP\MicrosoftEdgeWebview2Setup.exe"
532+ Goto install_webview2
533+ !endif
534+
535+ !if " ${INSTALLWEBVIEW2MODE}" == " offlineInstaller"
536+ Delete " $TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe"
537+ File " /oname=$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe" " ${WEBVIEW2INSTALLERPATH}"
538+ DetailPrint " $(installingWebview2)"
539+ StrCpy $6 " $TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe"
540+ Goto install_webview2
541+ !endif
542+
543+ Goto webview2_done
544+
545+ install_webview2:
546+ DetailPrint " $(installingWebview2)"
547+ ; $6 holds the path to the webview2 installer
548+ ExecWait " $6 ${WEBVIEW2INSTALLERARGS} /install" $1
549+ ${If} $1 = 0
550+ DetailPrint " $(webview2InstallSuccess)"
551+ ${Else}
552+ DetailPrint " $(webview2InstallError)"
553+ Abort " $(webview2AbortError)"
554+ ${EndIf}
555+ webview2_done:
556+ ${EndIf}
557+ ${Else}
558+ !if " ${MINIMUMWEBVIEW2VERSION}" != " "
559+ ${VersionCompare} " ${MINIMUMWEBVIEW2VERSION}" " $4" $R0
560+ ${If} $R0 = 1
561+ update_webview:
562+ DetailPrint " $(installingWebview2)"
563+ ${If} ${RunningX64}
564+ ReadRegStr $R1 HKLM " SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" " path"
565+ ${Else}
566+ ReadRegStr $R1 HKLM " SOFTWARE\Microsoft\EdgeUpdate" " path"
567+ ${EndIf}
568+ ${If} $R1 == " "
569+ ReadRegStr $R1 HKCU " SOFTWARE\Microsoft\EdgeUpdate" " path"
570+ ${EndIf}
571+ ${If} $R1 != " "
572+ ; Chromium updater docs: https://source.chromium.org/chromium/chromium/src/+/main:docs/updater/user_manual.md
573+ ; Modified from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView\ModifyPath"
574+ ExecWait ` "$R1" /install appguid=${WEBVIEW2APPGUID}&needsadmin=true` $1
575+ ${If} $1 = 0
576+ DetailPrint " $(webview2InstallSuccess)"
577+ ${Else}
578+ MessageBox MB_ICONEXCLAMATION |MB_ABORTRETRYIGNORE " $(webview2InstallError)" IDIGNORE ignore IDRETRY update_webview
579+ Quit
580+ ignore:
581+ ${EndIf}
582+ ${EndIf}
519583 ${EndIf}
520- StrCpy $6 " $TEMP\MicrosoftEdgeWebview2Setup.exe"
521- Goto install_webview2
522584 !endif
523-
524- !if " ${INSTALLWEBVIEW2MODE}" == " embedBootstrapper"
525- Delete " $TEMP\MicrosoftEdgeWebview2Setup.exe"
526- File " /oname=$TEMP\MicrosoftEdgeWebview2Setup.exe" " ${WEBVIEW2BOOTSTRAPPERPATH}"
527- DetailPrint " $(installingWebview2)"
528- StrCpy $6 " $TEMP\MicrosoftEdgeWebview2Setup.exe"
529- Goto install_webview2
530- !endif
531-
532- !if " ${INSTALLWEBVIEW2MODE}" == " offlineInstaller"
533- Delete " $TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe"
534- File " /oname=$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe" " ${WEBVIEW2INSTALLERPATH}"
535- DetailPrint " $(installingWebview2)"
536- StrCpy $6 " $TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe"
537- Goto install_webview2
538- !endif
539-
540- Goto webview2_done
541-
542- install_webview2:
543- DetailPrint " $(installingWebview2)"
544- ; $6 holds the path to the webview2 installer
545- ExecWait " $6 ${WEBVIEW2INSTALLERARGS} /install" $1
546- ${If} $1 = 0
547- DetailPrint " $(webview2InstallSuccess)"
548- ${Else}
549- DetailPrint " $(webview2InstallError)"
550- Abort " $(webview2AbortError)"
551- ${EndIf}
552- webview2_done:
553585 ${EndIf}
554586SectionEnd
555587
0 commit comments