2 ; smartmontools install NSIS script
4 ; Home page of code is: http://smartmontools.sourceforge.net
6 ; Copyright (C) 2006-11 Christian Franke <smartmontools-support@lists.sourceforge.net>
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)
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/>.
16 ; $Id: installer.nsi 3298 2011-03-22 18:36:44Z chrfranke $
20 ;--------------------------------------------------------------------
21 ; Command line arguments:
22 ; makensis -DINPDIR=<input-dir> -DOUTFILE=<output-file> -DVERSTR=<version-string> installer.nsi
29 !define OUTFILE "smartmontools.win32-setup.exe"
32 ;--------------------------------------------------------------------
38 SetCompressor /solid lzma
41 InstallColors /windows
43 InstallDir "$PROGRAMFILES\smartmontools"
44 InstallDirRegKey HKLM "Software\smartmontools" "Install_Dir"
47 LicenseData "${INPDIR}\doc\COPYING.txt"
49 !include "FileFunc.nsh"
50 !include "Sections.nsh"
52 !insertmacro GetParameters
53 !insertmacro GetOptions
55 RequestExecutionLevel admin
57 ;--------------------------------------------------------------------
62 Page directory SkipProgPath "" ""
64 PageCallbacks SkipUBCDPath "" ""
65 DirText "Setup will install the UBCD4Win plugin in the following folder."
70 UninstPage uninstConfirm
74 InstType "Extract files only"
76 InstType "UBCD4Win plugin"
79 ;--------------------------------------------------------------------
82 SectionGroup "!Program files"
84 Section "smartctl" SMARTCTL_SECTION
88 SetOutPath "$INSTDIR\bin"
89 File "${INPDIR}\bin\smartctl.exe"
93 Section "smartd" SMARTD_SECTION
97 SetOutPath "$INSTDIR\bin"
101 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
102 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
104 ExecWait "net stop smartd" $1
106 File "${INPDIR}\bin\smartd.exe"
108 IfFileExists "$INSTDIR\bin\smartd.conf" 0 +2
109 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Replace existing configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO +2
110 File "${INPDIR}\doc\smartd.conf"
112 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
113 File /nonfatal "${INPDIR}\bin\syslogevt.exe"
117 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Restart smartd service ?" IDYES 0 IDNO +2
118 ExecWait "net start smartd"
122 Section "smartctl-nc (GSmartControl)" SMARTCTL_NC_SECTION
126 SetOutPath "$INSTDIR\bin"
127 File "${INPDIR}\bin\smartctl-nc.exe"
131 Section "drivedb.h (Drive Database)" DRIVEDB_SECTION
135 SetOutPath "$INSTDIR\bin"
136 File "${INPDIR}\bin\drivedb.h"
137 File "${INPDIR}\bin\update-smart-drivedb.exe"
143 Section "!Documentation" DOC_SECTION
147 SetOutPath "$INSTDIR\doc"
148 File "${INPDIR}\doc\AUTHORS.txt"
149 File "${INPDIR}\doc\CHANGELOG.txt"
150 File "${INPDIR}\doc\COPYING.txt"
151 File "${INPDIR}\doc\INSTALL.txt"
152 File "${INPDIR}\doc\NEWS.txt"
153 File "${INPDIR}\doc\README.txt"
154 File "${INPDIR}\doc\TODO.txt"
155 File "${INPDIR}\doc\WARNINGS.txt"
156 File "${INPDIR}\doc\checksums.txt"
157 File "${INPDIR}\doc\smartctl.8.html"
158 File "${INPDIR}\doc\smartctl.8.txt"
159 File "${INPDIR}\doc\smartd.8.html"
160 File "${INPDIR}\doc\smartd.8.txt"
161 File "${INPDIR}\doc\smartd.conf"
162 File "${INPDIR}\doc\smartd.conf.5.html"
163 File "${INPDIR}\doc\smartd.conf.5.txt"
167 Section "Uninstaller" UNINST_SECTION
172 CreateDirectory "$INSTDIR"
174 ; Save installation location
175 WriteRegStr HKLM "Software\smartmontools" "Install_Dir" "$INSTDIR"
177 ; Write uninstall keys and program
178 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayName" "smartmontools"
180 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayVersion" "${VERSTR}"
182 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "Publisher" "smartmontools"
183 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "UninstallString" '"$INSTDIR\uninst-smartmontools.exe"'
184 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLInfoAbout" "http://smartmontools.sourceforge.net/"
185 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "HelpLink" "http://smartmontools.sourceforge.net/"
186 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://sourceforge.net/project/showfiles.php?group_id=64297"
187 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://smartmontools-win32.dyndns.org/"
188 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoModify" 1
189 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoRepair" 1
190 WriteUninstaller "uninst-smartmontools.exe"
194 Section "Start Menu Shortcuts" MENU_SECTION
198 SetShellVarContext all
200 CreateDirectory "$SMPROGRAMS\smartmontools"
203 IfFileExists "$INSTDIR\bin\smartctl.exe" 0 noctl
204 SetOutPath "$INSTDIR\bin"
205 DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat"
206 Push "$INSTDIR\bin\smartctl-run.bat"
207 Call CreateSmartctlBat
208 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
209 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl (CMD).lnk" "cmd.exe" "/k smartctl-run.bat"
210 CreateDirectory "$SMPROGRAMS\smartmontools\smartctl Examples"
211 FileOpen $0 "$SMPROGRAMS\smartmontools\smartctl Examples\!Read this first!.txt" "w"
212 FileWrite $0 "All the example commands in this directory$\r$\napply to the first drive (sda).$\r$\n"
214 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\All info (-a).lnk" "$INSTDIR\bin\smartctl-run.bat" "-a sda"
215 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Identify drive (-i).lnk" "$INSTDIR\bin\smartctl-run.bat" "-i sda"
216 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART attributes (-A).lnk" "$INSTDIR\bin\smartctl-run.bat" "-A sda"
217 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART capabilities (-c).lnk" "$INSTDIR\bin\smartctl-run.bat" "-c sda"
218 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART health status (-H).lnk" "$INSTDIR\bin\smartctl-run.bat" "-H sda"
219 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART error log (-l error).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l error sda"
220 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART selftest log (-l selftest).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l selftest sda"
221 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start long selftest (-t long).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t long sda"
222 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start offline test (-t offline).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t offline sda"
223 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start short selftest (-t short).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t short sda"
224 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Stop(Abort) selftest (-X).lnk" "$INSTDIR\bin\smartctl-run.bat" "-X sda"
225 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART off (-s off).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s off sda"
226 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART on (-s on).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s on sda"
230 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nod
231 SetOutPath "$INSTDIR\bin"
232 DetailPrint "Create file: $INSTDIR\bin\smartd-run.bat"
233 FileOpen $0 "$INSTDIR\bin\smartd-run.bat" "w"
234 FileWrite $0 '@echo off$\r$\necho smartd %1 %2 %3 %4 %5$\r$\n"$INSTDIR\bin\smartd" %1 %2 %3 %4 %5$\r$\npause$\r$\n'
236 CreateDirectory "$SMPROGRAMS\smartmontools\smartd Examples"
237 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, smartd.log.lnk" "$INSTDIR\bin\smartd-run.bat" "-l local0"
238 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
239 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, eventlog.lnk" "$INSTDIR\bin\smartd-run.bat" ""
240 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon stop.lnk" "$INSTDIR\bin\smartd-run.bat" "stop"
241 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Do all tests once (-q onecheck).lnk" "$INSTDIR\bin\smartd-run.bat" "-q onecheck"
242 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Debug mode (-d).lnk" "$INSTDIR\bin\smartd-run.bat" "-d"
243 IfFileExists "$WINDIR\notepad.exe" 0 nopad
244 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Edit smartd.conf.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.conf"
245 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\View smartd.log.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.log"
248 ; smartd service (not on 9x/ME)
249 IfFileExists "$WINDIR\system32\cmd.exe" 0 nosvc
250 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, eventlog, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install"
251 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 10min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0 -i 600"
252 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0"
253 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service remove.lnk" "$INSTDIR\bin\smartd-run.bat" "remove"
254 DetailPrint "Create file: $INSTDIR\bin\net-run.bat"
255 FileOpen $0 "$INSTDIR\bin\net-run.bat" "w"
256 FileWrite $0 "@echo off$\r$\necho net %1 %2 %3 %4 %5$\r$\nnet %1 %2 %3 %4 %5$\r$\npause$\r$\n"
258 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service start.lnk" "$INSTDIR\bin\net-run.bat" "start smartd"
259 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service stop.lnk" "$INSTDIR\bin\net-run.bat" "stop smartd"
264 IfFileExists "$INSTDIR\doc\README.TXT" 0 nodoc
265 SetOutPath "$INSTDIR\doc"
266 CreateDirectory "$SMPROGRAMS\smartmontools\Documentation"
267 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (html).lnk" "$INSTDIR\doc\smartctl.8.html"
268 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (html).lnk" "$INSTDIR\doc\smartd.8.html"
269 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (html).lnk" "$INSTDIR\doc\smartd.conf.5.html"
270 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (txt).lnk" "$INSTDIR\doc\smartctl.8.txt"
271 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (txt).lnk" "$INSTDIR\doc\smartd.8.txt"
272 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (txt).lnk" "$INSTDIR\doc\smartd.conf.5.txt"
273 IfFileExists "$WINDIR\notepad.exe" 0 +5
274 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$WINDIR\notepad.exe" "$INSTDIR\doc\smartd.conf"
275 IfFileExists "$INSTDIR\bin\drivedb.h" 0 +3
276 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb.h (view).lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\drivedb.h"
277 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb-add.h (create, edit).lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\drivedb-add.h"
278 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\AUTHORS.lnk" "$INSTDIR\doc\AUTHORS.txt"
279 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\CHANGELOG.lnk" "$INSTDIR\doc\CHANGELOG.txt"
280 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\COPYING.lnk" "$INSTDIR\doc\COPYING.txt"
281 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\INSTALL.lnk" "$INSTDIR\doc\INSTALL.txt"
282 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\NEWS.lnk" "$INSTDIR\doc\NEWS.txt"
283 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\README.lnk" "$INSTDIR\doc\README.txt"
284 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\TODO.lnk" "$INSTDIR\doc\TODO.txt"
285 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\WARNINGS.lnk" "$INSTDIR\doc\WARNINGS.txt"
286 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\Windows version download page.lnk" "http://smartmontools-win32.dyndns.org/smartmontools/"
290 CreateShortCut "$SMPROGRAMS\smartmontools\smartmontools Home Page.lnk" "http://smartmontools.sourceforge.net/"
293 IfFileExists "$INSTDIR\bin\update-smart-drivedb.exe" 0 +2
294 CreateShortCut "$SMPROGRAMS\smartmontools\drivedb.h update.lnk" "$INSTDIR\bin\update-smart-drivedb.exe"
297 IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 +2
298 CreateShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe"
302 Section "Add install dir to PATH" PATH_SECTION
306 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
312 SectionGroup "Add smartctl to drive menu"
314 !macro DriveMenuRemove
315 DetailPrint "Remove drive menu entries"
316 DeleteRegKey HKCR "Drive\shell\smartctl0"
317 DeleteRegKey HKCR "Drive\shell\smartctl1"
318 DeleteRegKey HKCR "Drive\shell\smartctl2"
319 DeleteRegKey HKCR "Drive\shell\smartctl3"
320 DeleteRegKey HKCR "Drive\shell\smartctl4"
321 DeleteRegKey HKCR "Drive\shell\smartctl5"
324 Section "Remove existing entries first" DRIVE_REMOVE_SECTION
326 !insertmacro DriveMenuRemove
329 !macro DriveSection id name args
330 Section 'smartctl ${args} ...' DRIVE_${id}_SECTION
332 Call CheckSmartctlBat
333 DetailPrint 'Add drive menu entry "${name}": smartctl ${args} ...'
334 WriteRegStr HKCR "Drive\shell\smartctl${id}" "" "${name}"
335 WriteRegStr HKCR "Drive\shell\smartctl${id}\command" "" '"$INSTDIR\bin\smartctl-run.bat" ${args} %L'
339 !insertmacro DriveSection 0 "SMART all info" "-a"
340 !insertmacro DriveSection 1 "SMART status" "-Hc"
341 !insertmacro DriveSection 2 "SMART attributes" "-A"
342 !insertmacro DriveSection 3 "SMART short selftest" "-t short"
343 !insertmacro DriveSection 4 "SMART long selftest" "-t long"
344 !insertmacro DriveSection 5 "SMART continue selective selftest" '-t "selective,cont"'
348 Section "UBCD4Win Plugin" UBCD_SECTION
352 SetOutPath "$UBCDDIR"
353 DetailPrint "Create file: smartmontools.inf"
354 FileOpen $0 "$UBCDDIR\smartmontools.inf" "w"
355 FileWrite $0 '; smartmontools.inf$\r$\n; PE Builder v3 plug-in INF file$\r$\n'
356 FileWrite $0 '; Created by smartmontools installer$\r$\n'
357 FileWrite $0 '; http://smartmontools.sourceforge.net/$\r$\n$\r$\n'
358 FileWrite $0 '[Version]$\r$\nSignature= "$$Windows NT$$"$\r$\n$\r$\n'
359 FileWrite $0 '[PEBuilder]$\r$\nName="Disk -Diagnostic: smartmontools"$\r$\n'
360 FileWrite $0 'Enable=1$\r$\nHelp="files\smartctl.8.html"$\r$\n$\r$\n'
361 FileWrite $0 '[WinntDirectories]$\r$\na=Programs\smartmontools,2$\r$\n$\r$\n'
362 FileWrite $0 '[SourceDisksFolders]$\r$\nfiles=a,,1$\r$\n$\r$\n'
363 FileWrite $0 '[Append]$\r$\nnu2menu.xml, smartmontools_nu2menu.xml$\r$\n'
366 DetailPrint "Create file: smartmontools_nu2menu.xml"
367 FileOpen $0 "$UBCDDIR\smartmontools_nu2menu.xml" "w"
368 FileWrite $0 '<!-- Nu2Menu entry for smartmontools -->$\r$\n<NU2MENU>$\r$\n'
369 FileWrite $0 '$\t<MENU ID="Programs">$\r$\n$\t$\t<MITEM TYPE="POPUP" MENUID="Disk Tools">'
370 FileWrite $0 'Disk Tools</MITEM>$\r$\n$\t</MENU>$\r$\n$\t<MENU ID="Disk Tools">$\r$\n'
371 FileWrite $0 '$\t$\t<MITEM TYPE="POPUP" MENUID="Diagnostic">Diagnostic</MITEM>$\r$\n$\t</MENU>'
372 FileWrite $0 '$\r$\n$\t<MENU ID="Diagnostic">$\r$\n$\t$\t<MITEM TYPE="ITEM" DISABLED="'
373 FileWrite $0 '@Not(@FileExists(@GetProgramDrive()\Programs\smartmontools\smartctl.exe))" '
374 FileWrite $0 'CMD="RUN" FUNC="cmd.exe /k cd /d @GetProgramDrive()\Programs\smartmontools&'
375 FileWrite $0 'set PATH=@GetProgramDrive()\Programs\smartmontools;%PATH%&smartctl-run.bat ">'
376 FileWrite $0 'smartctl</MITEM>$\r$\n$\t</MENU>$\r$\n</NU2MENU>$\r$\n'
379 SetOutPath "$UBCDDIR\files"
380 DetailPrint "Create file: smartctl-run.bat"
381 Push "$UBCDDIR\files\smartctl-run.bat"
382 Call CreateSmartctlBat
383 File "${INPDIR}\bin\smartctl.exe"
384 File "${INPDIR}\bin\smartd.exe"
385 File "${INPDIR}\doc\smartctl.8.html"
386 File "${INPDIR}\doc\smartctl.8.txt"
387 File "${INPDIR}\doc\smartd.8.html"
388 File "${INPDIR}\doc\smartd.8.txt"
389 File "${INPDIR}\doc\smartd.conf"
394 ;--------------------------------------------------------------------
398 ; Stop & remove service
399 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
400 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
402 ExecWait "net stop smartd"
403 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Remove smartd service ?" IDYES 0 IDNO nosrv
404 ExecWait "$INSTDIR\bin\smartd.exe remove"
407 ; Remove installer registry keys
408 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools"
409 DeleteRegKey HKLM "Software\smartmontools"
412 IfFileExists "$INSTDIR\bin\smartd.conf" 0 noconf
413 ; Assume unchanged if timestamp is equal to sample file
414 GetFileTime "$INSTDIR\bin\smartd.conf" $0 $1
415 GetFileTime "$INSTDIR\doc\smartd.conf" $2 $3
416 StrCmp "$0:$1" "$2:$3" +2 0
417 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO noconf
418 Delete "$INSTDIR\bin\smartd.conf"
422 IfFileExists "$INSTDIR\bin\smartd.log" 0 +3
423 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete log file$\n$INSTDIR\bin\smartd.log ?" IDYES 0 IDNO +2
424 Delete "$INSTDIR\bin\smartd.log"
426 ; Remove drivedb-add file ?
427 IfFileExists "$INSTDIR\bin\drivedb-add.h" 0 +3
428 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete local drive database file$\n$INSTDIR\bin\drivedb-add.h ?" IDYES 0 IDNO +2
429 Delete "$INSTDIR\bin\drivedb-add.h"
432 Delete "$INSTDIR\bin\smartctl.exe"
433 Delete "$INSTDIR\bin\smartctl-nc.exe"
434 Delete "$INSTDIR\bin\smartd.exe"
435 Delete "$INSTDIR\bin\syslogevt.exe"
436 Delete "$INSTDIR\bin\drivedb.h"
437 Delete "$INSTDIR\bin\drivedb.h.error"
438 Delete "$INSTDIR\bin\drivedb.h.lastcheck"
439 Delete "$INSTDIR\bin\drivedb.h.old"
440 Delete "$INSTDIR\bin\update-smart-drivedb.exe"
441 Delete "$INSTDIR\bin\smartctl-run.bat"
442 Delete "$INSTDIR\bin\smartd-run.bat"
443 Delete "$INSTDIR\bin\net-run.bat"
444 Delete "$INSTDIR\doc\AUTHORS.txt"
445 Delete "$INSTDIR\doc\CHANGELOG.txt"
446 Delete "$INSTDIR\doc\COPYING.txt"
447 Delete "$INSTDIR\doc\INSTALL.txt"
448 Delete "$INSTDIR\doc\NEWS.txt"
449 Delete "$INSTDIR\doc\README.txt"
450 Delete "$INSTDIR\doc\TODO.txt"
451 Delete "$INSTDIR\doc\WARNINGS.txt"
452 Delete "$INSTDIR\doc\checksums.txt"
453 Delete "$INSTDIR\doc\smartctl.8.html"
454 Delete "$INSTDIR\doc\smartctl.8.txt"
455 Delete "$INSTDIR\doc\smartd.8.html"
456 Delete "$INSTDIR\doc\smartd.8.txt"
457 Delete "$INSTDIR\doc\smartd.conf"
458 Delete "$INSTDIR\doc\smartd.conf.5.html"
459 Delete "$INSTDIR\doc\smartd.conf.5.txt"
460 Delete "$INSTDIR\uninst-smartmontools.exe"
463 SetShellVarContext all
464 Delete "$SMPROGRAMS\smartmontools\*.*"
465 Delete "$SMPROGRAMS\smartmontools\Documentation\*.*"
466 Delete "$SMPROGRAMS\smartmontools\smartctl Examples\*.*"
467 Delete "$SMPROGRAMS\smartmontools\smartd Examples\*.*"
470 RMDir "$SMPROGRAMS\smartmontools\Documentation"
471 RMDir "$SMPROGRAMS\smartmontools\smartctl Examples"
472 RMDir "$SMPROGRAMS\smartmontools\smartd Examples"
473 RMDir "$SMPROGRAMS\smartmontools"
478 ; Remove install dir from PATH
479 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
481 Call un.RemoveFromPath
483 ; Remove drive menu registry entries
484 !insertmacro DriveMenuRemove
486 ; Check for still existing entries
487 IfFileExists "$INSTDIR\bin\smartd.exe" 0 +3
488 MessageBox MB_OK|MB_ICONEXCLAMATION "$INSTDIR\bin\smartd.exe could not be removed.$\nsmartd is possibly still running."
490 IfFileExists "$INSTDIR" 0 +2
491 MessageBox MB_OK "Note: $INSTDIR could not be removed."
493 IfFileExists "$SMPROGRAMS\smartmontools" 0 +2
494 MessageBox MB_OK "Note: $SMPROGRAMS\smartmontools could not be removed."
498 ;--------------------------------------------------------------------
503 ; Get UBCD4Win install location
504 ReadRegStr $0 HKLM "Software\UBCD4Win" "InstallPath"
506 StrCpy $0 "C:\UBCD4Win"
507 StrCpy $UBCDDIR "$0\plugin\Disk\Diagnostic\smartmontools"
509 ; Hide "Add install dir to PATH" on 9x/ME
510 IfFileExists "$WINDIR\system32\cmd.exe" +2 0
511 SectionSetText ${PATH_SECTION} ""
516 ; Command line parsing
517 !macro CheckCmdLineOption name section
518 StrCpy $allopts "$allopts,${name}"
523 StrCmp $0 "" 0 sel_${name}
524 !insertmacro UnselectSection ${section}
527 !insertmacro SelectSection ${section}
532 Function ParseCmdLine
536 ${GetOptions} $R0 "/SO" $opts
543 ; turn sections on or off
544 !insertmacro CheckCmdLineOption "smartctl" ${SMARTCTL_SECTION}
545 !insertmacro CheckCmdLineOption "smartd" ${SMARTD_SECTION}
546 !insertmacro CheckCmdLineOption "smartctlnc" ${SMARTCTL_NC_SECTION}
547 !insertmacro CheckCmdLineOption "drivedb" ${DRIVEDB_SECTION}
548 !insertmacro CheckCmdLineOption "doc" ${DOC_SECTION}
549 !insertmacro CheckCmdLineOption "uninst" ${UNINST_SECTION}
550 !insertmacro CheckCmdLineOption "menu" ${MENU_SECTION}
551 !insertmacro CheckCmdLineOption "path" ${PATH_SECTION}
552 !insertmacro CheckCmdLineOption "driveremove" ${DRIVE_REMOVE_SECTION}
553 !insertmacro CheckCmdLineOption "drive0" ${DRIVE_0_SECTION}
554 !insertmacro CheckCmdLineOption "drive1" ${DRIVE_1_SECTION}
555 !insertmacro CheckCmdLineOption "drive2" ${DRIVE_2_SECTION}
556 !insertmacro CheckCmdLineOption "drive3" ${DRIVE_3_SECTION}
557 !insertmacro CheckCmdLineOption "drive4" ${DRIVE_4_SECTION}
558 !insertmacro CheckCmdLineOption "drive5" ${DRIVE_5_SECTION}
559 !insertmacro CheckCmdLineOption "ubcd" ${UBCD_SECTION}
560 StrCmp $opts "-" done
561 StrCmp $nomatch "" done
562 StrCpy $0 "$allopts,-" "" 1
563 MessageBox MB_OK "Usage: smartmontools-VERSION.win32-setup [/S] [/SO component,...] [/D=INSTDIR]$\n$\ncomponents:$\n $0"
568 ; Directory page callbacks
570 !macro CheckSection section
571 SectionGetFlags ${section} $0
576 Function SkipProgPath
577 !insertmacro CheckSection ${SMARTCTL_SECTION}
578 !insertmacro CheckSection ${SMARTCTL_NC_SECTION}
579 !insertmacro CheckSection ${SMARTD_SECTION}
580 !insertmacro CheckSection ${DRIVEDB_SECTION}
581 !insertmacro CheckSection ${DOC_SECTION}
582 !insertmacro CheckSection ${MENU_SECTION}
583 !insertmacro CheckSection ${PATH_SECTION}
584 !insertmacro CheckSection ${DRIVE_0_SECTION}
585 !insertmacro CheckSection ${DRIVE_1_SECTION}
586 !insertmacro CheckSection ${DRIVE_2_SECTION}
587 !insertmacro CheckSection ${DRIVE_3_SECTION}
588 !insertmacro CheckSection ${DRIVE_4_SECTION}
589 !insertmacro CheckSection ${DRIVE_5_SECTION}
594 Function SkipUBCDPath
595 !insertmacro CheckSection ${UBCD_SECTION}
601 ; Create smartctl-run.bat
603 Function CreateSmartctlBat
606 FileWrite $0 '@echo off$\r$\nif not "%1" == "" goto run$\r$\n'
607 FileWrite $0 'echo Examples (for first drive):$\r$\n'
608 FileWrite $0 'echo smartctl -i sda Show identify information$\r$\n'
609 FileWrite $0 'echo smartctl -H sda Show SMART health status$\r$\n'
610 FileWrite $0 'echo smartctl -c sda Show SMART capabilities$\r$\n'
611 FileWrite $0 'echo smartctl -A sda Show SMART attributes$\r$\n'
612 FileWrite $0 'echo smartctl -l error sda Show error log$\r$\n'
613 FileWrite $0 'echo smartctl -l selftest sda Show self-test log$\r$\n'
614 FileWrite $0 'echo smartctl -a sda Show all of the above$\r$\n'
615 FileWrite $0 'echo smartctl -t short sda Start short self test$\r$\n'
616 FileWrite $0 'echo smartctl -t long sda Start long self test$\r$\n'
617 FileWrite $0 'echo Use "sdb", "sdc", ... for second, third, ... drive.$\r$\n'
618 FileWrite $0 'echo See man page (smartctl.8.*) for further info.$\r$\n'
619 FileWrite $0 'goto end$\r$\n:run$\r$\n'
620 FileWrite $0 'echo smartctl %1 %2 %3 %4 %5$\r$\n'
621 FileWrite $0 '"$INSTDIR\bin\smartctl" %1 %2 %3 %4 %5$\r$\n'
622 FileWrite $0 'pause$\r$\n:end$\r$\n'
627 ; Create smartctl-run.bat if missing
629 Function CheckSmartctlBat
630 IfFileExists "$INSTDIR\bin\smartctl-run.bat" done 0
631 SetOutPath "$INSTDIR\bin"
632 DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat"
633 Push "$INSTDIR\bin\smartctl-run.bat"
634 Call CreateSmartctlBat
639 ;--------------------------------------------------------------------
642 ; Based on example from:
643 ; http://nsis.sourceforge.net/Path_Manipulation
647 !include "WinMessages.nsh"
649 ; Registry Entry for environment (NT4,2000,XP)
651 ;!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
653 !define Environ 'HKCU "Environment"'
656 ; AddToPath - Appends dir to PATH
657 ; (does not work on Win9x/ME)
669 ReadRegStr $1 ${Environ} "PATH"
681 DetailPrint "Add to PATH: $0"
684 StrCpy $1 $1 -1 ; remove trailing ';'
685 StrCmp $1 "" +2 ; no leading ';'
687 WriteRegExpandStr ${Environ} "PATH" $0
688 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
698 ; RemoveFromPath - Removes dir from PATH
702 ; Call RemoveFromPath
704 Function un.RemoveFromPath
713 ReadRegStr $1 ${Environ} "PATH"
716 StrCpy $1 "$1;" ; ensure trailing ';'
720 Pop $2 ; pos of our dir
723 DetailPrint "Remove from PATH: $0"
726 StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove
727 StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
731 StrCpy $3 $3 -1 ; remove trailing ';'
732 WriteRegExpandStr ${Environ} "PATH" $3
733 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
746 ; StrStr - find substring in a string
749 ; Push "this is some string"
752 ; Pop $0 ; "some string"
756 Exch $R1 ; $R1=substring, stack=[old$R1,string,...]
757 Exch ; stack=[string,old$R1,...]
758 Exch $R2 ; $R2=string, stack=[old$R2,old$R1,...]
764 ; $R1=substring, $R2=string, $R3=strlen(substring)
767 StrCpy $R5 $R2 $R3 $R4
773 StrCpy $R1 $R2 "" $R4
778 Exch $R1 ; $R1=old$R1, stack=[result,...]
781 !insertmacro StrStr ""
782 !insertmacro StrStr "un."