common.nsh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. !include x64.nsh
  2. !include WinVer.nsh
  3. BrandingText "${PRODUCT_NAME} ${VERSION}"
  4. ShowInstDetails nevershow
  5. !ifdef BUILD_UNINSTALLER
  6. ShowUninstDetails nevershow
  7. !endif
  8. FileBufSize 64
  9. Name "${PRODUCT_NAME}"
  10. !define APP_EXECUTABLE_FILENAME "${PRODUCT_FILENAME}.exe"
  11. !define UNINSTALL_FILENAME "Uninstall ${PRODUCT_FILENAME}.exe"
  12. !macro setSpaceRequired SECTION_ID
  13. !ifdef APP_64_UNPACKED_SIZE
  14. !ifdef APP_32_UNPACKED_SIZE
  15. !ifdef APP_ARM64_UNPACKED_SIZE
  16. ${if} ${IsNativeARM64}
  17. SectionSetSize ${SECTION_ID} ${APP_ARM64_UNPACKED_SIZE}
  18. ${elseif} ${IsNativeAMD64}
  19. SectionSetSize ${SECTION_ID} ${APP_64_UNPACKED_SIZE}
  20. ${else}
  21. SectionSetSize ${SECTION_ID} ${APP_32_UNPACKED_SIZE}
  22. ${endif}
  23. !else
  24. ${if} ${RunningX64}
  25. SectionSetSize ${SECTION_ID} ${APP_64_UNPACKED_SIZE}
  26. ${else}
  27. SectionSetSize ${SECTION_ID} ${APP_32_UNPACKED_SIZE}
  28. ${endif}
  29. !endif
  30. !else
  31. SectionSetSize ${SECTION_ID} ${APP_64_UNPACKED_SIZE}
  32. !endif
  33. !else
  34. !ifdef APP_32_UNPACKED_SIZE
  35. SectionSetSize ${SECTION_ID} ${APP_32_UNPACKED_SIZE}
  36. !endif
  37. !endif
  38. !macroend
  39. !macro check64BitAndSetRegView
  40. # https://github.com/electron-userland/electron-builder/issues/2420
  41. ${If} ${IsWin2000}
  42. ${OrIf} ${IsWinME}
  43. ${OrIf} ${IsWinXP}
  44. ${OrIf} ${IsWinVista}
  45. MessageBox MB_OK "$(win7Required)"
  46. Quit
  47. ${EndIf}
  48. !ifdef APP_ARM64
  49. ${If} ${RunningX64}
  50. SetRegView 64
  51. ${EndIf}
  52. ${If} ${IsNativeARM64}
  53. SetRegView 64
  54. ${EndIf}
  55. !else
  56. !ifdef APP_64
  57. ${If} ${RunningX64}
  58. SetRegView 64
  59. ${Else}
  60. !ifndef APP_32
  61. MessageBox MB_OK|MB_ICONEXCLAMATION "$(x64WinRequired)"
  62. Quit
  63. !endif
  64. ${EndIf}
  65. !endif
  66. !endif
  67. !macroend
  68. # avoid exit code 2
  69. !macro quitSuccess
  70. SetErrorLevel 0
  71. Quit
  72. !macroend
  73. !macro setLinkVars
  74. # old desktop shortcut (could exist or not since the user might has selected to delete it)
  75. ReadRegStr $oldShortcutName SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" ShortcutName
  76. ${if} $oldShortcutName == ""
  77. StrCpy $oldShortcutName "${PRODUCT_FILENAME}"
  78. ${endIf}
  79. StrCpy $oldDesktopLink "$DESKTOP\$oldShortcutName.lnk"
  80. # new desktop shortcut (will be created/renamed in case of a fresh installation or if the user haven't deleted the initial one)
  81. StrCpy $newDesktopLink "$DESKTOP\${SHORTCUT_NAME}.lnk"
  82. ReadRegStr $oldMenuDirectory SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" MenuDirectory
  83. ${if} $oldMenuDirectory == ""
  84. StrCpy $oldStartMenuLink "$SMPROGRAMS\$oldShortcutName.lnk"
  85. ${else}
  86. StrCpy $oldStartMenuLink "$SMPROGRAMS\$oldMenuDirectory\$oldShortcutName.lnk"
  87. ${endIf}
  88. # new menu shortcut (will be created/renamed in case of a fresh installation or if the user haven't deleted the initial one)
  89. !ifdef MENU_FILENAME
  90. StrCpy $newStartMenuLink "$SMPROGRAMS\${MENU_FILENAME}\${SHORTCUT_NAME}.lnk"
  91. !else
  92. StrCpy $newStartMenuLink "$SMPROGRAMS\${SHORTCUT_NAME}.lnk"
  93. !endif
  94. !macroend
  95. !macro skipPageIfUpdated
  96. !define UniqueID ${__LINE__}
  97. Function skipPageIfUpdated_${UniqueID}
  98. ${if} ${isUpdated}
  99. Abort
  100. ${endif}
  101. FunctionEnd
  102. !define MUI_PAGE_CUSTOMFUNCTION_PRE skipPageIfUpdated_${UniqueID}
  103. !undef UniqueID
  104. !macroend
  105. !macro StartApp
  106. Var /GLOBAL startAppArgs
  107. ${if} ${isUpdated}
  108. StrCpy $startAppArgs "--updated"
  109. ${else}
  110. StrCpy $startAppArgs ""
  111. ${endif}
  112. ${StdUtils.ExecShellAsUser} $0 "$launchLink" "open" "$startAppArgs"
  113. !macroend
  114. !define LogSet "!insertmacro LogSetMacro"
  115. !macro LogSetMacro SETTING
  116. !ifdef ENABLE_LOGGING_ELECTRON_BUILDER
  117. SetOutPath $INSTDIR
  118. LogSet ${SETTING}
  119. !endif
  120. !macroend
  121. !define LogText "!insertmacro LogTextMacroEB"
  122. !macro LogTextMacroEB INPUT_TEXT
  123. !ifdef ENABLE_LOGGING_ELECTRON_BUILDER
  124. LogText ${INPUT_TEXT}
  125. !endif
  126. !macroend