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 !system "check_drivers.bat"
31 ;--------------------------------
34 ; This function does a case sensitive searches for an occurrence of a substring in a string.
35 ; It returns the substring if it is found.
36 ; Otherwise it returns null("").
37 ; Written by kenglish_hi
38 ; Adapted from StrReplace written by dandaman32
43 Var STR_CONTAINS_VAR_1
44 Var STR_CONTAINS_VAR_2
45 Var STR_CONTAINS_VAR_3
46 Var STR_CONTAINS_VAR_4
54 ;MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
55 StrCpy $STR_RETURN_VAR ""
56 StrCpy $STR_CONTAINS_VAR_1 -1
57 StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
58 StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
60 IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
61 StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
62 StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
63 StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
66 StrCpy $STR_RETURN_VAR $STR_NEEDLE
69 Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the
73 !macro _StrContainsConstructor OUT NEEDLE HAYSTACK
80 !define StrContains '!insertmacro "_StrContainsConstructor"'
81 ;--------------------------------
83 !define MUI_ICON "dist/resources/cura.ico"
84 !define MUI_BGCOLOR FFFFFF
86 ; Directory page defines
87 !define MUI_DIRECTORYPAGE_VERIFYONLEAVE
90 !define MUI_HEADERIMAGE
91 !define MUI_HEADERIMAGE_RIGHT
92 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
93 !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
94 ; Don't show the component description box
95 !define MUI_COMPONENTSPAGE_NODESC
97 ;Do not leave (Un)Installer page automaticly
98 !define MUI_FINISHPAGE_NOAUTOCLOSE
99 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
101 ;Run Cura after installing
102 !define MUI_FINISHPAGE_RUN
103 !define MUI_FINISHPAGE_RUN_TEXT "Start Cura ${VERSION}"
104 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
107 ;!insertmacro MUI_PAGE_WELCOME
108 !insertmacro MUI_PAGE_DIRECTORY
109 !insertmacro MUI_PAGE_COMPONENTS
110 !insertmacro MUI_PAGE_INSTFILES
111 !insertmacro MUI_PAGE_FINISH
112 !insertmacro MUI_UNPAGE_CONFIRM
113 !insertmacro MUI_UNPAGE_INSTFILES
114 !insertmacro MUI_UNPAGE_FINISH
117 !insertmacro MUI_LANGUAGE "English"
120 !insertmacro MUI_RESERVEFILE_LANGDLL
121 ReserveFile '${NSISDIR}\Plugins\InstallOptions.dll'
122 ReserveFile "header.bmp"
124 ;--------------------------------
126 ; The stuff to install
127 Section "Cura ${VERSION}"
131 ; Set output path to the installation directory.
137 ; Write the installation path into the registry
138 WriteRegStr HKLM "SOFTWARE\Cura_${VERSION}" "Install_Dir" "$INSTDIR"
140 ; Write the uninstall keys for Windows
141 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "DisplayName" "Cura ${VERSION}"
142 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "UninstallString" '"$INSTDIR\uninstall.exe"'
143 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "NoModify" 1
144 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "NoRepair" 1
145 WriteUninstaller "uninstall.exe"
147 ; Write start menu entries for all users
148 SetShellVarContext all
150 CreateDirectory "$SMPROGRAMS\Cura ${VERSION}"
151 CreateShortCut "$SMPROGRAMS\Cura ${VERSION}\Uninstall Cura ${VERSION}.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
152 CreateShortCut "$SMPROGRAMS\Cura ${VERSION}\Cura ${VERSION}.lnk" "$INSTDIR\python\pythonw.exe" '-m "Cura.cura"' "$INSTDIR\resources\cura.ico" 0
157 ; Write start menu entries for all users
158 SetShellVarContext all
159 Exec '"$WINDIR\explorer.exe" "$SMPROGRAMS\Cura ${VERSION}\Cura ${VERSION}.lnk"'
162 Section "Install Arduino Drivers"
163 ; Set output path to the driver directory.
164 SetOutPath "$INSTDIR\drivers\"
169 ExecWait '"$INSTDIR\drivers\dpinst64.exe" /lm'
172 ExecWait '"$INSTDIR\drivers\dpinst32.exe" /lm'
176 Section "Open STL files with Cura"
177 WriteRegStr HKCR .stl "" "Cura STL model file"
178 DeleteRegValue HKCR .stl "Content Type"
179 WriteRegStr HKCR "Cura STL model file\DefaultIcon" "" "$INSTDIR\resources\stl.ico,0"
180 WriteRegStr HKCR "Cura STL model file\shell" "" "open"
181 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"'
184 Section /o "Open OBJ files with Cura"
185 WriteRegStr HKCR .obj "" "Cura OBJ model file"
186 DeleteRegValue HKCR .obj "Content Type"
187 WriteRegStr HKCR "Cura OBJ model file\DefaultIcon" "" "$INSTDIR\resources\stl.ico,0"
188 WriteRegStr HKCR "Cura OBJ model file\shell" "" "open"
189 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"'
192 Section /o "Open AMF files with Cura"
193 WriteRegStr HKCR .amf "" "Cura AMF model file"
194 DeleteRegValue HKCR .amf "Content Type"
195 WriteRegStr HKCR "Cura AMF model file\DefaultIcon" "" "$INSTDIR\resources\stl.ico,0"
196 WriteRegStr HKCR "Cura AMF model file\shell" "" "open"
197 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"'
200 ;--------------------------------
206 ; Remove registry keys
207 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}"
208 DeleteRegKey HKLM "SOFTWARE\Cura_${VERSION}"
210 ; Write start menu entries for all users
211 SetShellVarContext all
212 ; Remove directories used
213 RMDir /r "$SMPROGRAMS\Cura ${VERSION}"