installer.nsi 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. Var newStartMenuLink
  2. Var oldStartMenuLink
  3. Var newDesktopLink
  4. Var oldDesktopLink
  5. Var oldShortcutName
  6. Var oldMenuDirectory
  7. !include "common.nsh"
  8. !include "MUI2.nsh"
  9. !include "multiUser.nsh"
  10. !include "allowOnlyOneInstallerInstance.nsh"
  11. !ifdef INSTALL_MODE_PER_ALL_USERS
  12. !ifdef BUILD_UNINSTALLER
  13. RequestExecutionLevel user
  14. !else
  15. RequestExecutionLevel admin
  16. !endif
  17. !else
  18. RequestExecutionLevel user
  19. !endif
  20. !ifdef BUILD_UNINSTALLER
  21. SilentInstall silent
  22. !else
  23. Var appExe
  24. Var launchLink
  25. !endif
  26. !ifdef ONE_CLICK
  27. !include "oneClick.nsh"
  28. !else
  29. !include "assistedInstaller.nsh"
  30. !endif
  31. !insertmacro addLangs
  32. !ifmacrodef customHeader
  33. !insertmacro customHeader
  34. !endif
  35. Function .onInit
  36. Call setInstallSectionSpaceRequired
  37. SetOutPath $INSTDIR
  38. ${LogSet} on
  39. !ifmacrodef preInit
  40. !insertmacro preInit
  41. !endif
  42. !ifdef DISPLAY_LANG_SELECTOR
  43. !insertmacro MUI_LANGDLL_DISPLAY
  44. !endif
  45. !ifdef BUILD_UNINSTALLER
  46. WriteUninstaller "${UNINSTALLER_OUT_FILE}"
  47. !insertmacro quitSuccess
  48. !else
  49. !insertmacro check64BitAndSetRegView
  50. !ifdef ONE_CLICK
  51. !insertmacro ALLOW_ONLY_ONE_INSTALLER_INSTANCE
  52. !else
  53. ${IfNot} ${UAC_IsInnerInstance}
  54. !insertmacro ALLOW_ONLY_ONE_INSTALLER_INSTANCE
  55. ${EndIf}
  56. !endif
  57. !insertmacro initMultiUser
  58. !ifmacrodef customInit
  59. !insertmacro customInit
  60. !endif
  61. !ifmacrodef addLicenseFiles
  62. InitPluginsDir
  63. !insertmacro addLicenseFiles
  64. !endif
  65. !endif
  66. FunctionEnd
  67. !ifndef BUILD_UNINSTALLER
  68. !include "installUtil.nsh"
  69. !endif
  70. Section "install" INSTALL_SECTION_ID
  71. !ifndef BUILD_UNINSTALLER
  72. # If we're running a silent upgrade of a per-machine installation, elevate so extracting the new app will succeed.
  73. # For a non-silent install, the elevation will be triggered when the install mode is selected in the UI,
  74. # but that won't be executed when silent.
  75. !ifndef INSTALL_MODE_PER_ALL_USERS
  76. !ifndef ONE_CLICK
  77. ${if} $hasPerMachineInstallation == "1" # set in onInit by initMultiUser
  78. ${andIf} ${Silent}
  79. ${ifNot} ${UAC_IsAdmin}
  80. ShowWindow $HWNDPARENT ${SW_HIDE}
  81. !insertmacro UAC_RunElevated
  82. ${Switch} $0
  83. ${Case} 0
  84. ${Break}
  85. ${Case} 1223 ;user aborted
  86. ${Break}
  87. ${Default}
  88. MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate, error $0"
  89. ${Break}
  90. ${EndSwitch}
  91. Quit
  92. ${else}
  93. !insertmacro setInstallModePerAllUsers
  94. ${endIf}
  95. ${endIf}
  96. !endif
  97. !endif
  98. !include "installSection.nsh"
  99. !endif
  100. SectionEnd
  101. Function setInstallSectionSpaceRequired
  102. !insertmacro setSpaceRequired ${INSTALL_SECTION_ID}
  103. FunctionEnd
  104. !ifdef BUILD_UNINSTALLER
  105. !include "uninstaller.nsh"
  106. !endif