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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. !include "MUI2.nsh"
  2. Name "VCV Rack v${VERSION}"
  3. OutFile "installer.exe"
  4. SetCompressor /solid "lzma"
  5. SetCompressorDictSize 8
  6. CRCCheck On
  7. ; Default installation folder
  8. InstallDir "$PROGRAMFILES\VCV\Rack"
  9. ; Get installation folder from registry if available
  10. InstallDirRegKey HKLM "Software\VCV\Rack" ""
  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 "VCV Rack" VCV_RACK_SECTION
  42. SectionIn RO
  43. SetOutPath "$INSTDIR"
  44. File /r "dist\Rack\*"
  45. ; Store installation folder
  46. WriteRegStr HKLM "Software\VCV\Rack" "" "$INSTDIR"
  47. ; Write uninstaller info
  48. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack" "DisplayName" "VCV Rack"
  49. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack" "DisplayIcon" '"$INSTDIR\Rack.exe"'
  50. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack" "DisplayVersion" "${VERSION}"
  51. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack" "UninstallString" '"$INSTDIR\Uninstall.exe"'
  52. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack" "QuietUninstallString" '"$INSTDIR\Uninstall.exe" /S'
  53. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack" "InstallLocation" '"$INSTDIR"'
  54. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack" "Publisher" "VCV"
  55. SectionGetSize ${VCV_RACK_SECTION} $0
  56. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack" "EstimatedSize" $0
  57. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack" "NoModify" 1
  58. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack" "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.lnk" "$INSTDIR\Rack.exe"
  67. CreateShortcut "$SMPROGRAMS\VCV Rack.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.lnk"
  75. Delete "$SMPROGRAMS\VCV Rack.lnk"
  76. DeleteRegKey HKLM "Software\VCV\Rack"
  77. DeleteRegKey /ifempty HKLM "Software\VCV"
  78. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VCV Rack"
  79. DeleteRegKey HKLM "Software\Classes\.vcv"
  80. DeleteRegKey HKLM "Software\Classes\VCVRack.Patch"
  81. SectionEnd
  82. ; Functions