2010-07-05 19:59:27 +00:00
;
; $Id$
;
; Blender Self-Installer for Windows (NSIS - http://nsis.sourceforge.net)
;
2011-03-29 13:00:03 +00:00
SetCompressor /SOLID lzma
Name "Blender [VERSION]"
2011-04-12 08:41:26 +00:00
RequestExecutionLevel admin
2011-03-29 13:00:03 +00:00
2010-07-05 19:59:27 +00:00
!include "MUI.nsh"
!include "WinVer.nsh"
!include "FileFunc.nsh"
!include "WordFunc.nsh"
!include "nsDialogs.nsh"
2010-10-26 23:52:34 +00:00
!include "x64.nsh"
2010-07-05 19:59:27 +00:00
!define MUI_ABORTWARNING
!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."
!define MUI_WELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "[RELDIR]\00.header.bmp"
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_FINISHPAGE_RUN "$INSTDIR\blender.exe"
!define MUI_CHECKBITMAP "[RELDIR]\00.checked.bmp"
2010-07-07 12:46:39 +00:00
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp"
2010-07-05 19:59:27 +00:00
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "[DISTDIR]\Copyright.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
Page custom DataLocation DataLocationOnLeave
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro Locate
!insertmacro VersionCompare
Icon "[RELDIR]\00.installer.ico"
UninstallIcon "[RELDIR]\00.installer.ico"
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Language Strings
;Description
2011-03-29 13:00:03 +00:00
LangString DESC_InstallFiles ${LANG_ENGLISH} "Copy all required files to the application folder."
LangString DESC_StartMenu ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)"
LangString DESC_DesktopShortcut ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop."
LangString DESC_BlendRegister ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc."
2010-07-05 19:59:27 +00:00
LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Specify User Data Location"
;--------------------------------
;Data
Caption "Blender [VERSION] Installer"
2010-07-06 09:19:52 +00:00
OutFile "[DISTDIR]\..\blender-[VERSION]-windows[BITNESS].exe"
2011-03-29 13:00:03 +00:00
InstallDir $INSTDIR ; $INSTDIR is set inside .onInit
2010-07-06 09:13:10 +00:00
BrandingText "Blender Foundation | http://www.blender.org"
2010-07-05 19:59:27 +00:00
ComponentText "This will install Blender [VERSION] on your computer."
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."
SilentUnInstall normal
Var BLENDERHOME
2010-07-06 09:13:10 +00:00
Var SHORTVERSION ; This is blender_version_decimal() from path_util.c
2010-07-05 19:59:27 +00:00
2011-03-29 13:00:03 +00:00
; Custom controls
2010-07-05 19:59:27 +00:00
Var HWND
Var HWND_APPDATA
Var HWND_INSTDIR
Var HWND_HOMEDIR
2010-07-06 09:13:10 +00:00
Function .onInit
2010-07-07 12:46:39 +00:00
ClearErrors
2010-07-06 09:13:10 +00:00
StrCpy $SHORTVERSION "[SHORTVERSION]"
2011-03-29 13:00:03 +00:00
${If} ${RunningX64}
${If} "[BITNESS]" == "32"
${OrIf} "[BITNESS]" == "-mingw"
StrCpy $INSTDIR "$PROGRAMFILES32\Blender Foundation\Blender" ; Can't use InstallDir inside Section
${ElseIf} "[BITNESS]" == "64"
StrCpy $INSTDIR "$PROGRAMFILES64\Blender Foundation\Blender"
${EndIf}
${Else}
StrCpy $INSTDIR "$PROGRAMFILES\Blender Foundation\Blender"
${EndIf}
FunctionEnd
Function un.onInit
2010-07-05 19:59:27 +00:00
FunctionEnd
Function DataLocation
nsDialogs::Create /NOUNLOAD 1018
Pop $HWND
${If} $HWND == error
Abort
${EndIf}
2011-03-29 13:00:03 +00:00
${NSD_CreateLabel} 0 0 100% 24u "Please specify where you wish to install Blender's user data files. Be aware that if you choose to use your Application Data directory, your preferences and scripts will only be accessible by the current user account."
${NSD_CreateRadioButton} 0 50 100% 12u "Use Application Data directory (recommended)"
2010-07-05 19:59:27 +00:00
Pop $HWND_APPDATA
2011-03-29 13:00:03 +00:00
${NSD_CreateRadioButton} 0 80 100% 12u "Use installation directory"
2010-07-05 19:59:27 +00:00
Pop $HWND_INSTDIR
2011-03-29 13:00:03 +00:00
${NSD_CreateRadioButton} 0 110 100% 12u "I have defined a %HOME% variable, please install files there"
2010-07-05 19:59:27 +00:00
Pop $HWND_HOMEDIR
${If} ${AtMostWinME}
GetDlgItem $0 $HWND $HWND_APPDATA
EnableWindow $0 0
SendMessage $HWND_INSTDIR ${BM_SETCHECK} 1 0
${Else}
SendMessage $HWND_APPDATA ${BM_SETCHECK} 1 0
${EndIf}
nsDialogs::Show
FunctionEnd
Function DataLocationOnLeave
${NSD_GetState} $HWND_APPDATA $R0
${If} $R0 == "1"
2011-03-29 13:00:03 +00:00
SetShellVarContext current
2010-07-06 09:13:10 +00:00
StrCpy $BLENDERHOME "$APPDATA\Blender Foundation\Blender"
2011-03-29 13:00:03 +00:00
SetShellVarContext all
2010-07-05 19:59:27 +00:00
${Else}
${NSD_GetState} $HWND_INSTDIR $R0
${If} $R0 == "1"
2010-07-06 09:13:10 +00:00
StrCpy $BLENDERHOME $INSTDIR
2010-07-05 19:59:27 +00:00
${Else}
${NSD_GetState} $HWND_HOMEDIR $R0
${If} $R0 == "1"
ReadEnvStr $BLENDERHOME "HOME"
${EndIf}
${EndIf}
${EndIf}
FunctionEnd
2011-03-29 13:00:03 +00:00
Section "Blender [VERSION] (required)" InstallFiles
2010-07-05 19:59:27 +00:00
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
2011-03-29 13:00:03 +00:00
; The contents of Blender installation root dir
2010-07-05 19:59:27 +00:00
[ROOTDIRCONTS]
2011-03-29 13:00:03 +00:00
; All datafiles (python, scripts, config)
2010-07-05 19:59:27 +00:00
[DODATAFILES]
SetOutPath $INSTDIR
2010-10-26 23:52:34 +00:00
${If} ${RunningX64}
SetRegView 64
${EndIf}
2010-07-05 19:59:27 +00:00
; Write the installation path into the registry
2010-07-06 09:13:10 +00:00
WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "Install_Dir" "$INSTDIR"
WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir" "$BLENDERHOME"
WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" "[SHORTVERSION]"
2010-07-05 19:59:27 +00:00
; Write the uninstall keys for Windows
2011-03-29 13:00:03 +00:00
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "Publisher" "Blender Foundation"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "URLInfoAbout" "http://www.blender.org/"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayVersion" "[VERSION]"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayIcon" "$INSTDIR\blender.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoRepair " 1
2010-07-05 19:59:27 +00:00
WriteUninstaller "uninstall.exe"
SectionEnd
2011-03-29 13:00:03 +00:00
Section "Add Start Menu Shortcuts" StartMenu
2010-07-07 12:46:39 +00:00
SetShellVarContext all
2010-07-05 19:59:27 +00:00
CreateDirectory "$SMPROGRAMS\Blender Foundation\Blender\"
CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Blender.lnk" "$INSTDIR\Blender.exe" "" "$INSTDIR\blender.exe" 0
2010-07-08 06:16:08 +00:00
CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Readme.lnk" "$INSTDIR\readme.html" "" "" 0
2010-07-05 19:59:27 +00:00
CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Copyright.lnk" "$INSTDIR\Copyright.txt" "" "$INSTDIR\copyright.txt" 0
CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\GPL-license.lnk" "$INSTDIR\GPL-license.txt" "" "$INSTDIR\GPL-license.txt" 0
2011-03-29 13:00:03 +00:00
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons
2010-07-05 19:59:27 +00:00
SectionEnd
2011-03-29 13:00:03 +00:00
Section "Add Desktop Shortcut" DesktopShortcut
2010-07-05 19:59:27 +00:00
CreateShortCut "$DESKTOP\Blender.lnk" "$INSTDIR\blender.exe" "" "$INSTDIR\blender.exe" 0
2011-03-29 13:00:03 +00:00
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons
2010-07-05 19:59:27 +00:00
SectionEnd
2011-03-29 13:00:03 +00:00
Section "Open .blend files with Blender" BlendRegister
2011-04-12 08:41:26 +00:00
ExecWait '"$INSTDIR\blender.exe" -r'
2010-07-05 19:59:27 +00:00
SectionEnd
2011-03-29 13:00:03 +00:00
UninstallText "This will uninstall Blender [VERSION], and all installed files. Before continuing make sure you have created backup of all the files you may want to keep: startup.blend, bookmarks.txt, recent-files.txt. Hit 'Uninstall' to continue."
2010-07-05 19:59:27 +00:00
Section "Uninstall"
2011-03-29 13:00:03 +00:00
; Remove registry keys
2010-10-26 23:52:34 +00:00
${If} ${RunningX64}
SetRegView 64
${EndIf}
2011-03-29 13:00:03 +00:00
2010-07-06 09:13:10 +00:00
ReadRegStr $BLENDERHOME HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir"
ReadRegStr $SHORTVERSION HKLM "SOFTWARE\BlenderFoundation" "ShortVersion"
2011-03-29 13:00:03 +00:00
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Blender"
2010-07-06 09:13:10 +00:00
DeleteRegKey HKLM "SOFTWARE\BlenderFoundation"
2011-03-29 13:00:03 +00:00
DeleteRegKey HKCR ".blend"
DeleteRegKey HKCR "blendfile"
DeleteRegKey HKCR "CLSID\{D45F043D-F17F-4e8a-8435-70971D9FA46D}"
2010-07-07 12:46:39 +00:00
SetShellVarContext all
2010-10-26 22:48:26 +00:00
2011-03-29 13:00:03 +00:00
; Remove files
2010-07-05 19:59:27 +00:00
[DELROOTDIRCONTS]
2010-07-06 09:13:10 +00:00
Delete "$INSTDIR\uninstall.exe"
2010-10-26 22:48:26 +00:00
MessageBox MB_YESNO "Recursively erase contents of $BLENDERHOME\$SHORTVERSION\scripts? NOTE: This includes all installed scripts and *any* file and directory you have manually created, installed later or copied. This also including .blend files." IDNO NextNoScriptRemove
RMDir /r "$BLENDERHOME\$SHORTVERSION\scripts"
NextNoScriptRemove:
MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\config? NOTE: This includes your startup.blend, bookmarks and any other file and directory you may have created in that directory" IDNO NextNoConfigRemove
RMDir /r "$BLENDERHOME\$SHORTVERSION\config"
NextNoConfigRemove:
MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\plugins? NOTE: This includes files and subdirectories in this directory" IDNO NextNoPluginRemove
RMDir /r "$BLENDERHOME\$SHORTVERSION\plugins"
NextNoPluginRemove:
2011-03-29 13:00:03 +00:00
; Try to remove dirs, but leave them if they contain anything
2010-10-26 22:48:26 +00:00
RMDir "$BLENDERHOME\$SHORTVERSION\plugins"
RMDir "$BLENDERHOME\$SHORTVERSION\config"
RMDir "$BLENDERHOME\$SHORTVERSION\scripts"
RMDir "$BLENDERHOME\$SHORTVERSION"
RMDir "$BLENDERHOME"
2011-03-29 13:00:03 +00:00
; Remove shortcuts
2010-10-26 22:48:26 +00:00
Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*"
2010-07-05 19:59:27 +00:00
Delete "$DESKTOP\Blender.lnk"
2011-03-29 13:00:03 +00:00
; Remove all link related directories and files
RMDir /r "$SMPROGRAMS\Blender Foundation"
2010-10-26 22:48:26 +00:00
; Clear out installation dir
2011-03-29 13:00:03 +00:00
RMDir /r "$INSTDIR"
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; Refresh icons
2010-07-05 19:59:27 +00:00
SectionEnd
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
2011-03-29 13:00:03 +00:00
!insertmacro MUI_DESCRIPTION_TEXT ${InstallFiles} $(DESC_InstallFiles)
!insertmacro MUI_DESCRIPTION_TEXT ${StartMenu} $(DESC_StartMenu)
!insertmacro MUI_DESCRIPTION_TEXT ${DesktopShortcut} $(DESC_DesktopShortcut)
!insertmacro MUI_DESCRIPTION_TEXT ${BlendRegister} $(DESC_BlendRegister)
2010-07-05 19:59:27 +00:00
!insertmacro MUI_FUNCTION_DESCRIPTION_END