chiark / gitweb /
7555419d46b879519303c522cd800b6613b6ee0b
[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 "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 ; Pages
48 ;!insertmacro MUI_PAGE_WELCOME
49 !insertmacro MUI_PAGE_DIRECTORY
50 !insertmacro MUI_PAGE_COMPONENTS
51 !insertmacro MUI_PAGE_INSTFILES
52 !insertmacro MUI_PAGE_FINISH
53 !insertmacro MUI_UNPAGE_CONFIRM
54 !insertmacro MUI_UNPAGE_INSTFILES
55 !insertmacro MUI_UNPAGE_FINISH
56
57 ; Languages
58 !insertmacro MUI_LANGUAGE "English"
59
60 ; Reserve Files
61 !insertmacro MUI_RESERVEFILE_LANGDLL
62 ReserveFile '${NSISDIR}\Plugins\InstallOptions.dll'
63 ReserveFile "cura.ico"
64 ReserveFile "header.bmp"
65
66 ;--------------------------------
67
68 ; The stuff to install
69 Section "Cura ${VERSION}"
70
71   SectionIn RO
72   
73   ; Set output path to the installation directory.
74   SetOutPath $INSTDIR
75   
76   ; Put file there
77   File /r "dist\"
78   
79   ; Write the installation path into the registry
80   WriteRegStr HKLM "SOFTWARE\Cura_${VERSION}" "Install_Dir" "$INSTDIR"
81   
82   ; Write the uninstall keys for Windows
83   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "DisplayName" "Cura ${VERSION}"
84   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "UninstallString" '"$INSTDIR\uninstall.exe"'
85   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "NoModify" 1
86   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}" "NoRepair" 1
87   WriteUninstaller "uninstall.exe"
88   
89   CreateDirectory "$SMPROGRAMS\Cura ${VERSION}"
90   CreateShortCut "$SMPROGRAMS\Cura ${VERSION}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
91   CreateShortCut "$SMPROGRAMS\Cura ${VERSION}\Cura.lnk" "$INSTDIR\python\python.exe" "$INSTDIR\Cura\cura.py" "$INSTDIR\cura.ico" 0
92
93   ; Set output path to the driver directory.
94   SetOutPath "$INSTDIR\drivers\"
95   File /r "drivers\"
96   
97   ${If} ${RunningX64}
98     ExecWait '"$INSTDIR\drivers\dpinst64.exe" /lm'
99   ${Else}
100     ExecWait '"$INSTDIR\drivers\dpinst32.exe" /lm'
101   ${EndIf}
102   
103   ; Give all users write permissions in the install directory, so they can read/write profile and preferences files.
104   AccessControl::GrantOnFile "$INSTDIR" "(S-1-5-32-545)" "FullAccess"
105   
106 SectionEnd
107
108 Section "Open STL files with Cura"
109         WriteRegStr HKCR .stl "" "Cura STL model file"
110         DeleteRegValue HKCR .stl "Content Type"
111         WriteRegStr HKCR "Cura STL model file\DefaultIcon" "" "$INSTDIR\Cura\stl.ico,0"
112         WriteRegStr HKCR "Cura STL model file\shell" "" "open"
113         WriteRegStr HKCR "Cura STL model file\shell\open\command" "" '"$INSTDIR\python\python.exe" "$INSTDIR\Cura\cura.py" "%1"'
114 SectionEnd
115
116 ;--------------------------------
117
118 ; Uninstaller
119
120 Section "Uninstall"
121   
122   ; Remove registry keys
123   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cura_${VERSION}"
124   DeleteRegKey HKLM "SOFTWARE\Cura_${VERSION}"
125
126   ; Remove directories used
127   RMDir /r "$SMPROGRAMS\Cura ${VERSION}"
128   RMDir /r "$INSTDIR"
129
130 SectionEnd
131