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.

109 lines
3.9KB

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