forked from CauldronDevelopmentLLC/CAMotics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
camotics.nsi
165 lines (136 loc) · 4.51 KB
/
camotics.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
; Defines
!define PRODUCT_NAME "CAMotics"
!define PRODUCT_EXE "camotics.exe"
!define PRODUCT_ICON "camotics.ico"
!define DISPLAY_NAME "${PRODUCT_NAME}"
!define UNINSTALLER "Uninstall.exe"
!define PRODUCT_LICENSE "LICENSE"
!define PRODUCT_VENDOR "%(vendor)s"
!define PRODUCT_TARGET "%(package)s"
!define PRODUCT_VERSION "%(version)s"
!define PRODUCT_WEBSITE "http://camotics.com/"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_UNINST_KEY \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_DIR_REGKEY \
"Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}"
!define MUI_ABORTWARNING
!define MUI_ICON "images\${PRODUCT_ICON}"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "images\header.bmp"
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
; Includes
!include MUI2.nsh
!include nsDialogs.nsh
!include WinVer.nsh
!include LogicLib.nsh
; Config
Name "${DISPLAY_NAME} ${PRODUCT_VERSION}"
OutFile "${PRODUCT_TARGET}"
InstallDir "$PROGRAMFILES64\${PRODUCT_NAME}"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
; Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE}"
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\${PRODUCT_EXE}"
!define MUI_FINISHPAGE_RUN_TEXT "Start ${PRODUCT_NAME}"
!insertmacro MUI_PAGE_FINISH
; !insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
; Functions
Function .onInit
${IfNot} ${AtLeastWin7}
MessageBox MB_OK "Windows 7 or above is required"
Quit
${EndIf}
FunctionEnd
; Sections
Section -Install
SetRegView 64
; Install files
SetOutPath "$INSTDIR"
File ${PRODUCT_EXE}
File "gcodetool.exe"
File "tplang.exe"
File "camsim.exe"
File "images\${PRODUCT_ICON}"
File ${PRODUCT_LICENSE}
File "README.md"
File "CHANGELOG.md"
%(NSIS_INSTALL_FILES)s
ExecWait '"$INSTDIR\%(VCREDIST)s" /passive /norestart'
; TPL Libs
SetOverwrite on
SetOutPath "$INSTDIR\tpl_lib"
File /r "tpl_lib\*.*"
; Examples
SetOverwrite on
SetOutPath "$INSTDIR\examples"
File /r "examples\*.*"
; Machines
SetOverwrite on
SetOutPath "$INSTDIR\machines"
File /r "machines\*.*"
; Desktop
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_EXE}" \
"" "$INSTDIR\${PRODUCT_ICON}"
; Start Menu
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" \
"$INSTDIR\${PRODUCT_EXE}" "" "$INSTDIR\${PRODUCT_ICON}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" \
"$INSTDIR\${UNINSTALLER}"
; Internet shortcut
WriteIniStr "$INSTDIR\About ${PRODUCT_NAME}.url" "InternetShortcut" "URL" \
"${PRODUCT_WEBSITE}"
; Write uninstaller
write_uninstaller:
ClearErrors
WriteUninstaller "$INSTDIR\${UNINSTALLER}"
IfErrors 0 +2
MessageBox MB_ABORTRETRYIGNORE "Failed to create uninstaller" \
IDABORT abort IDRETRY write_uninstaller
; Save uninstall information
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
"DisplayName" "${PRODUCT_NAME}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
"UninstallString" "$INSTDIR\${UNINSTALLER}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
"DisplayIcon" "$INSTDIR\${PRODUCT_ICON}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
"URLInfoAbout" "${PRODUCT_WEBSITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
"Publisher" "${PRODUCT_VENDOR}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" \
"DisplayVersion" "${PRODUCT_VERSION}"
# Uninstall OpenSCAM
IfFileExists "$PROGRAMFILES32\OpenSCAM\${UNINSTALLER}" 0 done
MessageBox MB_YESNO \
"CAMotics replaces OpenSCAM. Do you want to uninstall OpenSCAM?" \
IDNO done
ExecWait '"$PROGRAMFILES32\OpenSCAM\${UNINSTALLER}" /S'
done:
Return
abort:
Abort
SectionEnd
Section -un.Program
; Menu
RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}"
; Desktop
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
; Registry
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
; Program directory
remove_dir:
ClearErrors
RMDir /r "$INSTDIR"
IfErrors 0 +2
MessageBox MB_RETRYCANCEL "Failed to remove $INSTDIR. Please stop all \
running ${PRODUCT_NAME} software." IDRETRY remove_dir
SectionEnd