00.sconsblender.nsi 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. ;
  2. ;
  3. ; Blender Self-Installer for Windows (NSIS - http://nsis.sourceforge.net)
  4. ;
  5. SetCompressor /SOLID lzma
  6. Name "Blender [VERSION]"
  7. RequestExecutionLevel admin
  8. !include "MUI.nsh"
  9. !include "WinVer.nsh"
  10. !include "FileFunc.nsh"
  11. !include "WordFunc.nsh"
  12. !include "nsDialogs.nsh"
  13. !include "x64.nsh"
  14. !define MUI_ABORTWARNING
  15. !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Blender. It is recommended that you close all other applications before starting Setup."
  16. !define MUI_WELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp"
  17. !define MUI_HEADERIMAGE
  18. !define MUI_HEADERIMAGE_BITMAP "[RELDIR]\00.header.bmp"
  19. !define MUI_COMPONENTSPAGE_SMALLDESC
  20. !define MUI_FINISHPAGE_RUN "$INSTDIR\blender.exe"
  21. !define MUI_CHECKBITMAP "[RELDIR]\00.checked.bmp"
  22. !define MUI_UNWELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp"
  23. !insertmacro MUI_PAGE_WELCOME
  24. !insertmacro MUI_PAGE_LICENSE "[DISTDIR]\Copyright.txt"
  25. !insertmacro MUI_PAGE_COMPONENTS
  26. !insertmacro MUI_PAGE_DIRECTORY
  27. !insertmacro MUI_PAGE_INSTFILES
  28. !insertmacro MUI_PAGE_FINISH
  29. !insertmacro MUI_UNPAGE_WELCOME
  30. UninstPage custom un.OptionalRemoveConfig un.OptionalRemoveConfigOnLeave
  31. !insertmacro MUI_UNPAGE_CONFIRM
  32. !insertmacro MUI_UNPAGE_INSTFILES
  33. !insertmacro MUI_UNPAGE_FINISH
  34. !insertmacro Locate
  35. !insertmacro VersionCompare
  36. Icon "[RELDIR]\00.installer.ico"
  37. UninstallIcon "[RELDIR]\00.installer.ico"
  38. ;--------------------------------
  39. ;Languages
  40. !insertmacro MUI_LANGUAGE "English"
  41. ;--------------------------------
  42. ;Language Strings
  43. ;Description
  44. LangString DESC_InstallFiles ${LANG_ENGLISH} "Copy all required files to the application folder."
  45. LangString DESC_StartMenu ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)"
  46. LangString DESC_DesktopShortcut ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop."
  47. LangString DESC_BlendRegister ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc."
  48. ;--------------------------------
  49. ;Data
  50. Caption "Blender [VERSION] Installer"
  51. OutFile "[DISTDIR]\..\blender-[VERSION]-windows[BITNESS].exe"
  52. InstallDir $INSTDIR ; $INSTDIR is set inside .onInit
  53. BrandingText "Blender Foundation | http://www.blender.org"
  54. ComponentText "This will install Blender [VERSION] on your computer."
  55. VIAddVersionKey "ProductName" "Blender"
  56. VIAddVersionKey "CompanyName" "http://www.blender.org"
  57. VIAddVersionKey "FileDescription" "Free open source 3D content creation suite."
  58. VIAddVersionKey "FileVersion" "[SHORTVERSION].0.0"
  59. VIProductVersion "[SHORTVERSION].0.0"
  60. DirText "Use the field below to specify the folder where you want Blender to be copied to. To specify a different folder, type a new name or use the Browse button to select an existing folder."
  61. SilentUnInstall normal
  62. Var SHORTVERSION ; This is blender_version_decimal() from path_util.c
  63. Var BLENDERCONFIG
  64. Var REMOVECONFIG
  65. ; Custom controls
  66. Var HWND
  67. Var HWND_KEEPCONFIG
  68. Var HWND_REMOVECONFIG
  69. Function .onInit
  70. ClearErrors
  71. StrCpy $SHORTVERSION "[SHORTVERSION]"
  72. ${If} ${RunningX64}
  73. ${If} "[BITNESS]" == "32"
  74. StrCpy $INSTDIR "$PROGRAMFILES32\Blender Foundation\Blender" ; Can't use InstallDir inside Section
  75. ${ElseIf} "[BITNESS]" == "64"
  76. StrCpy $INSTDIR "$PROGRAMFILES64\Blender Foundation\Blender"
  77. ${EndIf}
  78. ${Else}
  79. StrCpy $INSTDIR "$PROGRAMFILES\Blender Foundation\Blender"
  80. ${EndIf}
  81. FunctionEnd
  82. Function un.onInit
  83. SetShellVarContext current
  84. StrCpy $BLENDERCONFIG "$APPDATA\Blender Foundation\Blender"
  85. SetShellVarContext all
  86. FunctionEnd
  87. Function un.OptionalRemoveConfig
  88. nsDialogs::Create /NOUNLOAD 1018
  89. Pop $HWND
  90. ${If} $HWND == error
  91. Abort
  92. ${EndIf}
  93. ${NSD_CreateRadioButton} 0 50 100% 12u "Keep configuration files, autosaved .blend files and installed addons (recommended)"
  94. Pop $HWND_KEEPCONFIG
  95. ${NSD_CreateRadioButton} 0 80 100% 12u "Remove all files, including configuration files, autosaved .blend files and installed addons"
  96. Pop $HWND_REMOVECONFIG
  97. SendMessage $HWND_KEEPCONFIG ${BM_SETCHECK} 1 0
  98. nsDialogs::Show
  99. FunctionEnd
  100. Function un.OptionalRemoveConfigOnLeave
  101. ${NSD_GetState} $HWND_REMOVECONFIG $R0
  102. ${If} $R0 == "1"
  103. StrCpy $REMOVECONFIG "1"
  104. ${Else}
  105. StrCpy $REMOVECONFIG "0"
  106. ${EndIf}
  107. FunctionEnd
  108. Section "Blender [VERSION] (required)" InstallFiles
  109. SectionIn RO
  110. ; Set output path to the installation directory.
  111. SetOutPath $INSTDIR
  112. ; The contents of Blender installation root dir
  113. [ROOTDIRCONTS]
  114. ; All datafiles (python, scripts, datafiles)
  115. [DODATAFILES]
  116. SetOutPath $INSTDIR
  117. ${If} ${RunningX64}
  118. SetRegView 64
  119. ${EndIf}
  120. ; Write the installation path into the registry
  121. WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "Install_Dir" "$INSTDIR"
  122. WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" "[SHORTVERSION]"
  123. ; Write the uninstall keys for Windows
  124. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender"
  125. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "Publisher" "Blender Foundation"
  126. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "URLInfoAbout" "http://www.blender.org/"
  127. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayVersion" "[VERSION]"
  128. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayIcon" "$INSTDIR\blender.exe"
  129. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "UninstallString" '"$INSTDIR\uninstall.exe"'
  130. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoModify" 1
  131. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoRepair " 1
  132. WriteUninstaller "uninstall.exe"
  133. SectionEnd
  134. Section "Add Start Menu Shortcuts" StartMenu
  135. SetShellVarContext all
  136. CreateDirectory "$SMPROGRAMS\Blender Foundation\Blender\"
  137. CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  138. CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Blender.lnk" "$INSTDIR\Blender.exe" "" "$INSTDIR\blender.exe" 0
  139. CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Readme.lnk" "$INSTDIR\readme.html" "" "" 0
  140. CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Copyright.lnk" "$INSTDIR\Copyright.txt" "" "$INSTDIR\copyright.txt" 0
  141. CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\GPL-license.lnk" "$INSTDIR\GPL-license.txt" "" "$INSTDIR\GPL-license.txt" 0
  142. System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons
  143. SectionEnd
  144. Section "Add Desktop Shortcut" DesktopShortcut
  145. CreateShortCut "$DESKTOP\Blender.lnk" "$INSTDIR\blender.exe" "" "$INSTDIR\blender.exe" 0
  146. System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons
  147. SectionEnd
  148. Section "Open .blend files with Blender" BlendRegister
  149. ExecWait '"$INSTDIR\blender.exe" -r'
  150. SectionEnd
  151. UninstallText "This will uninstall Blender [VERSION], and all installed files. Hit 'Uninstall' to continue."
  152. Section "Uninstall"
  153. ; Remove registry keys
  154. ${If} ${RunningX64}
  155. SetRegView 64
  156. ${EndIf}
  157. ReadRegStr $SHORTVERSION HKLM "SOFTWARE\BlenderFoundation" "ShortVersion"
  158. DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Blender"
  159. DeleteRegKey HKLM "SOFTWARE\BlenderFoundation"
  160. DeleteRegKey HKCR ".blend"
  161. DeleteRegKey HKCR "blendfile"
  162. DeleteRegKey HKCR "CLSID\{D45F043D-F17F-4e8a-8435-70971D9FA46D}"
  163. SetShellVarContext all
  164. ; Remove files
  165. [DELROOTDIRCONTS]
  166. [DELDATAFILES]
  167. [DELDATADIRS]
  168. Delete "$INSTDIR\uninstall.exe"
  169. ${If} $REMOVECONFIG == "1"
  170. RMDir /r "$BLENDERCONFIG\$SHORTVERSION"
  171. ${Endif}
  172. ; Remove install directory if it's empty
  173. RMDir $INSTDIR
  174. ; Remove shortcuts
  175. Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*"
  176. Delete "$DESKTOP\Blender.lnk"
  177. ; Remove all link related directories and files
  178. RMDir "$SMPROGRAMS\Blender Foundation\Blender"
  179. RMDir "$SMPROGRAMS\Blender Foundation"
  180. System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; Refresh icons
  181. SectionEnd
  182. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  183. !insertmacro MUI_DESCRIPTION_TEXT ${InstallFiles} $(DESC_InstallFiles)
  184. !insertmacro MUI_DESCRIPTION_TEXT ${StartMenu} $(DESC_StartMenu)
  185. !insertmacro MUI_DESCRIPTION_TEXT ${DesktopShortcut} $(DESC_DesktopShortcut)
  186. !insertmacro MUI_DESCRIPTION_TEXT ${BlendRegister} $(DESC_BlendRegister)
  187. !insertmacro MUI_FUNCTION_DESCRIPTION_END