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.

installer.nsi 4.3KB

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