chiark / gitweb /
Merge pull request #601 from CapnBry/reloadscene
[cura.git] / scripts / win32 / installer.nsi
1 !ifndef VERSION
2   !define VERSION 'DEV'
3 !endif
4 !addplugindir "nsisPlugins"
5
6 ; The name of the installer
7 Name "Cura ${VERSION}"
8
9 ; The file to write
10 OutFile "Cura_${VERSION}.exe"
11
12 ; The default installation directory
13 InstallDir $PROGRAMFILES\Cura_${VERSION}
14
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"
18
19 ; Request application privileges for Windows Vista
20 RequestExecutionLevel admin
21
22 ; Set the LZMA compressor to reduce size.
23 SetCompressor /SOLID lzma
24 ;--------------------------------
25
26 !include "MUI2.nsh"
27 !include Library.nsh
28
29 !define MUI_ICON "dist/resources/cura.ico"
30 !define MUI_BGCOLOR FFFFFF
31
32 ; Directory page defines
33 !define MUI_DIRECTORYPAGE_VERIFYONLEAVE
34
35 ; Header
36 !define MUI_HEADERIMAGE
37 !define MUI_HEADERIMAGE_RIGHT
38 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
39 !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH 
40 ; Don't show the component description box
41 !define MUI_COMPONENTSPAGE_NODESC
42
43 ;Do not leave (Un)Installer page automaticly
44 !define MUI_FINISHPAGE_NOAUTOCLOSE
45 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
46
47 ;Run Cura after installing
48 !define MUI_FINISHPAGE_RUN
49 !define MUI_FINISHPAGE_RUN_TEXT "Start Cura ${VERSION}"
50 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
51
52 ; Pages
53 ;!insertmacro MUI_PAGE_WELCOME
54 !insertmacro MUI_PAGE_DIRECTORY
55 !insertmacro MUI_PAGE_COMPONENTS
56 !insertmacro MUI_PAGE_INSTFILES
57 !insertmacro MUI_PAGE_FINISH
58 !insertmacro MUI_UNPAGE_CONFIRM
59 !insertmacro MUI_UNPAGE_INSTFILES
60 !insertmacro MUI_UNPAGE_FINISH
61
62 ; Languages
63 !insertmacro MUI_LANGUAGE "English"
64
65 ; Reserve Files
66 !insertmacro MUI_RESERVEFILE_LANGDLL
67 ReserveFile '${NSISDIR}\Plugins\InstallOptions.dll'
68 ReserveFile "header.bmp"
69
70 ;--------------------------------
71
72 ; The stuff to install
73 Section "Cura ${VERSION}"
74
75   SectionIn RO
76   
77   ; Set output path to the installation directory.
78   SetOutPath $INSTDIR
79   
80   ; Put file there
81   File /r "dist\"
82   
83   ; Write the installation path into the registry
84   WriteRegStr HKLM "SOFTWARE\Cura_${VERSION}" "Install_Dir" "$INSTDIR"
85   
86   ; Write the uninstall keys for Windows
87   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "DisplayName" "Cura ${VERSION}"
88   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "UninstallString" '"$INSTDIR\uninstall.exe"'
89   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "NoModify" 1
90   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "NoRepair" 1
91   WriteUninstaller "uninstall.exe"
92
93   ; Write start menu entries for all users
94   SetShellVarContext all
95   
96   CreateDirectory "$SMPROGRAMS\Cura ${VERSION}"
97   CreateShortCut "$SMPROGRAMS\Cura ${VERSION}\Uninstall Cura ${VERSION}.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
98   CreateShortCut "$SMPROGRAMS\Cura ${VERSION}\Cura ${VERSION}.lnk" "$INSTDIR\python\pythonw.exe" '-m "Cura.cura"' "$INSTDIR\resources\cura.ico" 0
99   
100   ; Give all users write permissions in the install directory, so they can read/write profile and preferences files.
101   AccessControl::GrantOnFile "$INSTDIR" "(S-1-5-32-545)" "FullAccess"
102   
103 SectionEnd
104
105 Function LaunchLink
106   ; Write start menu entries for all users
107   SetShellVarContext all
108   ExecShell "" "$SMPROGRAMS\Cura ${VERSION}\Cura ${VERSION}.lnk"
109 FunctionEnd
110
111 Section "Install Arduino Drivers"
112   ; Set output path to the driver directory.
113   SetOutPath "$INSTDIR\drivers\"
114   File /r "drivers\"
115   
116   ${If} ${RunningX64}
117     ExecWait '"$INSTDIR\drivers\dpinst64.exe" /lm'
118   ${Else}
119     ExecWait '"$INSTDIR\drivers\dpinst32.exe" /lm'
120   ${EndIf}
121 SectionEnd
122
123 Section "Open STL files with Cura"
124         WriteRegStr HKCR .stl "" "Cura STL model file"
125         DeleteRegValue HKCR .stl "Content Type"
126         WriteRegStr HKCR "Cura STL model file\DefaultIcon" "" "$INSTDIR\resources\stl.ico,0"
127         WriteRegStr HKCR "Cura STL model file\shell" "" "open"
128         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"'
129 SectionEnd
130
131 Section /o "Open OBJ files with Cura"
132         WriteRegStr HKCR .obj "" "Cura OBJ model file"
133         DeleteRegValue HKCR .obj "Content Type"
134         WriteRegStr HKCR "Cura OBJ model file\DefaultIcon" "" "$INSTDIR\resources\stl.ico,0"
135         WriteRegStr HKCR "Cura OBJ model file\shell" "" "open"
136         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"'
137 SectionEnd
138
139 Section /o "Open AMF files with Cura"
140         WriteRegStr HKCR .amf "" "Cura AMF model file"
141         DeleteRegValue HKCR .amf "Content Type"
142         WriteRegStr HKCR "Cura AMF model file\DefaultIcon" "" "$INSTDIR\resources\stl.ico,0"
143         WriteRegStr HKCR "Cura AMF model file\shell" "" "open"
144         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"'
145 SectionEnd
146
147 ;--------------------------------
148
149 ; Uninstaller
150
151 Section "Uninstall"
152   
153   ; Remove registry keys
154   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}"
155   DeleteRegKey HKLM "SOFTWARE\Cura_${VERSION}"
156
157   ; Write start menu entries for all users
158   SetShellVarContext all
159   ; Remove directories used
160   RMDir /r "$SMPROGRAMS\Cura ${VERSION}"
161   RMDir /r "$INSTDIR"
162
163 SectionEnd
164