4 !addplugindir "nsisPlugins"
6 ; The name of the installer
10 OutFile "Cura_${VERSION}.exe"
12 ; The default installation directory
13 InstallDir $PROGRAMFILES\Cura_${VERSION}
15 ; Registry key to check for directory (so if you install again, it will
16 ; overwrite the old one automatically)
17 InstallDirRegKey HKLM "Software\Cura_${VERSION}" "Install_Dir"
19 ; Request application privileges for Windows Vista
20 RequestExecutionLevel admin
22 ; Set the LZMA compressor to reduce size.
23 SetCompressor /SOLID lzma
24 ;--------------------------------
27 !include "Library.nsh"
29 ;--------------------------------
32 ; This function does a case sensitive searches for an occurrence of a substring in a string.
33 ; It returns the substring if it is found.
34 ; Otherwise it returns null("").
35 ; Written by kenglish_hi
36 ; Adapted from StrReplace written by dandaman32
41 Var STR_CONTAINS_VAR_1
42 Var STR_CONTAINS_VAR_2
43 Var STR_CONTAINS_VAR_3
44 Var STR_CONTAINS_VAR_4
52 ;MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
53 StrCpy $STR_RETURN_VAR ""
54 StrCpy $STR_CONTAINS_VAR_1 -1
55 StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
56 StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
58 IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
59 StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
60 StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
61 StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
64 StrCpy $STR_RETURN_VAR $STR_NEEDLE
67 Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the
71 !macro _StrContainsConstructor OUT NEEDLE HAYSTACK
78 !define StrContains '!insertmacro "_StrContainsConstructor"'
79 ;--------------------------------
81 !define MUI_ICON "dist/resources/cura.ico"
82 !define MUI_BGCOLOR FFFFFF
84 ; Directory page defines
85 !define MUI_DIRECTORYPAGE_VERIFYONLEAVE
88 !define MUI_HEADERIMAGE
89 !define MUI_HEADERIMAGE_RIGHT
90 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
91 !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
92 ; Don't show the component description box
93 !define MUI_COMPONENTSPAGE_NODESC
95 ;Do not leave (Un)Installer page automaticly
96 !define MUI_FINISHPAGE_NOAUTOCLOSE
97 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
99 ;Run Cura after installing
100 !define MUI_FINISHPAGE_RUN
101 !define MUI_FINISHPAGE_RUN_TEXT "Start Cura ${VERSION}"
102 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
105 ;!insertmacro MUI_PAGE_WELCOME
106 !insertmacro MUI_PAGE_DIRECTORY
107 !insertmacro MUI_PAGE_COMPONENTS
108 !insertmacro MUI_PAGE_INSTFILES
109 !insertmacro MUI_PAGE_FINISH
110 !insertmacro MUI_UNPAGE_CONFIRM
111 !insertmacro MUI_UNPAGE_INSTFILES
112 !insertmacro MUI_UNPAGE_FINISH
115 !insertmacro MUI_LANGUAGE "English"
118 !insertmacro MUI_RESERVEFILE_LANGDLL
119 ReserveFile '${NSISDIR}\Plugins\InstallOptions.dll'
120 ReserveFile "header.bmp"
122 ;--------------------------------
124 ; The stuff to install
125 Section "Cura ${VERSION}"
129 ; Set output path to the installation directory.
135 ; Write the installation path into the registry
136 WriteRegStr HKLM "SOFTWARE\Cura_${VERSION}" "Install_Dir" "$INSTDIR"
138 ; Write the uninstall keys for Windows
139 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "DisplayName" "Cura ${VERSION}"
140 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "UninstallString" '"$INSTDIR\uninstall.exe"'
141 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "NoModify" 1
142 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "NoRepair" 1
143 WriteUninstaller "uninstall.exe"
145 ; Write start menu entries for all users
146 SetShellVarContext all
148 CreateDirectory "$SMPROGRAMS\Cura ${VERSION}"
149 CreateShortCut "$SMPROGRAMS\Cura ${VERSION}\Uninstall Cura ${VERSION}.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
150 CreateShortCut "$SMPROGRAMS\Cura ${VERSION}\Cura ${VERSION}.lnk" "$INSTDIR\python\pythonw.exe" '-m "Cura.cura"' "$INSTDIR\resources\cura.ico" 0
155 ; Write start menu entries for all users
156 SetShellVarContext all
157 ExecShell "" "$SMPROGRAMS\Cura ${VERSION}\Cura ${VERSION}.lnk"
160 Section "Install Arduino Drivers"
161 ; Set output path to the driver directory.
162 SetOutPath "$INSTDIR\drivers\"
167 ExecWait '"$INSTDIR\drivers\dpinst64.exe" /lm'
170 ExecWait '"$INSTDIR\drivers\dpinst32.exe" /lm'
174 Section "Open STL files with Cura"
175 WriteRegStr HKCR .stl "" "Cura STL model file"
176 DeleteRegValue HKCR .stl "Content Type"
177 WriteRegStr HKCR "Cura STL model file\DefaultIcon" "" "$INSTDIR\resources\stl.ico,0"
178 WriteRegStr HKCR "Cura STL model file\shell" "" "open"
179 WriteRegStr HKCR "Cura STL model file\shell\open\command" "" '"$INSTDIR\python\pythonw.exe" -c "import os; os.chdir(\"$INSTDIR\"); import Cura.cura; Cura.cura.main()" "%1"'
182 Section /o "Open OBJ files with Cura"
183 WriteRegStr HKCR .obj "" "Cura OBJ model file"
184 DeleteRegValue HKCR .obj "Content Type"
185 WriteRegStr HKCR "Cura OBJ model file\DefaultIcon" "" "$INSTDIR\resources\stl.ico,0"
186 WriteRegStr HKCR "Cura OBJ model file\shell" "" "open"
187 WriteRegStr HKCR "Cura OBJ model file\shell\open\command" "" '"$INSTDIR\python\pythonw.exe" -c "import os; os.chdir(\"$INSTDIR\"); import Cura.cura; Cura.cura.main()" "%1"'
190 Section /o "Open AMF files with Cura"
191 WriteRegStr HKCR .amf "" "Cura AMF model file"
192 DeleteRegValue HKCR .amf "Content Type"
193 WriteRegStr HKCR "Cura AMF model file\DefaultIcon" "" "$INSTDIR\resources\stl.ico,0"
194 WriteRegStr HKCR "Cura AMF model file\shell" "" "open"
195 WriteRegStr HKCR "Cura AMF model file\shell\open\command" "" '"$INSTDIR\python\pythonw.exe" -c "import os; os.chdir(\"$INSTDIR\"); import Cura.cura; Cura.cura.main()" "%1"'
198 ;--------------------------------
204 ; Remove registry keys
205 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}"
206 DeleteRegKey HKLM "SOFTWARE\Cura_${VERSION}"
208 ; Write start menu entries for all users
209 SetShellVarContext all
210 ; Remove directories used
211 RMDir /r "$SMPROGRAMS\Cura ${VERSION}"