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 3296 2011-03-16 22:17:51Z 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 ;--------------------------------------------------------------------
54 Page directory SkipProgPath "" ""
56 PageCallbacks SkipUBCDPath "" ""
57 DirText "Setup will install the UBCD4Win plugin in the following folder."
62 UninstPage uninstConfirm
66 InstType "Extract files only"
68 InstType "UBCD4Win plugin"
71 ;--------------------------------------------------------------------
74 SectionGroup "!Program files"
76 Section "smartctl" SMARTCTL_SECTION
80 SetOutPath "$INSTDIR\bin"
81 File "${INPDIR}\bin\smartctl.exe"
85 Section "smartd" SMARTD_SECTION
89 SetOutPath "$INSTDIR\bin"
93 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
94 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
96 ExecWait "net stop smartd" $1
98 File "${INPDIR}\bin\smartd.exe"
100 IfFileExists "$INSTDIR\bin\smartd.conf" 0 +2
101 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Replace existing configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO +2
102 File "${INPDIR}\doc\smartd.conf"
104 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
105 File /nonfatal "${INPDIR}\bin\syslogevt.exe"
109 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Restart smartd service ?" IDYES 0 IDNO +2
110 ExecWait "net start smartd"
114 Section "smartctl-nc (GSmartControl)" SMARTCTL_NC_SECTION
118 SetOutPath "$INSTDIR\bin"
119 File "${INPDIR}\bin\smartctl-nc.exe"
123 Section "drivedb.h (Drive Database)" DRIVEDB_SECTION
127 SetOutPath "$INSTDIR\bin"
128 File "${INPDIR}\bin\drivedb.h"
129 File "${INPDIR}\bin\update-smart-drivedb.exe"
135 Section "!Documentation" DOC_SECTION
139 SetOutPath "$INSTDIR\doc"
140 File "${INPDIR}\doc\AUTHORS.txt"
141 File "${INPDIR}\doc\CHANGELOG.txt"
142 File "${INPDIR}\doc\COPYING.txt"
143 File "${INPDIR}\doc\INSTALL.txt"
144 File "${INPDIR}\doc\NEWS.txt"
145 File "${INPDIR}\doc\README.txt"
146 File "${INPDIR}\doc\TODO.txt"
147 File "${INPDIR}\doc\WARNINGS.txt"
148 File "${INPDIR}\doc\checksums.txt"
149 File "${INPDIR}\doc\smartctl.8.html"
150 File "${INPDIR}\doc\smartctl.8.txt"
151 File "${INPDIR}\doc\smartd.8.html"
152 File "${INPDIR}\doc\smartd.8.txt"
153 File "${INPDIR}\doc\smartd.conf"
154 File "${INPDIR}\doc\smartd.conf.5.html"
155 File "${INPDIR}\doc\smartd.conf.5.txt"
159 Section "Uninstaller" UNINST_SECTION
164 CreateDirectory "$INSTDIR"
166 ; Save installation location
167 WriteRegStr HKLM "Software\smartmontools" "Install_Dir" "$INSTDIR"
169 ; Write uninstall keys and program
170 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayName" "smartmontools"
172 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayVersion" "${VERSTR}"
174 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "Publisher" "smartmontools"
175 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "UninstallString" '"$INSTDIR\uninst-smartmontools.exe"'
176 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLInfoAbout" "http://smartmontools.sourceforge.net/"
177 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "HelpLink" "http://smartmontools.sourceforge.net/"
178 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://sourceforge.net/project/showfiles.php?group_id=64297"
179 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://smartmontools-win32.dyndns.org/"
180 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoModify" 1
181 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoRepair" 1
182 WriteUninstaller "uninst-smartmontools.exe"
186 Section "Start Menu Shortcuts" MENU_SECTION
190 CreateDirectory "$SMPROGRAMS\smartmontools"
193 IfFileExists "$INSTDIR\bin\smartctl.exe" 0 noctl
194 SetOutPath "$INSTDIR\bin"
195 DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat"
196 Push "$INSTDIR\bin\smartctl-run.bat"
197 Call CreateSmartctlBat
198 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
199 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl (CMD).lnk" "cmd.exe" "/k smartctl-run.bat"
200 CreateDirectory "$SMPROGRAMS\smartmontools\smartctl Examples"
201 FileOpen $0 "$SMPROGRAMS\smartmontools\smartctl Examples\!Read this first!.txt" "w"
202 FileWrite $0 "All the example commands in this directory$\r$\napply to the first drive (sda).$\r$\n"
204 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\All info (-a).lnk" "$INSTDIR\bin\smartctl-run.bat" "-a sda"
205 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Identify drive (-i).lnk" "$INSTDIR\bin\smartctl-run.bat" "-i sda"
206 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART attributes (-A).lnk" "$INSTDIR\bin\smartctl-run.bat" "-A sda"
207 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART capabilities (-c).lnk" "$INSTDIR\bin\smartctl-run.bat" "-c sda"
208 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART health status (-H).lnk" "$INSTDIR\bin\smartctl-run.bat" "-H sda"
209 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART error log (-l error).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l error sda"
210 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART selftest log (-l selftest).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l selftest sda"
211 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start long selftest (-t long).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t long sda"
212 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start offline test (-t offline).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t offline sda"
213 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start short selftest (-t short).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t short sda"
214 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Stop(Abort) selftest (-X).lnk" "$INSTDIR\bin\smartctl-run.bat" "-X sda"
215 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART off (-s off).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s off sda"
216 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART on (-s on).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s on sda"
220 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nod
221 SetOutPath "$INSTDIR\bin"
222 DetailPrint "Create file: $INSTDIR\bin\smartd-run.bat"
223 FileOpen $0 "$INSTDIR\bin\smartd-run.bat" "w"
224 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'
226 CreateDirectory "$SMPROGRAMS\smartmontools\smartd Examples"
227 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, smartd.log.lnk" "$INSTDIR\bin\smartd-run.bat" "-l local0"
228 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
229 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, eventlog.lnk" "$INSTDIR\bin\smartd-run.bat" ""
230 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon stop.lnk" "$INSTDIR\bin\smartd-run.bat" "stop"
231 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Do all tests once (-q onecheck).lnk" "$INSTDIR\bin\smartd-run.bat" "-q onecheck"
232 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Debug mode (-d).lnk" "$INSTDIR\bin\smartd-run.bat" "-d"
233 IfFileExists "$WINDIR\notepad.exe" 0 nopad
234 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Edit smartd.conf.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.conf"
235 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\View smartd.log.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.log"
238 ; smartd service (not on 9x/ME)
239 IfFileExists "$WINDIR\system32\cmd.exe" 0 nosvc
240 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, eventlog, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install"
241 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 10min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0 -i 600"
242 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0"
243 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service remove.lnk" "$INSTDIR\bin\smartd-run.bat" "remove"
244 DetailPrint "Create file: $INSTDIR\bin\net-run.bat"
245 FileOpen $0 "$INSTDIR\bin\net-run.bat" "w"
246 FileWrite $0 "@echo off$\r$\necho net %1 %2 %3 %4 %5$\r$\nnet %1 %2 %3 %4 %5$\r$\npause$\r$\n"
248 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service start.lnk" "$INSTDIR\bin\net-run.bat" "start smartd"
249 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service stop.lnk" "$INSTDIR\bin\net-run.bat" "stop smartd"
254 IfFileExists "$INSTDIR\doc\README.TXT" 0 nodoc
255 SetOutPath "$INSTDIR\doc"
256 CreateDirectory "$SMPROGRAMS\smartmontools\Documentation"
257 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (html).lnk" "$INSTDIR\doc\smartctl.8.html"
258 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (html).lnk" "$INSTDIR\doc\smartd.8.html"
259 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (html).lnk" "$INSTDIR\doc\smartd.conf.5.html"
260 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (txt).lnk" "$INSTDIR\doc\smartctl.8.txt"
261 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (txt).lnk" "$INSTDIR\doc\smartd.8.txt"
262 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (txt).lnk" "$INSTDIR\doc\smartd.conf.5.txt"
263 IfFileExists "$WINDIR\notepad.exe" 0 +5
264 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$WINDIR\notepad.exe" "$INSTDIR\doc\smartd.conf"
265 IfFileExists "$INSTDIR\bin\drivedb.h" 0 +3
266 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb.h (view).lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\drivedb.h"
267 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb-add.h (create, edit).lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\drivedb-add.h"
268 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\AUTHORS.lnk" "$INSTDIR\doc\AUTHORS.txt"
269 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\CHANGELOG.lnk" "$INSTDIR\doc\CHANGELOG.txt"
270 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\COPYING.lnk" "$INSTDIR\doc\COPYING.txt"
271 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\INSTALL.lnk" "$INSTDIR\doc\INSTALL.txt"
272 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\NEWS.lnk" "$INSTDIR\doc\NEWS.txt"
273 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\README.lnk" "$INSTDIR\doc\README.txt"
274 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\TODO.lnk" "$INSTDIR\doc\TODO.txt"
275 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\WARNINGS.lnk" "$INSTDIR\doc\WARNINGS.txt"
276 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\Windows version download page.lnk" "http://smartmontools-win32.dyndns.org/smartmontools/"
280 CreateShortCut "$SMPROGRAMS\smartmontools\smartmontools Home Page.lnk" "http://smartmontools.sourceforge.net/"
283 IfFileExists "$INSTDIR\bin\update-smart-drivedb.exe" 0 +2
284 CreateShortCut "$SMPROGRAMS\smartmontools\drivedb.h update.lnk" "$INSTDIR\bin\update-smart-drivedb.exe"
287 IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 +2
288 CreateShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe"
292 Section "Add install dir to PATH" PATH_SECTION
296 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
302 SectionGroup "Add smartctl to drive menu"
304 !macro DriveMenuRemove
305 DetailPrint "Remove drive menu entries"
306 DeleteRegKey HKCR "Drive\shell\smartctl0"
307 DeleteRegKey HKCR "Drive\shell\smartctl1"
308 DeleteRegKey HKCR "Drive\shell\smartctl2"
309 DeleteRegKey HKCR "Drive\shell\smartctl3"
310 DeleteRegKey HKCR "Drive\shell\smartctl4"
311 DeleteRegKey HKCR "Drive\shell\smartctl5"
314 Section "Remove existing entries first"
316 !insertmacro DriveMenuRemove
319 !macro DriveSection id name args
320 Section 'smartctl ${args} ...' DRIVE_${id}_SECTION
322 Call CheckSmartctlBat
323 DetailPrint 'Add drive menu entry "${name}": smartctl ${args} ...'
324 WriteRegStr HKCR "Drive\shell\smartctl${id}" "" "${name}"
325 WriteRegStr HKCR "Drive\shell\smartctl${id}\command" "" '"$INSTDIR\bin\smartctl-run.bat" ${args} %L'
329 !insertmacro DriveSection 0 "SMART all info" "-a"
330 !insertmacro DriveSection 1 "SMART status" "-Hc"
331 !insertmacro DriveSection 2 "SMART attributes" "-A"
332 !insertmacro DriveSection 3 "SMART short selftest" "-t short"
333 !insertmacro DriveSection 4 "SMART long selftest" "-t long"
334 !insertmacro DriveSection 5 "SMART continue selective selftest" '-t "selective,cont"'
338 Section "UBCD4Win Plugin" UBCD_SECTION
342 SetOutPath "$UBCDDIR"
343 DetailPrint "Create file: smartmontools.inf"
344 FileOpen $0 "$UBCDDIR\smartmontools.inf" "w"
345 FileWrite $0 '; smartmontools.inf$\r$\n; PE Builder v3 plug-in INF file$\r$\n'
346 FileWrite $0 '; Created by smartmontools installer$\r$\n'
347 FileWrite $0 '; http://smartmontools.sourceforge.net/$\r$\n$\r$\n'
348 FileWrite $0 '[Version]$\r$\nSignature= "$$Windows NT$$"$\r$\n$\r$\n'
349 FileWrite $0 '[PEBuilder]$\r$\nName="Disk -Diagnostic: smartmontools"$\r$\n'
350 FileWrite $0 'Enable=1$\r$\nHelp="files\smartctl.8.html"$\r$\n$\r$\n'
351 FileWrite $0 '[WinntDirectories]$\r$\na=Programs\smartmontools,2$\r$\n$\r$\n'
352 FileWrite $0 '[SourceDisksFolders]$\r$\nfiles=a,,1$\r$\n$\r$\n'
353 FileWrite $0 '[Append]$\r$\nnu2menu.xml, smartmontools_nu2menu.xml$\r$\n'
356 DetailPrint "Create file: smartmontools_nu2menu.xml"
357 FileOpen $0 "$UBCDDIR\smartmontools_nu2menu.xml" "w"
358 FileWrite $0 '<!-- Nu2Menu entry for smartmontools -->$\r$\n<NU2MENU>$\r$\n'
359 FileWrite $0 '$\t<MENU ID="Programs">$\r$\n$\t$\t<MITEM TYPE="POPUP" MENUID="Disk Tools">'
360 FileWrite $0 'Disk Tools</MITEM>$\r$\n$\t</MENU>$\r$\n$\t<MENU ID="Disk Tools">$\r$\n'
361 FileWrite $0 '$\t$\t<MITEM TYPE="POPUP" MENUID="Diagnostic">Diagnostic</MITEM>$\r$\n$\t</MENU>'
362 FileWrite $0 '$\r$\n$\t<MENU ID="Diagnostic">$\r$\n$\t$\t<MITEM TYPE="ITEM" DISABLED="'
363 FileWrite $0 '@Not(@FileExists(@GetProgramDrive()\Programs\smartmontools\smartctl.exe))" '
364 FileWrite $0 'CMD="RUN" FUNC="cmd.exe /k cd /d @GetProgramDrive()\Programs\smartmontools&'
365 FileWrite $0 'set PATH=@GetProgramDrive()\Programs\smartmontools;%PATH%&smartctl-run.bat ">'
366 FileWrite $0 'smartctl</MITEM>$\r$\n$\t</MENU>$\r$\n</NU2MENU>$\r$\n'
369 SetOutPath "$UBCDDIR\files"
370 DetailPrint "Create file: smartctl-run.bat"
371 Push "$UBCDDIR\files\smartctl-run.bat"
372 Call CreateSmartctlBat
373 File "${INPDIR}\bin\smartctl.exe"
374 File "${INPDIR}\bin\smartd.exe"
375 File "${INPDIR}\doc\smartctl.8.html"
376 File "${INPDIR}\doc\smartctl.8.txt"
377 File "${INPDIR}\doc\smartd.8.html"
378 File "${INPDIR}\doc\smartd.8.txt"
379 File "${INPDIR}\doc\smartd.conf"
384 ;--------------------------------------------------------------------
388 ; Stop & remove service
389 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
390 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
392 ExecWait "net stop smartd"
393 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Remove smartd service ?" IDYES 0 IDNO nosrv
394 ExecWait "$INSTDIR\bin\smartd.exe remove"
397 ; Remove installer registry keys
398 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools"
399 DeleteRegKey HKLM "Software\smartmontools"
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
407 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO noconf
408 Delete "$INSTDIR\bin\smartd.conf"
412 IfFileExists "$INSTDIR\bin\smartd.log" 0 +3
413 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete log file$\n$INSTDIR\bin\smartd.log ?" IDYES 0 IDNO +2
414 Delete "$INSTDIR\bin\smartd.log"
416 ; Remove drivedb-add file ?
417 IfFileExists "$INSTDIR\bin\drivedb-add.h" 0 +3
418 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete local drive database file$\n$INSTDIR\bin\drivedb-add.h ?" IDYES 0 IDNO +2
419 Delete "$INSTDIR\bin\drivedb-add.h"
422 Delete "$INSTDIR\bin\smartctl.exe"
423 Delete "$INSTDIR\bin\smartctl-nc.exe"
424 Delete "$INSTDIR\bin\smartd.exe"
425 Delete "$INSTDIR\bin\syslogevt.exe"
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"
431 Delete "$INSTDIR\bin\smartctl-run.bat"
432 Delete "$INSTDIR\bin\smartd-run.bat"
433 Delete "$INSTDIR\bin\net-run.bat"
434 Delete "$INSTDIR\doc\AUTHORS.txt"
435 Delete "$INSTDIR\doc\CHANGELOG.txt"
436 Delete "$INSTDIR\doc\COPYING.txt"
437 Delete "$INSTDIR\doc\INSTALL.txt"
438 Delete "$INSTDIR\doc\NEWS.txt"
439 Delete "$INSTDIR\doc\README.txt"
440 Delete "$INSTDIR\doc\TODO.txt"
441 Delete "$INSTDIR\doc\WARNINGS.txt"
442 Delete "$INSTDIR\doc\checksums.txt"
443 Delete "$INSTDIR\doc\smartctl.8.html"
444 Delete "$INSTDIR\doc\smartctl.8.txt"
445 Delete "$INSTDIR\doc\smartd.8.html"
446 Delete "$INSTDIR\doc\smartd.8.txt"
447 Delete "$INSTDIR\doc\smartd.conf"
448 Delete "$INSTDIR\doc\smartd.conf.5.html"
449 Delete "$INSTDIR\doc\smartd.conf.5.txt"
450 Delete "$INSTDIR\uninst-smartmontools.exe"
453 Delete "$SMPROGRAMS\smartmontools\*.*"
454 Delete "$SMPROGRAMS\smartmontools\Documentation\*.*"
455 Delete "$SMPROGRAMS\smartmontools\smartctl Examples\*.*"
456 Delete "$SMPROGRAMS\smartmontools\smartd Examples\*.*"
459 RMDir "$SMPROGRAMS\smartmontools\Documentation"
460 RMDir "$SMPROGRAMS\smartmontools\smartctl Examples"
461 RMDir "$SMPROGRAMS\smartmontools\smartd Examples"
462 RMDir "$SMPROGRAMS\smartmontools"
467 ; Remove install dir from PATH
468 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
470 Call un.RemoveFromPath
472 ; Remove drive menu registry entries
473 !insertmacro DriveMenuRemove
475 ; Check for still existing entries
476 IfFileExists "$INSTDIR\bin\smartd.exe" 0 +3
477 MessageBox MB_OK|MB_ICONEXCLAMATION "$INSTDIR\bin\smartd.exe could not be removed.$\nsmartd is possibly still running."
479 IfFileExists "$INSTDIR" 0 +2
480 MessageBox MB_OK "Note: $INSTDIR could not be removed."
482 IfFileExists "$SMPROGRAMS\smartmontools" 0 +2
483 MessageBox MB_OK "Note: $SMPROGRAMS\smartmontools could not be removed."
487 ;--------------------------------------------------------------------
492 ; Get UBCD4Win install location
493 ReadRegStr $0 HKLM "Software\UBCD4Win" "InstallPath"
495 StrCpy $0 "C:\UBCD4Win"
496 StrCpy $UBCDDIR "$0\plugin\Disk\Diagnostic\smartmontools"
498 ; Hide "Add install dir to PATH" on 9x/ME
499 IfFileExists "$WINDIR\system32\cmd.exe" +2 0
500 SectionSetText ${PATH_SECTION} ""
504 ; Directory page callbacks
506 !macro CheckSection section
507 SectionGetFlags ${section} $0
512 Function SkipProgPath
513 !insertmacro CheckSection ${SMARTCTL_SECTION}
514 !insertmacro CheckSection ${SMARTCTL_NC_SECTION}
515 !insertmacro CheckSection ${SMARTD_SECTION}
516 !insertmacro CheckSection ${DRIVEDB_SECTION}
517 !insertmacro CheckSection ${DOC_SECTION}
518 !insertmacro CheckSection ${MENU_SECTION}
519 !insertmacro CheckSection ${PATH_SECTION}
520 !insertmacro CheckSection ${DRIVE_0_SECTION}
521 !insertmacro CheckSection ${DRIVE_1_SECTION}
522 !insertmacro CheckSection ${DRIVE_2_SECTION}
523 !insertmacro CheckSection ${DRIVE_3_SECTION}
524 !insertmacro CheckSection ${DRIVE_4_SECTION}
525 !insertmacro CheckSection ${DRIVE_5_SECTION}
530 Function SkipUBCDPath
531 !insertmacro CheckSection ${UBCD_SECTION}
537 ; Create smartctl-run.bat
539 Function CreateSmartctlBat
542 FileWrite $0 '@echo off$\r$\nif not "%1" == "" goto run$\r$\n'
543 FileWrite $0 'echo Examples (for first drive):$\r$\n'
544 FileWrite $0 'echo smartctl -i sda Show identify information$\r$\n'
545 FileWrite $0 'echo smartctl -H sda Show SMART health status$\r$\n'
546 FileWrite $0 'echo smartctl -c sda Show SMART capabilities$\r$\n'
547 FileWrite $0 'echo smartctl -A sda Show SMART attributes$\r$\n'
548 FileWrite $0 'echo smartctl -l error sda Show error log$\r$\n'
549 FileWrite $0 'echo smartctl -l selftest sda Show self-test log$\r$\n'
550 FileWrite $0 'echo smartctl -a sda Show all of the above$\r$\n'
551 FileWrite $0 'echo smartctl -t short sda Start short self test$\r$\n'
552 FileWrite $0 'echo smartctl -t long sda Start long self test$\r$\n'
553 FileWrite $0 'echo Use "sdb", "sdc", ... for second, third, ... drive.$\r$\n'
554 FileWrite $0 'echo See man page (smartctl.8.*) for further info.$\r$\n'
555 FileWrite $0 'goto end$\r$\n:run$\r$\n'
556 FileWrite $0 'echo smartctl %1 %2 %3 %4 %5$\r$\n'
557 FileWrite $0 '"$INSTDIR\bin\smartctl" %1 %2 %3 %4 %5$\r$\n'
558 FileWrite $0 'pause$\r$\n:end$\r$\n'
563 ; Create smartctl-run.bat if missing
565 Function CheckSmartctlBat
566 IfFileExists "$INSTDIR\bin\smartctl-run.bat" done 0
567 SetOutPath "$INSTDIR\bin"
568 DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat"
569 Push "$INSTDIR\bin\smartctl-run.bat"
570 Call CreateSmartctlBat
575 ;--------------------------------------------------------------------
578 ; Based on example from:
579 ; http://nsis.sourceforge.net/Path_Manipulation
583 !include "WinMessages.nsh"
585 ; Registry Entry for environment (NT4,2000,XP)
587 ;!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
589 !define Environ 'HKCU "Environment"'
592 ; AddToPath - Appends dir to PATH
593 ; (does not work on Win9x/ME)
605 ReadRegStr $1 ${Environ} "PATH"
617 DetailPrint "Add to PATH: $0"
620 StrCpy $1 $1 -1 ; remove trailing ';'
621 StrCmp $1 "" +2 ; no leading ';'
623 WriteRegExpandStr ${Environ} "PATH" $0
624 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
634 ; RemoveFromPath - Removes dir from PATH
638 ; Call RemoveFromPath
640 Function un.RemoveFromPath
649 ReadRegStr $1 ${Environ} "PATH"
652 StrCpy $1 "$1;" ; ensure trailing ';'
656 Pop $2 ; pos of our dir
659 DetailPrint "Remove from PATH: $0"
662 StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove
663 StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
667 StrCpy $3 $3 -1 ; remove trailing ';'
668 WriteRegExpandStr ${Environ} "PATH" $3
669 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
682 ; StrStr - find substring in a string
685 ; Push "this is some string"
688 ; Pop $0 ; "some string"
692 Exch $R1 ; $R1=substring, stack=[old$R1,string,...]
693 Exch ; stack=[string,old$R1,...]
694 Exch $R2 ; $R2=string, stack=[old$R2,old$R1,...]
700 ; $R1=substring, $R2=string, $R3=strlen(substring)
703 StrCpy $R5 $R2 $R3 $R4
709 StrCpy $R1 $R2 "" $R4
714 Exch $R1 ; $R1=old$R1, stack=[result,...]
717 !insertmacro StrStr ""
718 !insertmacro StrStr "un."