]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - os_win32/installer.nsi
Imported Upstream version 6.3+svn3990
[mirror_smartmontools-debian.git] / os_win32 / installer.nsi
CommitLineData
4d59bff9 1;
cfbba5b9 2; smartmontools install NSIS script
4d59bff9 3;
cfbba5b9 4; Home page of code is: http://smartmontools.sourceforge.net
4d59bff9 5;
d2e702cf 6; Copyright (C) 2006-14 Christian Franke <smartmontools-support@lists.sourceforge.net>
4d59bff9 7;
cfbba5b9
GI
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2, or (at your option)
11; any later version.
4d59bff9 12;
cfbba5b9
GI
13; You should have received a copy of the GNU General Public License
14; (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
15;
d2e702cf 16; $Id: installer.nsi 3912 2014-06-18 19:03:30Z chrfranke $
4d59bff9
GG
17;
18
19
20;--------------------------------------------------------------------
21; Command line arguments:
f4e463df
GI
22; makensis -DINPDIR=<input-dir> -DINPDIR64=<input-dir-64-bit> \
23; -DOUTFILE=<output-file> -DVERSTR=<version-string> installer.nsi
4d59bff9
GG
24
25!ifndef INPDIR
26 !define INPDIR "."
27!endif
28
29!ifndef OUTFILE
30 !define OUTFILE "smartmontools.win32-setup.exe"
31!endif
32
33;--------------------------------------------------------------------
34; General
35
36Name "smartmontools"
37OutFile "${OUTFILE}"
38
39SetCompressor /solid lzma
40
41XPStyle on
42InstallColors /windows
43
f4e463df
GI
44; Set in .onInit
45;InstallDir "$PROGRAMFILES\smartmontools"
46;InstallDirRegKey HKLM "Software\smartmontools" "Install_Dir"
d008864d
GI
47
48Var EDITOR
f4e463df
GI
49
50!ifdef INPDIR64
51 Var X64
52 Var INSTDIR32
53 Var INSTDIR64
54!endif
4d59bff9
GG
55
56LicenseData "${INPDIR}\doc\COPYING.txt"
57
a7e8ffec
GI
58!include "FileFunc.nsh"
59!include "Sections.nsh"
60
61!insertmacro GetParameters
62!insertmacro GetOptions
63
64RequestExecutionLevel admin
65
4d59bff9
GG
66;--------------------------------------------------------------------
67; Pages
68
69Page license
70Page components
f4e463df
GI
71!ifdef INPDIR64
72 Page directory CheckX64
73!else
74 Page directory
75!endif
4d59bff9
GG
76Page instfiles
77
78UninstPage uninstConfirm
79UninstPage instfiles
80
81InstType "Full"
82InstType "Extract files only"
a37e7145 83InstType "Drive menu"
4d59bff9
GG
84
85
86;--------------------------------------------------------------------
87; Sections
88
f4e463df 89!ifdef INPDIR64
ee38a438 90 Section "64-bit version" X64_SECTION
f4e463df
GI
91 ; Handled in Function CheckX64
92 SectionEnd
93!endif
94
a37e7145 95SectionGroup "!Program files"
4d59bff9 96
f4e463df
GI
97 !macro FileExe path option
98 !ifdef INPDIR64
99 ; Use dummy SetOutPath to control archive location of executables
100 StrCmp $X64 "" +5
101 Goto +2
102 SetOutPath "$INSTDIR\bin64"
103 File ${option} '${INPDIR64}\${path}'
104 GoTo +4
105 Goto +2
106 SetOutPath "$INSTDIR\bin"
107 File ${option} '${INPDIR}\${path}'
108 !else
109 File ${option} '${INPDIR}\${path}'
110 !endif
111 !macroend
112
a37e7145 113 Section "smartctl" SMARTCTL_SECTION
4d59bff9
GG
114
115 SectionIn 1 2
116
117 SetOutPath "$INSTDIR\bin"
f4e463df 118 !insertmacro FileExe "bin\smartctl.exe" ""
4d59bff9
GG
119
120 SectionEnd
121
a37e7145 122 Section "smartd" SMARTD_SECTION
4d59bff9
GG
123
124 SectionIn 1 2
125
126 SetOutPath "$INSTDIR\bin"
a37e7145
GG
127
128 ; Stop service ?
129 StrCpy $1 ""
130 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
131 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
132 StrCmp $0 "" nosrv
133 ExecWait "net stop smartd" $1
134 nosrv:
f4e463df 135 !insertmacro FileExe "bin\smartd.exe" ""
4d59bff9
GG
136
137 IfFileExists "$INSTDIR\bin\smartd.conf" 0 +2
ee38a438 138 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Replace existing configuration file$\n$INSTDIR\bin\smartd.conf ?" /SD IDNO IDYES 0 IDNO +2
4d59bff9
GG
139 File "${INPDIR}\doc\smartd.conf"
140
ee38a438
GI
141 File "${INPDIR}\bin\smartd_warning.cmd"
142 !insertmacro FileExe "bin\wtssendmsg.exe" ""
4d59bff9 143
a37e7145
GG
144 ; Restart service ?
145 StrCmp $1 "0" 0 +3
ee38a438 146 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Restart smartd service ?" /SD IDNO IDYES 0 IDNO +2
a37e7145
GG
147 ExecWait "net start smartd"
148
4d59bff9
GG
149 SectionEnd
150
2127e193
GI
151 Section "smartctl-nc (GSmartControl)" SMARTCTL_NC_SECTION
152
153 SectionIn 1 2
154
155 SetOutPath "$INSTDIR\bin"
f4e463df 156 !insertmacro FileExe "bin\smartctl-nc.exe" ""
2127e193
GI
157
158 SectionEnd
159
cfbba5b9
GI
160 Section "drivedb.h (Drive Database)" DRIVEDB_SECTION
161
162 SectionIn 1 2
163
164 SetOutPath "$INSTDIR\bin"
165 File "${INPDIR}\bin\drivedb.h"
166 File "${INPDIR}\bin\update-smart-drivedb.exe"
167
168 SectionEnd
169
4d59bff9
GG
170SectionGroupEnd
171
a37e7145 172Section "!Documentation" DOC_SECTION
4d59bff9
GG
173
174 SectionIn 1 2
175
176 SetOutPath "$INSTDIR\doc"
177 File "${INPDIR}\doc\AUTHORS.txt"
ee38a438
GI
178 File "${INPDIR}\doc\ChangeLog.txt"
179 File "${INPDIR}\doc\ChangeLog-5.0-6.0.txt"
4d59bff9
GG
180 File "${INPDIR}\doc\COPYING.txt"
181 File "${INPDIR}\doc\INSTALL.txt"
182 File "${INPDIR}\doc\NEWS.txt"
183 File "${INPDIR}\doc\README.txt"
184 File "${INPDIR}\doc\TODO.txt"
185 File "${INPDIR}\doc\WARNINGS.txt"
f4e463df
GI
186!ifdef INPDIR64
187 StrCmp $X64 "" +3
188 File "${INPDIR64}\doc\checksums64.txt"
189 GoTo +2
190 File "${INPDIR}\doc\checksums32.txt"
191!else
192 File "${INPDIR}\doc\checksums??.txt"
193!endif
4d59bff9
GG
194 File "${INPDIR}\doc\smartctl.8.html"
195 File "${INPDIR}\doc\smartctl.8.txt"
196 File "${INPDIR}\doc\smartd.8.html"
197 File "${INPDIR}\doc\smartd.8.txt"
198 File "${INPDIR}\doc\smartd.conf"
199 File "${INPDIR}\doc\smartd.conf.5.html"
200 File "${INPDIR}\doc\smartd.conf.5.txt"
201
202SectionEnd
203
a37e7145 204Section "Uninstaller" UNINST_SECTION
4d59bff9
GG
205
206 SectionIn 1
f4e463df 207 AddSize 40
4d59bff9
GG
208
209 CreateDirectory "$INSTDIR"
210
d2e702cf
GI
211 ; Keep old Install_Dir registry entry for GSmartControl
212 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GSmartControl" "InstallLocation"
213 ReadRegStr $1 HKLM "Software\smartmontools" "Install_Dir"
214 StrCmp "$0$1" "" +2 0
215 WriteRegStr HKLM "Software\smartmontools" "Install_Dir" "$INSTDIR"
4d59bff9
GG
216
217 ; Write uninstall keys and program
218 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayName" "smartmontools"
2127e193
GI
219!ifdef VERSTR
220 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayVersion" "${VERSTR}"
221!endif
d2e702cf 222 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "InstallLocation" "$INSTDIR"
4d59bff9 223 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "UninstallString" '"$INSTDIR\uninst-smartmontools.exe"'
d2e702cf
GI
224 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "Publisher" "smartmontools.org"
225 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLInfoAbout" "http://www.smartmontools.org/"
226 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "HelpLink" "http://sourceforge.net/projects/smartmontools/support"
227 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://smartmontools.no-ip.org/"
4d59bff9
GG
228 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoModify" 1
229 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoRepair" 1
230 WriteUninstaller "uninst-smartmontools.exe"
231
232SectionEnd
233
a37e7145 234Section "Start Menu Shortcuts" MENU_SECTION
4d59bff9
GG
235
236 SectionIn 1
237
a7e8ffec
GI
238 SetShellVarContext all
239
4d59bff9
GG
240 CreateDirectory "$SMPROGRAMS\smartmontools"
241
d008864d
GI
242 !macro CreateAdminShortCut link target args
243 CreateShortCut '${link}' '${target}' '${args}'
244 push '${link}'
245 Call ShellLinkSetRunAs
246 !macroend
247
248 ; runcmdu
249 IfFileExists "$INSTDIR\bin\smartctl.exe" 0 +2
f4e463df 250 IfFileExists "$INSTDIR\bin\smartd.exe" 0 noruncmd
d008864d 251 SetOutPath "$INSTDIR\bin"
f4e463df 252 !insertmacro FileExe "bin\runcmdu.exe" ""
d008864d 253 File "${INPDIR}\bin\runcmdu.exe.manifest"
f4e463df 254 noruncmd:
d008864d 255
4d59bff9
GG
256 ; smartctl
257 IfFileExists "$INSTDIR\bin\smartctl.exe" 0 noctl
258 SetOutPath "$INSTDIR\bin"
ee38a438 259 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl (Admin CMD).lnk" "$WINDIR\system32\cmd.exe" '/k PATH=$INSTDIR\bin;%PATH%&cd /d "$INSTDIR\bin"'
4d59bff9
GG
260 CreateDirectory "$SMPROGRAMS\smartmontools\smartctl Examples"
261 FileOpen $0 "$SMPROGRAMS\smartmontools\smartctl Examples\!Read this first!.txt" "w"
a37e7145 262 FileWrite $0 "All the example commands in this directory$\r$\napply to the first drive (sda).$\r$\n"
4d59bff9 263 FileClose $0
ee38a438 264 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\All info (-x).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -x sda"
d008864d 265 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Identify drive (-i).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -i sda"
ee38a438 266 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART attributes (-A -f brief).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -A -f brief sda"
d008864d
GI
267 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART capabilities (-c).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -c sda"
268 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART health status (-H).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -H sda"
269 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART error log (-l error).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -l error sda"
270 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART selftest log (-l selftest).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -l selftest sda"
271 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start long selftest (-t long).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -t long sda"
272 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start offline test (-t offline).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -t offline sda"
273 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start short selftest (-t short).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -t short sda"
274 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Stop(Abort) selftest (-X).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -X sda"
275 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART off (-s off).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -s off sda"
276 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART on (-s on).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -s on sda"
4d59bff9
GG
277 noctl:
278
279 ; smartd
280 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nod
281 SetOutPath "$INSTDIR\bin"
4d59bff9 282 CreateDirectory "$SMPROGRAMS\smartmontools\smartd Examples"
d008864d
GI
283 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, smartd.log.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd -l local0"
284 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, eventlog.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd"
285 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon stop.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd stop"
286 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Do all tests once (-q onecheck).lnk" "$INSTDIR\bin\runcmdu.exe" "smartd -q onecheck"
287 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Debug mode (-d).lnk" "$INSTDIR\bin\runcmdu.exe" "smartd -d"
288 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\smartd.conf (edit).lnk" "$EDITOR" "$INSTDIR\bin\smartd.conf"
289 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\smartd.conf (view).lnk" "$EDITOR" "$INSTDIR\bin\smartd.conf"
290 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\smartd.log (view).lnk" "$EDITOR" "$INSTDIR\bin\smartd.log"
4d59bff9 291
ee38a438
GI
292 ; smartd service
293 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, eventlog, 30min.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd install"
294 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 10min.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd install -l local0 -i 600"
295 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 30min.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd install -l local0"
296 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service remove.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd remove"
297 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service start.lnk" "$INSTDIR\bin\runcmdu.exe" "net start smartd"
298 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service stop.lnk" "$INSTDIR\bin\runcmdu.exe" "net stop smartd"
4d59bff9
GG
299 nod:
300
301 ; Documentation
302 IfFileExists "$INSTDIR\doc\README.TXT" 0 nodoc
303 SetOutPath "$INSTDIR\doc"
304 CreateDirectory "$SMPROGRAMS\smartmontools\Documentation"
305 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (html).lnk" "$INSTDIR\doc\smartctl.8.html"
306 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (html).lnk" "$INSTDIR\doc\smartd.8.html"
307 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (html).lnk" "$INSTDIR\doc\smartd.conf.5.html"
308 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (txt).lnk" "$INSTDIR\doc\smartctl.8.txt"
309 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (txt).lnk" "$INSTDIR\doc\smartd.8.txt"
310 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (txt).lnk" "$INSTDIR\doc\smartd.conf.5.txt"
d008864d
GI
311 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$EDITOR" "$INSTDIR\doc\smartd.conf"
312 IfFileExists "$INSTDIR\bin\drivedb.h" 0 nodb
313 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb.h (view).lnk" "$EDITOR" "$INSTDIR\bin\drivedb.h"
314 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb-add.h (create, edit).lnk" "$EDITOR" "$INSTDIR\bin\drivedb-add.h"
315 nodb:
ee38a438 316 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\ChangeLog.lnk" "$INSTDIR\doc\ChangeLog.txt"
4d59bff9 317 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\COPYING.lnk" "$INSTDIR\doc\COPYING.txt"
4d59bff9 318 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\NEWS.lnk" "$INSTDIR\doc\NEWS.txt"
d2e702cf 319 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\Windows version download page.lnk" "http://smartmontools.no-ip.org/"
4d59bff9
GG
320 nodoc:
321
322 ; Homepage
d2e702cf 323 CreateShortCut "$SMPROGRAMS\smartmontools\smartmontools Home Page.lnk" "http://www.smartmontools.org/"
4d59bff9 324
cfbba5b9 325 ; drivedb.h update
d008864d
GI
326 IfFileExists "$INSTDIR\bin\update-smart-drivedb.exe" 0 noupdb
327 SetOutPath "$INSTDIR\bin"
328 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\drivedb.h update.lnk" "$INSTDIR\bin\update-smart-drivedb.exe" ""
329 noupdb:
cfbba5b9 330
4d59bff9 331 ; Uninstall
d008864d
GI
332 IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 noinst
333 SetOutPath "$INSTDIR"
334 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe" ""
335 noinst:
4d59bff9
GG
336
337SectionEnd
338
a37e7145 339Section "Add install dir to PATH" PATH_SECTION
4d59bff9
GG
340
341 SectionIn 1
342
ee38a438
GI
343 Push "$INSTDIR\bin"
344 Call AddToPath
4d59bff9
GG
345
346SectionEnd
347
a37e7145
GG
348SectionGroup "Add smartctl to drive menu"
349
350!macro DriveMenuRemove
351 DetailPrint "Remove drive menu entries"
352 DeleteRegKey HKCR "Drive\shell\smartctl0"
353 DeleteRegKey HKCR "Drive\shell\smartctl1"
354 DeleteRegKey HKCR "Drive\shell\smartctl2"
355 DeleteRegKey HKCR "Drive\shell\smartctl3"
356 DeleteRegKey HKCR "Drive\shell\smartctl4"
357 DeleteRegKey HKCR "Drive\shell\smartctl5"
358!macroend
359
a7e8ffec 360 Section "Remove existing entries first" DRIVE_REMOVE_SECTION
a37e7145
GG
361 SectionIn 3
362 !insertmacro DriveMenuRemove
363 SectionEnd
364
365!macro DriveSection id name args
366 Section 'smartctl ${args} ...' DRIVE_${id}_SECTION
367 SectionIn 3
d008864d 368 Call CheckRunCmdA
a37e7145
GG
369 DetailPrint 'Add drive menu entry "${name}": smartctl ${args} ...'
370 WriteRegStr HKCR "Drive\shell\smartctl${id}" "" "${name}"
d008864d 371 WriteRegStr HKCR "Drive\shell\smartctl${id}\command" "" '"$INSTDIR\bin\runcmda.exe" "$INSTDIR\bin\smartctl.exe" ${args} %L'
a37e7145
GG
372 SectionEnd
373!macroend
374
ee38a438 375 !insertmacro DriveSection 0 "SMART all info" "-x"
a37e7145 376 !insertmacro DriveSection 1 "SMART status" "-Hc"
ee38a438 377 !insertmacro DriveSection 2 "SMART attributes" "-A -f brief"
a37e7145
GG
378 !insertmacro DriveSection 3 "SMART short selftest" "-t short"
379 !insertmacro DriveSection 4 "SMART long selftest" "-t long"
380 !insertmacro DriveSection 5 "SMART continue selective selftest" '-t "selective,cont"'
381
382SectionGroupEnd
383
4d59bff9
GG
384;--------------------------------------------------------------------
385
386Section "Uninstall"
387
a37e7145
GG
388 ; Stop & remove service
389 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
390 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
391 StrCmp $0 "" nosrv
392 ExecWait "net stop smartd"
ee38a438 393 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Remove smartd service ?" /SD IDNO IDYES 0 IDNO nosrv
a37e7145
GG
394 ExecWait "$INSTDIR\bin\smartd.exe remove"
395 nosrv:
396
397 ; Remove installer registry keys
4d59bff9
GG
398 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools"
399 DeleteRegKey HKLM "Software\smartmontools"
400
cfbba5b9 401 ; Remove conf file ?
4d59bff9
GG
402 IfFileExists "$INSTDIR\bin\smartd.conf" 0 noconf
403 ; Assume unchanged if timestamp is equal to sample file
404 GetFileTime "$INSTDIR\bin\smartd.conf" $0 $1
405 GetFileTime "$INSTDIR\doc\smartd.conf" $2 $3
406 StrCmp "$0:$1" "$2:$3" +2 0
ee38a438 407 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete configuration file$\n$INSTDIR\bin\smartd.conf ?" /SD IDNO IDYES 0 IDNO noconf
4d59bff9
GG
408 Delete "$INSTDIR\bin\smartd.conf"
409 noconf:
410
cfbba5b9 411 ; Remove log file ?
4d59bff9 412 IfFileExists "$INSTDIR\bin\smartd.log" 0 +3
ee38a438 413 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete log file$\n$INSTDIR\bin\smartd.log ?" /SD IDNO IDYES 0 IDNO +2
4d59bff9
GG
414 Delete "$INSTDIR\bin\smartd.log"
415
cfbba5b9
GI
416 ; Remove drivedb-add file ?
417 IfFileExists "$INSTDIR\bin\drivedb-add.h" 0 +3
ee38a438 418 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete local drive database file$\n$INSTDIR\bin\drivedb-add.h ?" /SD IDNO IDYES 0 IDNO +2
cfbba5b9
GI
419 Delete "$INSTDIR\bin\drivedb-add.h"
420
4d59bff9
GG
421 ; Remove files
422 Delete "$INSTDIR\bin\smartctl.exe"
2127e193 423 Delete "$INSTDIR\bin\smartctl-nc.exe"
4d59bff9 424 Delete "$INSTDIR\bin\smartd.exe"
ee38a438 425 Delete "$INSTDIR\bin\smartd_warning.cmd" ; TODO: Check for modifications?
cfbba5b9
GI
426 Delete "$INSTDIR\bin\drivedb.h"
427 Delete "$INSTDIR\bin\drivedb.h.error"
428 Delete "$INSTDIR\bin\drivedb.h.lastcheck"
429 Delete "$INSTDIR\bin\drivedb.h.old"
430 Delete "$INSTDIR\bin\update-smart-drivedb.exe"
4d59bff9
GG
431 Delete "$INSTDIR\bin\smartctl-run.bat"
432 Delete "$INSTDIR\bin\smartd-run.bat"
433 Delete "$INSTDIR\bin\net-run.bat"
d008864d
GI
434 Delete "$INSTDIR\bin\runcmda.exe"
435 Delete "$INSTDIR\bin\runcmda.exe.manifest"
436 Delete "$INSTDIR\bin\runcmdu.exe"
437 Delete "$INSTDIR\bin\runcmdu.exe.manifest"
ee38a438 438 Delete "$INSTDIR\bin\wtssendmsg.exe"
4d59bff9 439 Delete "$INSTDIR\doc\AUTHORS.txt"
ee38a438
GI
440 Delete "$INSTDIR\doc\ChangeLog.txt"
441 Delete "$INSTDIR\doc\ChangeLog-5.0-6.0.txt"
4d59bff9
GG
442 Delete "$INSTDIR\doc\COPYING.txt"
443 Delete "$INSTDIR\doc\INSTALL.txt"
444 Delete "$INSTDIR\doc\NEWS.txt"
445 Delete "$INSTDIR\doc\README.txt"
446 Delete "$INSTDIR\doc\TODO.txt"
447 Delete "$INSTDIR\doc\WARNINGS.txt"
f4e463df 448 Delete "$INSTDIR\doc\checksums*.txt"
4d59bff9
GG
449 Delete "$INSTDIR\doc\smartctl.8.html"
450 Delete "$INSTDIR\doc\smartctl.8.txt"
451 Delete "$INSTDIR\doc\smartd.8.html"
452 Delete "$INSTDIR\doc\smartd.8.txt"
453 Delete "$INSTDIR\doc\smartd.conf"
454 Delete "$INSTDIR\doc\smartd.conf.5.html"
455 Delete "$INSTDIR\doc\smartd.conf.5.txt"
456 Delete "$INSTDIR\uninst-smartmontools.exe"
457
458 ; Remove shortcuts
a7e8ffec 459 SetShellVarContext all
4d59bff9
GG
460 Delete "$SMPROGRAMS\smartmontools\*.*"
461 Delete "$SMPROGRAMS\smartmontools\Documentation\*.*"
462 Delete "$SMPROGRAMS\smartmontools\smartctl Examples\*.*"
463 Delete "$SMPROGRAMS\smartmontools\smartd Examples\*.*"
464
465 ; Remove folders
466 RMDir "$SMPROGRAMS\smartmontools\Documentation"
a37e7145
GG
467 RMDir "$SMPROGRAMS\smartmontools\smartctl Examples"
468 RMDir "$SMPROGRAMS\smartmontools\smartd Examples"
4d59bff9
GG
469 RMDir "$SMPROGRAMS\smartmontools"
470 RMDir "$INSTDIR\bin"
471 RMDir "$INSTDIR\doc"
472 RMDir "$INSTDIR"
473
474 ; Remove install dir from PATH
ee38a438
GI
475 Push "$INSTDIR\bin"
476 Call un.RemoveFromPath
4d59bff9 477
a37e7145
GG
478 ; Remove drive menu registry entries
479 !insertmacro DriveMenuRemove
480
481 ; Check for still existing entries
4d59bff9 482 IfFileExists "$INSTDIR\bin\smartd.exe" 0 +3
ee38a438 483 MessageBox MB_OK|MB_ICONEXCLAMATION "$INSTDIR\bin\smartd.exe could not be removed.$\nsmartd is possibly still running." /SD IDOK
4d59bff9
GG
484 Goto +3
485 IfFileExists "$INSTDIR" 0 +2
ee38a438 486 MessageBox MB_OK "Note: $INSTDIR could not be removed." /SD IDOK
4d59bff9 487
a37e7145 488 IfFileExists "$SMPROGRAMS\smartmontools" 0 +2
ee38a438 489 MessageBox MB_OK "Note: $SMPROGRAMS\smartmontools could not be removed." /SD IDOK
a37e7145 490
4d59bff9
GG
491SectionEnd
492
493;--------------------------------------------------------------------
a37e7145 494; Functions
4d59bff9 495
f4e463df
GI
496!macro AdjustSectionSize section
497 SectionGetSize ${section} $0
498 IntOp $0 $0 / 2
499 SectionSetSize ${section} $0
500!macroend
501
4d59bff9
GG
502Function .onInit
503
f4e463df
GI
504 ; Set default install directories
505 StrCmp $INSTDIR "" 0 endinst ; /D=PATH option specified ?
d2e702cf
GI
506 ReadRegStr $INSTDIR HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "InstallLocation"
507 StrCmp $INSTDIR "" 0 endinst ; Already installed ?
f4e463df
GI
508 ReadRegStr $INSTDIR HKLM "Software\smartmontools" "Install_Dir"
509 StrCmp $INSTDIR "" 0 endinst ; Already installed ?
510 StrCpy $INSTDIR "$PROGRAMFILES\smartmontools"
511!ifdef INPDIR64
512 StrCpy $INSTDIR32 $INSTDIR
513 StrCpy $INSTDIR64 "$PROGRAMFILES64\smartmontools"
514!endif
515 endinst:
516
517!ifdef INPDIR64
518 ; Sizes of binary sections include 32-bit and 64-bit executables
519 !insertmacro AdjustSectionSize ${SMARTCTL_SECTION}
520 !insertmacro AdjustSectionSize ${SMARTD_SECTION}
521 !insertmacro AdjustSectionSize ${SMARTCTL_NC_SECTION}
522!endif
523
d008864d
GI
524 ; Use Notepad++ if installed
525 StrCpy $EDITOR "$PROGRAMFILES\Notepad++\notepad++.exe"
526 IfFileExists "$EDITOR" +2 0
527 StrCpy $EDITOR "notepad.exe"
528
a7e8ffec
GI
529 Call ParseCmdLine
530FunctionEnd
531
f4e463df
GI
532; Check x64 section and update INSTDIR accordingly
533
534!ifdef INPDIR64
535Function CheckX64
536 SectionGetFlags ${X64_SECTION} $0
537 IntOp $0 $0 & ${SF_SELECTED}
538 IntCmp $0 ${SF_SELECTED} x64
539 StrCpy $X64 ""
540 StrCmp $INSTDIR32 "" +3
541 StrCpy $INSTDIR $INSTDIR32
542 StrCpy $INSTDIR32 ""
543 Goto done
544 x64:
545 StrCpy $X64 "t"
546 StrCmp $INSTDIR64 "" +3
547 StrCpy $INSTDIR $INSTDIR64
548 StrCpy $INSTDIR64 ""
549 done:
550FunctionEnd
551!endif
552
a7e8ffec
GI
553; Command line parsing
554!macro CheckCmdLineOption name section
555 StrCpy $allopts "$allopts,${name}"
556 Push ",$opts,"
557 Push ",${name},"
558 Call StrStr
559 Pop $0
560 StrCmp $0 "" 0 sel_${name}
561 !insertmacro UnselectSection ${section}
562 Goto done_${name}
563sel_${name}:
564 !insertmacro SelectSection ${section}
565 StrCpy $nomatch ""
566done_${name}:
567!macroend
568
569Function ParseCmdLine
570 ; get /SO option
571 Var /global opts
572 ${GetParameters} $R0
573 ${GetOptions} $R0 "/SO" $opts
574 IfErrors 0 +2
575 Return
576 Var /global allopts
577 StrCpy $allopts ""
578 Var /global nomatch
579 StrCpy $nomatch "t"
580 ; turn sections on or off
f4e463df
GI
581!ifdef INPDIR64
582 !insertmacro CheckCmdLineOption "x64" ${X64_SECTION}
583 Call CheckX64
584 StrCmp $opts "x64" 0 +2
585 Return ; leave sections unchanged if only "x64" is specified
586!endif
a7e8ffec
GI
587 !insertmacro CheckCmdLineOption "smartctl" ${SMARTCTL_SECTION}
588 !insertmacro CheckCmdLineOption "smartd" ${SMARTD_SECTION}
589 !insertmacro CheckCmdLineOption "smartctlnc" ${SMARTCTL_NC_SECTION}
590 !insertmacro CheckCmdLineOption "drivedb" ${DRIVEDB_SECTION}
591 !insertmacro CheckCmdLineOption "doc" ${DOC_SECTION}
592 !insertmacro CheckCmdLineOption "uninst" ${UNINST_SECTION}
593 !insertmacro CheckCmdLineOption "menu" ${MENU_SECTION}
594 !insertmacro CheckCmdLineOption "path" ${PATH_SECTION}
595 !insertmacro CheckCmdLineOption "driveremove" ${DRIVE_REMOVE_SECTION}
596 !insertmacro CheckCmdLineOption "drive0" ${DRIVE_0_SECTION}
597 !insertmacro CheckCmdLineOption "drive1" ${DRIVE_1_SECTION}
598 !insertmacro CheckCmdLineOption "drive2" ${DRIVE_2_SECTION}
599 !insertmacro CheckCmdLineOption "drive3" ${DRIVE_3_SECTION}
600 !insertmacro CheckCmdLineOption "drive4" ${DRIVE_4_SECTION}
601 !insertmacro CheckCmdLineOption "drive5" ${DRIVE_5_SECTION}
a7e8ffec
GI
602 StrCmp $opts "-" done
603 StrCmp $nomatch "" done
604 StrCpy $0 "$allopts,-" "" 1
605 MessageBox MB_OK "Usage: smartmontools-VERSION.win32-setup [/S] [/SO component,...] [/D=INSTDIR]$\n$\ncomponents:$\n $0"
606 Abort
607done:
4d59bff9
GG
608FunctionEnd
609
d008864d 610; Install runcmda.exe if missing
cfbba5b9 611
d008864d
GI
612Function CheckRunCmdA
613 IfFileExists "$INSTDIR\bin\runcmda.exe" done 0
cfbba5b9 614 SetOutPath "$INSTDIR\bin"
f4e463df 615 !insertmacro FileExe "bin\runcmda.exe" ""
d008864d 616 File "${INPDIR}\bin\runcmda.exe.manifest"
cfbba5b9
GI
617 done:
618FunctionEnd
619
4d59bff9
GG
620
621;--------------------------------------------------------------------
a37e7145 622; Path functions
4d59bff9
GG
623;
624; Based on example from:
625; http://nsis.sourceforge.net/Path_Manipulation
626;
627
628
629!include "WinMessages.nsh"
630
631; Registry Entry for environment (NT4,2000,XP)
632; All users:
633;!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
634; Current user only:
635!define Environ 'HKCU "Environment"'
636
637
638; AddToPath - Appends dir to PATH
639; (does not work on Win9x/ME)
640;
641; Usage:
642; Push "dir"
643; Call AddToPath
644
645Function AddToPath
646 Exch $0
647 Push $1
648 Push $2
649 Push $3
a37e7145 650
4d59bff9
GG
651 ReadRegStr $1 ${Environ} "PATH"
652 Push "$1;"
653 Push "$0;"
654 Call StrStr
655 Pop $2
a37e7145 656 StrCmp $2 "" 0 done
4d59bff9
GG
657 Push "$1;"
658 Push "$0\;"
659 Call StrStr
660 Pop $2
a37e7145
GG
661 StrCmp $2 "" 0 done
662
4d59bff9
GG
663 DetailPrint "Add to PATH: $0"
664 StrCpy $2 $1 1 -1
665 StrCmp $2 ";" 0 +2
666 StrCpy $1 $1 -1 ; remove trailing ';'
667 StrCmp $1 "" +2 ; no leading ';'
668 StrCpy $0 "$1;$0"
669 WriteRegExpandStr ${Environ} "PATH" $0
670 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
a37e7145 671
4d59bff9
GG
672done:
673 Pop $3
674 Pop $2
675 Pop $1
676 Pop $0
677FunctionEnd
678
679
680; RemoveFromPath - Removes dir from PATH
681;
682; Usage:
683; Push "dir"
684; Call RemoveFromPath
a37e7145 685
4d59bff9
GG
686Function un.RemoveFromPath
687 Exch $0
688 Push $1
689 Push $2
690 Push $3
691 Push $4
692 Push $5
693 Push $6
a37e7145 694
4d59bff9
GG
695 ReadRegStr $1 ${Environ} "PATH"
696 StrCpy $5 $1 1 -1
697 StrCmp $5 ";" +2
698 StrCpy $1 "$1;" ; ensure trailing ';'
699 Push $1
700 Push "$0;"
701 Call un.StrStr
702 Pop $2 ; pos of our dir
703 StrCmp $2 "" done
704
705 DetailPrint "Remove from PATH: $0"
706 StrLen $3 "$0;"
707 StrLen $4 $2
708 StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove
709 StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
710 StrCpy $3 "$5$6"
711 StrCpy $5 $3 1 -1
712 StrCmp $5 ";" 0 +2
713 StrCpy $3 $3 -1 ; remove trailing ';'
714 WriteRegExpandStr ${Environ} "PATH" $3
715 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
716
717done:
718 Pop $6
719 Pop $5
720 Pop $4
721 Pop $3
722 Pop $2
723 Pop $1
724 Pop $0
725FunctionEnd
726
727
728; StrStr - find substring in a string
729;
730; Usage:
731; Push "this is some string"
732; Push "some"
733; Call StrStr
734; Pop $0 ; "some string"
a37e7145 735
4d59bff9
GG
736!macro StrStr un
737Function ${un}StrStr
738 Exch $R1 ; $R1=substring, stack=[old$R1,string,...]
739 Exch ; stack=[string,old$R1,...]
740 Exch $R2 ; $R2=string, stack=[old$R2,old$R1,...]
741 Push $R3
742 Push $R4
743 Push $R5
744 StrLen $R3 $R1
745 StrCpy $R4 0
746 ; $R1=substring, $R2=string, $R3=strlen(substring)
747 ; $R4=count, $R5=tmp
748 loop:
749 StrCpy $R5 $R2 $R3 $R4
750 StrCmp $R5 $R1 done
751 StrCmp $R5 "" done
752 IntOp $R4 $R4 + 1
753 Goto loop
754done:
755 StrCpy $R1 $R2 "" $R4
756 Pop $R5
757 Pop $R4
758 Pop $R3
759 Pop $R2
760 Exch $R1 ; $R1=old$R1, stack=[result,...]
761FunctionEnd
762!macroend
763!insertmacro StrStr ""
764!insertmacro StrStr "un."
d008864d
GI
765
766
767;--------------------------------------------------------------------
768; Set Run As Administrator flag in shortcut
769;
770; Slightly modified version from:
771; http://nsis.sourceforge.net/IShellLink_Set_RunAs_flag
772;
773
774!include "LogicLib.nsh"
775
776!define IPersistFile {0000010b-0000-0000-c000-000000000046}
777!define CLSID_ShellLink {00021401-0000-0000-C000-000000000046}
778!define IID_IShellLinkA {000214EE-0000-0000-C000-000000000046}
779!define IID_IShellLinkW {000214F9-0000-0000-C000-000000000046}
780!define IShellLinkDataList {45e2b4ae-b1c3-11d0-b92f-00a0c90312e1}
781!ifdef NSIS_UNICODE
782 !define IID_IShellLink ${IID_IShellLinkW}
783!else
784 !define IID_IShellLink ${IID_IShellLinkA}
785!endif
786
787Function ShellLinkSetRunAs
f4e463df
GI
788 ; Set archive location of $PLUGINSDIR
789 Goto +2
790 SetOutPath "$INSTDIR"
791
d008864d
GI
792 System::Store S ; push $0-$9, $R0-$R9
793 pop $9
794 ; $0 = CoCreateInstance(CLSID_ShellLink, 0, CLSCTX_INPROC_SERVER, IID_IShellLink, &$1)
795 System::Call "ole32::CoCreateInstance(g'${CLSID_ShellLink}',i0,i1,g'${IID_IShellLink}',*i.r1)i.r0"
796 ${If} $0 = 0
797 System::Call "$1->0(g'${IPersistFile}',*i.r2)i.r0" ; $0 = $1->QueryInterface(IPersistFile, &$2)
798 ${If} $0 = 0
799 System::Call "$2->5(w '$9',i 0)i.r0" ; $0 = $2->Load($9, STGM_READ)
800 ${If} $0 = 0
801 System::Call "$1->0(g'${IShellLinkDataList}',*i.r3)i.r0" ; $0 = $1->QueryInterface(IShellLinkDataList, &$3)
802 ${If} $0 = 0
803 System::Call "$3->6(*i.r4)i.r0"; $0 = $3->GetFlags(&$4)
804 ${If} $0 = 0
805 System::Call "$3->7(i $4|0x2000)i.r0" ; $0 = $3->SetFlags($4|SLDF_RUNAS_USER)
806 ${If} $0 = 0
807 System::Call "$2->6(w '$9',i1)i.r0" ; $2->Save($9, TRUE)
808 ${EndIf}
809 ${EndIf}
810 System::Call "$3->2()" ; $3->Release()
811 ${EndIf}
812 System::Call "$2->2()" ; $2->Release()
813 ${EndIf}
814 ${EndIf}
815 System::Call "$1->2()" ; $1->Release()
816 ${EndIf}
817 ${If} $0 <> 0
818 DetailPrint "Set RunAsAdmin: $9 failed ($0)"
819 ${Else}
820 DetailPrint "Set RunAsAdmin: $9"
821 ${EndIf}
822 System::Store L ; push $0-$9, $R0-$R9
823FunctionEnd