You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.3KB

  1. !include "MUI2.nsh"
  2. !define NAME_FULL "VCV Rack Community Edition ${VERSION}"
  3. !define NAME "VCV Rack ${VERSION_MAJOR}"
  4. !define RACK_DIR "Rack${VERSION_MAJOR}"
  5. !define INSTALL_REG "Software\VCV\Rack${VERSION_MAJOR}"
  6. !define UNINSTALL_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCVRack${VERSION_MAJOR}"
  7. Name "${NAME_FULL}"
  8. Unicode True
  9. SetCompressor /solid "lzma"
  10. SetCompressorDictSize 8
  11. CRCCheck On
  12. ; Default installation folder
  13. InstallDir "$PROGRAMFILES\VCV\${RACK_DIR}"
  14. ; Get installation folder from registry if available
  15. InstallDirRegKey HKLM "${INSTALL_REG}" ""
  16. ; Request admin permissions so we can install to Program Files and add a registry entry
  17. RequestExecutionLevel admin
  18. ; MUI installer pages
  19. !define MUI_ICON "icon.ico"
  20. ;!define MUI_HEADERIMAGE
  21. ;!define MUI_HEADERIMAGE_BITMAP "installer-banner.bmp" ; 150x57
  22. ;!define MUI_WELCOMEFINISHPAGE_BITMAP "$NSISDIR\Contrib\Graphics\Wizard\win.bmp" ; 164x314
  23. ;!define MUI_UNWELCOMEFINISHPAGE_BITMAP "$NSISDIR\Contrib\Graphics\Wizard\win.bmp" ; 164x314
  24. !define MUI_COMPONENTSPAGE_NODESC
  25. ;!insertmacro MUI_PAGE_COMPONENTS
  26. ; Prevent user from choosing an installation directory that already exists, such as C:\Program Files.
  27. ; This is necessary because the uninstaller removes the installation directory, which is dangerous for directories that existed before Rack was installed.
  28. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE directoryLeave
  29. Function directoryLeave
  30. StrCmp "$INSTDIR" "$PROGRAMFILES" directoryBad
  31. StrCmp "$INSTDIR" "$PROGRAMFILES32" directoryBad
  32. StrCmp "$INSTDIR" "$PROGRAMFILES64" directoryBad
  33. StrCmp "$INSTDIR" "$COMMONFILES" directoryBad
  34. StrCmp "$INSTDIR" "$COMMONFILES32" directoryBad
  35. StrCmp "$INSTDIR" "$COMMONFILES64" directoryBad
  36. StrCmp "$INSTDIR" "$DESKTOP" directoryBad
  37. StrCmp "$INSTDIR" "$WINDIR" directoryBad
  38. StrCmp "$INSTDIR" "$SYSDIR" directoryBad
  39. StrCmp "$INSTDIR" "$DOCUMENTS" directoryBad
  40. StrCmp "$INSTDIR" "$MUSIC" directoryBad
  41. StrCmp "$INSTDIR" "$PICTURES" directoryBad
  42. StrCmp "$INSTDIR" "$VIDEOS" directoryBad
  43. StrCmp "$INSTDIR" "$APPDATA" directoryBad
  44. StrCmp "$INSTDIR" "$LOCALAPPDATA" directoryBad
  45. Return
  46. directoryBad:
  47. MessageBox MB_OK|MB_ICONSTOP "Cannot install to $INSTDIR."
  48. Abort
  49. FunctionEnd
  50. !insertmacro MUI_PAGE_DIRECTORY
  51. !insertmacro MUI_PAGE_INSTFILES
  52. !define MUI_FINISHPAGE_RUN "$INSTDIR\Rack.exe"
  53. !define MUI_FINISHPAGE_RUN_TEXT "Launch ${NAME}"
  54. !insertmacro MUI_PAGE_FINISH
  55. ; MUI uninstaller pages
  56. !insertmacro MUI_UNPAGE_CONFIRM
  57. !insertmacro MUI_UNPAGE_INSTFILES
  58. !insertmacro MUI_LANGUAGE "English"
  59. ; Sections
  60. Section "${NAME}" INSTALL_SECTION
  61. SectionIn RO
  62. SetOutPath "$INSTDIR"
  63. File /r "dist\${RACK_DIR}\*"
  64. ; Store installation folder
  65. WriteRegStr HKLM "${INSTALL_REG}" "" "$INSTDIR"
  66. ; Write uninstaller info
  67. WriteRegStr HKLM "${UNINSTALL_REG}" "DisplayName" "${NAME}"
  68. WriteRegStr HKLM "${UNINSTALL_REG}" "DisplayIcon" '"$INSTDIR\Rack.exe"'
  69. WriteRegStr HKLM "${UNINSTALL_REG}" "DisplayVersion" "${VERSION}"
  70. WriteRegStr HKLM "${UNINSTALL_REG}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
  71. WriteRegStr HKLM "${UNINSTALL_REG}" "QuietUninstallString" '"$INSTDIR\Uninstall.exe" /S'
  72. WriteRegStr HKLM "${UNINSTALL_REG}" "InstallLocation" '"$INSTDIR"'
  73. WriteRegStr HKLM "${UNINSTALL_REG}" "Publisher" "VCV"
  74. SectionGetSize ${INSTALL_SECTION} $0
  75. WriteRegDWORD HKLM "${UNINSTALL_REG}" "EstimatedSize" $0
  76. WriteRegDWORD HKLM "${UNINSTALL_REG}" "NoModify" 1
  77. WriteRegDWORD HKLM "${UNINSTALL_REG}" "NoRepair" 1
  78. ; Create uninstaller
  79. WriteUninstaller "$INSTDIR\Uninstall.exe"
  80. ; Associate file type
  81. WriteRegStr HKLM "Software\Classes\.vcv" "" "VCVRack.Patch"
  82. WriteRegStr HKLM "Software\Classes\VCVRack.Patch" "" "VCV Rack patch"
  83. WriteRegStr HKLM "Software\Classes\VCVRack.Patch\shell\open\command" "" '"$INSTDIR\Rack.exe" "%1"'
  84. ; Create shortcuts
  85. CreateShortcut "$DESKTOP\${NAME}.lnk" "$INSTDIR\Rack.exe"
  86. CreateShortcut "$SMPROGRAMS\${NAME}.lnk" "$INSTDIR\Rack.exe"
  87. SectionEnd
  88. Section "Uninstall"
  89. ; directoryLeave above ensures that INSTDIR is safe to remove.
  90. RMDir /r "$INSTDIR"
  91. ; Attempt to remove C:\Program Files\VCV if empty
  92. RMDir "$INSTDIR\.."
  93. Delete "$DESKTOP\${NAME}.lnk"
  94. Delete "$SMPROGRAMS\${NAME}.lnk"
  95. DeleteRegKey HKLM "${INSTALL_REG}"
  96. DeleteRegKey /ifempty HKLM "Software\VCV"
  97. DeleteRegKey HKLM "${UNINSTALL_REG}"
  98. DeleteRegKey HKLM "Software\Classes\.vcv"
  99. DeleteRegKey HKLM "Software\Classes\VCVRack.Patch"
  100. SectionEnd