2 ; installer.nsi - NSIS install script for smartmontools
4 ; Copyright (C) 2006-9 Christian Franke <smartmontools-support@lists.sourceforge.net>
6 ; Project home page is: http://smartmontools.sourceforge.net
8 ; Download and install NSIS from: http://nsis.sourceforge.net/Download
9 ; Process with makensis to create installer (tested with NSIS 2.45)
11 ; $Id: installer.nsi 2878 2009-08-26 20:03:06Z chrfranke $
15 ;--------------------------------------------------------------------
16 ; Command line arguments:
17 ; makensis /DINPDIR=<input-dir> /DOUTFILE=<output-file> /DVERSTR=<version-string> installer.nsi
24 !define OUTFILE "smartmontools.win32-setup.exe"
27 ;--------------------------------------------------------------------
33 SetCompressor /solid lzma
36 InstallColors /windows
38 InstallDir "$PROGRAMFILES\smartmontools"
39 InstallDirRegKey HKLM "Software\smartmontools" "Install_Dir"
42 LicenseData "${INPDIR}\doc\COPYING.txt"
44 ;--------------------------------------------------------------------
49 Page directory SkipProgPath "" ""
51 PageCallbacks SkipUBCDPath "" ""
52 DirText "Setup will install the UBCD4Win plugin in the following folder."
57 UninstPage uninstConfirm
61 InstType "Extract files only"
63 InstType "UBCD4Win plugin"
66 ;--------------------------------------------------------------------
69 SectionGroup "!Program files"
71 Section "smartctl" SMARTCTL_SECTION
75 SetOutPath "$INSTDIR\bin"
76 File "${INPDIR}\bin\smartctl.exe"
80 Section "smartd" SMARTD_SECTION
84 SetOutPath "$INSTDIR\bin"
88 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
89 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
91 ExecWait "net stop smartd" $1
93 File "${INPDIR}\bin\smartd.exe"
95 IfFileExists "$INSTDIR\bin\smartd.conf" 0 +2
96 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Replace existing configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO +2
97 File "${INPDIR}\doc\smartd.conf"
99 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
100 File /nonfatal "${INPDIR}\bin\syslogevt.exe"
104 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Restart smartd service ?" IDYES 0 IDNO +2
105 ExecWait "net start smartd"
109 Section "smartctl-nc (GSmartControl)" SMARTCTL_NC_SECTION
113 SetOutPath "$INSTDIR\bin"
114 File "${INPDIR}\bin\smartctl-nc.exe"
120 Section "!Documentation" DOC_SECTION
124 SetOutPath "$INSTDIR\doc"
125 File "${INPDIR}\doc\AUTHORS.txt"
126 File "${INPDIR}\doc\CHANGELOG.txt"
127 File "${INPDIR}\doc\COPYING.txt"
128 File "${INPDIR}\doc\INSTALL.txt"
129 File "${INPDIR}\doc\NEWS.txt"
130 File "${INPDIR}\doc\README.txt"
131 File "${INPDIR}\doc\TODO.txt"
132 File "${INPDIR}\doc\WARNINGS.txt"
133 File "${INPDIR}\doc\smartctl.8.html"
134 File "${INPDIR}\doc\smartctl.8.txt"
135 File "${INPDIR}\doc\smartd.8.html"
136 File "${INPDIR}\doc\smartd.8.txt"
137 File "${INPDIR}\doc\smartd.conf"
138 File "${INPDIR}\doc\smartd.conf.5.html"
139 File "${INPDIR}\doc\smartd.conf.5.txt"
143 Section "Uninstaller" UNINST_SECTION
148 CreateDirectory "$INSTDIR"
150 ; Save installation location
151 WriteRegStr HKLM "Software\smartmontools" "Install_Dir" "$INSTDIR"
153 ; Write uninstall keys and program
154 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayName" "smartmontools"
156 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayVersion" "${VERSTR}"
158 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "Publisher" "smartmontools"
159 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "UninstallString" '"$INSTDIR\uninst-smartmontools.exe"'
160 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLInfoAbout" "http://smartmontools.sourceforge.net/"
161 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "HelpLink" "http://smartmontools.sourceforge.net/"
162 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://sourceforge.net/project/showfiles.php?group_id=64297"
163 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://smartmontools-win32.dyndns.org/"
164 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoModify" 1
165 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoRepair" 1
166 WriteUninstaller "uninst-smartmontools.exe"
170 Section "Start Menu Shortcuts" MENU_SECTION
174 CreateDirectory "$SMPROGRAMS\smartmontools"
177 IfFileExists "$INSTDIR\bin\smartctl.exe" 0 noctl
178 SetOutPath "$INSTDIR\bin"
179 DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat"
180 Push "$INSTDIR\bin\smartctl-run.bat"
181 Call CreateSmartctlBat
182 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
183 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl (CMD).lnk" "cmd.exe" "/k smartctl-run.bat"
184 CreateDirectory "$SMPROGRAMS\smartmontools\smartctl Examples"
185 FileOpen $0 "$SMPROGRAMS\smartmontools\smartctl Examples\!Read this first!.txt" "w"
186 FileWrite $0 "All the example commands in this directory$\r$\napply to the first drive (sda).$\r$\n"
188 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\All info (-a).lnk" "$INSTDIR\bin\smartctl-run.bat" "-a sda"
189 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Identify drive (-i).lnk" "$INSTDIR\bin\smartctl-run.bat" "-i sda"
190 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART attributes (-A).lnk" "$INSTDIR\bin\smartctl-run.bat" "-A sda"
191 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART capabilities (-c).lnk" "$INSTDIR\bin\smartctl-run.bat" "-c sda"
192 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART health status (-H).lnk" "$INSTDIR\bin\smartctl-run.bat" "-H sda"
193 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART error log (-l error).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l error sda"
194 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART selftest log (-l selftest).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l selftest sda"
195 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start long selftest (-t long).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t long sda"
196 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start offline test (-t offline).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t offline sda"
197 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start short selftest (-t short).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t short sda"
198 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Stop(Abort) selftest (-X).lnk" "$INSTDIR\bin\smartctl-run.bat" "-X sda"
199 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART off (-s off).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s off sda"
200 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART on (-s on).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s on sda"
204 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nod
205 SetOutPath "$INSTDIR\bin"
206 DetailPrint "Create file: $INSTDIR\bin\smartd-run.bat"
207 FileOpen $0 "$INSTDIR\bin\smartd-run.bat" "w"
208 FileWrite $0 "@echo off$\r$\necho smartd %1 %2 %3 %4 %5$\r$\nsmartd %1 %2 %3 %4 %5$\r$\npause$\r$\n"
210 CreateDirectory "$SMPROGRAMS\smartmontools\smartd Examples"
211 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, smartd.log.lnk" "$INSTDIR\bin\smartd-run.bat" "-l local0"
212 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
213 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, eventlog.lnk" "$INSTDIR\bin\smartd-run.bat" ""
214 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon stop.lnk" "$INSTDIR\bin\smartd-run.bat" "stop"
215 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Do all tests once (-q onecheck).lnk" "$INSTDIR\bin\smartd-run.bat" "-q onecheck"
216 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Debug mode (-d).lnk" "$INSTDIR\bin\smartd-run.bat" "-d"
217 IfFileExists "$WINDIR\notepad.exe" 0 nopad
218 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Edit smartd.conf.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.conf"
219 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\View smartd.log.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.log"
222 ; smartd service (not on 9x/ME)
223 IfFileExists "$WINDIR\system32\cmd.exe" 0 nosvc
224 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, eventlog, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install"
225 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 10min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0 -i 600"
226 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0"
227 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service remove.lnk" "$INSTDIR\bin\smartd-run.bat" "remove"
228 DetailPrint "Create file: $INSTDIR\bin\net-run.bat"
229 FileOpen $0 "$INSTDIR\bin\net-run.bat" "w"
230 FileWrite $0 "@echo off$\r$\necho net %1 %2 %3 %4 %5$\r$\nnet %1 %2 %3 %4 %5$\r$\npause$\r$\n"
232 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service start.lnk" "$INSTDIR\bin\net-run.bat" "start smartd"
233 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service stop.lnk" "$INSTDIR\bin\net-run.bat" "stop smartd"
238 IfFileExists "$INSTDIR\doc\README.TXT" 0 nodoc
239 SetOutPath "$INSTDIR\doc"
240 CreateDirectory "$SMPROGRAMS\smartmontools\Documentation"
241 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (html).lnk" "$INSTDIR\doc\smartctl.8.html"
242 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (html).lnk" "$INSTDIR\doc\smartd.8.html"
243 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (html).lnk" "$INSTDIR\doc\smartd.conf.5.html"
244 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (txt).lnk" "$INSTDIR\doc\smartctl.8.txt"
245 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (txt).lnk" "$INSTDIR\doc\smartd.8.txt"
246 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (txt).lnk" "$INSTDIR\doc\smartd.conf.5.txt"
247 IfFileExists "$WINDIR\notepad.exe" 0 +2
248 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$WINDIR\notepad.exe" "$INSTDIR\doc\smartd.conf"
249 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\AUTHORS.lnk" "$INSTDIR\doc\AUTHORS.txt"
250 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\CHANGELOG.lnk" "$INSTDIR\doc\CHANGELOG.txt"
251 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\COPYING.lnk" "$INSTDIR\doc\COPYING.txt"
252 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\INSTALL.lnk" "$INSTDIR\doc\INSTALL.txt"
253 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\NEWS.lnk" "$INSTDIR\doc\NEWS.txt"
254 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\README.lnk" "$INSTDIR\doc\README.txt"
255 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\TODO.lnk" "$INSTDIR\doc\TODO.txt"
256 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\WARNINGS.lnk" "$INSTDIR\doc\WARNINGS.txt"
257 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\Windows version download page.lnk" "http://smartmontools-win32.dyndns.org/smartmontools/"
261 CreateShortCut "$SMPROGRAMS\smartmontools\smartmontools Home Page.lnk" "http://smartmontools.sourceforge.net/"
264 IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 +2
265 CreateShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe"
269 Section "Add install dir to PATH" PATH_SECTION
273 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
279 SectionGroup "Add smartctl to drive menu"
281 !macro DriveMenuRemove
282 DetailPrint "Remove drive menu entries"
283 DeleteRegKey HKCR "Drive\shell\smartctl0"
284 DeleteRegKey HKCR "Drive\shell\smartctl1"
285 DeleteRegKey HKCR "Drive\shell\smartctl2"
286 DeleteRegKey HKCR "Drive\shell\smartctl3"
287 DeleteRegKey HKCR "Drive\shell\smartctl4"
288 DeleteRegKey HKCR "Drive\shell\smartctl5"
291 Section "Remove existing entries first"
293 !insertmacro DriveMenuRemove
296 !macro DriveSection id name args
297 Section 'smartctl ${args} ...' DRIVE_${id}_SECTION
299 DetailPrint 'Add drive menu entry "${name}": smartctl ${args} ...'
300 WriteRegStr HKCR "Drive\shell\smartctl${id}" "" "${name}"
301 WriteRegStr HKCR "Drive\shell\smartctl${id}\command" "" '"$INSTDIR\bin\smartctl-run.bat" ${args} %L'
305 !insertmacro DriveSection 0 "SMART all info" "-a"
306 !insertmacro DriveSection 1 "SMART status" "-Hc"
307 !insertmacro DriveSection 2 "SMART attributes" "-A"
308 !insertmacro DriveSection 3 "SMART short selftest" "-t short"
309 !insertmacro DriveSection 4 "SMART long selftest" "-t long"
310 !insertmacro DriveSection 5 "SMART continue selective selftest" '-t "selective,cont"'
314 Section "UBCD4Win Plugin" UBCD_SECTION
318 SetOutPath "$UBCDDIR"
319 DetailPrint "Create file: smartmontools.inf"
320 FileOpen $0 "$UBCDDIR\smartmontools.inf" "w"
321 FileWrite $0 '; smartmontools.inf$\r$\n; PE Builder v3 plug-in INF file$\r$\n'
322 FileWrite $0 '; Created by smartmontools installer$\r$\n'
323 FileWrite $0 '; http://smartmontools.sourceforge.net/$\r$\n$\r$\n'
324 FileWrite $0 '[Version]$\r$\nSignature= "$$Windows NT$$"$\r$\n$\r$\n'
325 FileWrite $0 '[PEBuilder]$\r$\nName="Disk -Diagnostic: smartmontools"$\r$\n'
326 FileWrite $0 'Enable=1$\r$\nHelp="files\smartctl.8.html"$\r$\n$\r$\n'
327 FileWrite $0 '[WinntDirectories]$\r$\na=Programs\smartmontools,2$\r$\n$\r$\n'
328 FileWrite $0 '[SourceDisksFolders]$\r$\nfiles=a,,1$\r$\n$\r$\n'
329 FileWrite $0 '[Append]$\r$\nnu2menu.xml, smartmontools_nu2menu.xml$\r$\n'
332 DetailPrint "Create file: smartmontools_nu2menu.xml"
333 FileOpen $0 "$UBCDDIR\smartmontools_nu2menu.xml" "w"
334 FileWrite $0 '<!-- Nu2Menu entry for smartmontools -->$\r$\n<NU2MENU>$\r$\n'
335 FileWrite $0 '$\t<MENU ID="Programs">$\r$\n$\t$\t<MITEM TYPE="POPUP" MENUID="Disk Tools">'
336 FileWrite $0 'Disk Tools</MITEM>$\r$\n$\t</MENU>$\r$\n$\t<MENU ID="Disk Tools">$\r$\n'
337 FileWrite $0 '$\t$\t<MITEM TYPE="POPUP" MENUID="Diagnostic">Diagnostic</MITEM>$\r$\n$\t</MENU>'
338 FileWrite $0 '$\r$\n$\t<MENU ID="Diagnostic">$\r$\n$\t$\t<MITEM TYPE="ITEM" DISABLED="'
339 FileWrite $0 '@Not(@FileExists(@GetProgramDrive()\Programs\smartmontools\smartctl.exe))" '
340 FileWrite $0 'CMD="RUN" FUNC="cmd.exe /k cd /d @GetProgramDrive()\Programs\smartmontools&'
341 FileWrite $0 'set PATH=@GetProgramDrive()\Programs\smartmontools;%PATH%&smartctl-run.bat ">'
342 FileWrite $0 'smartctl</MITEM>$\r$\n$\t</MENU>$\r$\n</NU2MENU>$\r$\n'
345 SetOutPath "$UBCDDIR\files"
346 DetailPrint "Create file: smartctl-run.bat"
347 Push "$UBCDDIR\files\smartctl-run.bat"
348 Call CreateSmartctlBat
349 File "${INPDIR}\bin\smartctl.exe"
350 File "${INPDIR}\bin\smartd.exe"
351 File "${INPDIR}\doc\smartctl.8.html"
352 File "${INPDIR}\doc\smartctl.8.txt"
353 File "${INPDIR}\doc\smartd.8.html"
354 File "${INPDIR}\doc\smartd.8.txt"
355 File "${INPDIR}\doc\smartd.conf"
360 ;--------------------------------------------------------------------
364 ; Stop & remove service
365 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
366 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
368 ExecWait "net stop smartd"
369 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Remove smartd service ?" IDYES 0 IDNO nosrv
370 ExecWait "$INSTDIR\bin\smartd.exe remove"
373 ; Remove installer registry keys
374 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools"
375 DeleteRegKey HKLM "Software\smartmontools"
377 ; Remove conf and log file
378 IfFileExists "$INSTDIR\bin\smartd.conf" 0 noconf
379 ; Assume unchanged if timestamp is equal to sample file
380 GetFileTime "$INSTDIR\bin\smartd.conf" $0 $1
381 GetFileTime "$INSTDIR\doc\smartd.conf" $2 $3
382 StrCmp "$0:$1" "$2:$3" +2 0
383 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO noconf
384 Delete "$INSTDIR\bin\smartd.conf"
387 IfFileExists "$INSTDIR\bin\smartd.log" 0 +3
388 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete log file$\n$INSTDIR\bin\smartd.log ?" IDYES 0 IDNO +2
389 Delete "$INSTDIR\bin\smartd.log"
392 Delete "$INSTDIR\bin\smartctl.exe"
393 Delete "$INSTDIR\bin\smartctl-nc.exe"
394 Delete "$INSTDIR\bin\smartd.exe"
395 Delete "$INSTDIR\bin\syslogevt.exe"
396 Delete "$INSTDIR\bin\smartctl-run.bat"
397 Delete "$INSTDIR\bin\smartd-run.bat"
398 Delete "$INSTDIR\bin\net-run.bat"
399 Delete "$INSTDIR\doc\AUTHORS.txt"
400 Delete "$INSTDIR\doc\CHANGELOG.txt"
401 Delete "$INSTDIR\doc\COPYING.txt"
402 Delete "$INSTDIR\doc\INSTALL.txt"
403 Delete "$INSTDIR\doc\NEWS.txt"
404 Delete "$INSTDIR\doc\README.txt"
405 Delete "$INSTDIR\doc\TODO.txt"
406 Delete "$INSTDIR\doc\WARNINGS.txt"
407 Delete "$INSTDIR\doc\smartctl.8.html"
408 Delete "$INSTDIR\doc\smartctl.8.txt"
409 Delete "$INSTDIR\doc\smartd.8.html"
410 Delete "$INSTDIR\doc\smartd.8.txt"
411 Delete "$INSTDIR\doc\smartd.conf"
412 Delete "$INSTDIR\doc\smartd.conf.5.html"
413 Delete "$INSTDIR\doc\smartd.conf.5.txt"
414 Delete "$INSTDIR\uninst-smartmontools.exe"
417 Delete "$SMPROGRAMS\smartmontools\*.*"
418 Delete "$SMPROGRAMS\smartmontools\Documentation\*.*"
419 Delete "$SMPROGRAMS\smartmontools\smartctl Examples\*.*"
420 Delete "$SMPROGRAMS\smartmontools\smartd Examples\*.*"
423 RMDir "$SMPROGRAMS\smartmontools\Documentation"
424 RMDir "$SMPROGRAMS\smartmontools\smartctl Examples"
425 RMDir "$SMPROGRAMS\smartmontools\smartd Examples"
426 RMDir "$SMPROGRAMS\smartmontools"
431 ; Remove install dir from PATH
432 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
434 Call un.RemoveFromPath
436 ; Remove drive menu registry entries
437 !insertmacro DriveMenuRemove
439 ; Check for still existing entries
440 IfFileExists "$INSTDIR\bin\smartd.exe" 0 +3
441 MessageBox MB_OK|MB_ICONEXCLAMATION "$INSTDIR\bin\smartd.exe could not be removed.$\nsmartd is possibly still running."
443 IfFileExists "$INSTDIR" 0 +2
444 MessageBox MB_OK "Note: $INSTDIR could not be removed."
446 IfFileExists "$SMPROGRAMS\smartmontools" 0 +2
447 MessageBox MB_OK "Note: $SMPROGRAMS\smartmontools could not be removed."
451 ;--------------------------------------------------------------------
456 ; Get UBCD4Win install location
457 ReadRegStr $0 HKLM "Software\UBCD4Win" "InstallPath"
459 StrCpy $0 "C:\UBCD4Win"
460 StrCpy $UBCDDIR "$0\plugin\Disk\Diagnostic\smartmontools"
462 ; Hide "Add install dir to PATH" on 9x/ME
463 IfFileExists "$WINDIR\system32\cmd.exe" +2 0
464 SectionSetText ${PATH_SECTION} ""
468 ; Directory page callbacks
470 !macro CheckSection section
471 SectionGetFlags ${section} $0
476 Function SkipProgPath
477 !insertmacro CheckSection ${SMARTCTL_SECTION}
478 !insertmacro CheckSection ${SMARTCTL_NC_SECTION}
479 !insertmacro CheckSection ${SMARTD_SECTION}
480 !insertmacro CheckSection ${DOC_SECTION}
481 !insertmacro CheckSection ${MENU_SECTION}
482 !insertmacro CheckSection ${PATH_SECTION}
483 !insertmacro CheckSection ${DRIVE_0_SECTION}
484 !insertmacro CheckSection ${DRIVE_1_SECTION}
485 !insertmacro CheckSection ${DRIVE_2_SECTION}
486 !insertmacro CheckSection ${DRIVE_3_SECTION}
487 !insertmacro CheckSection ${DRIVE_4_SECTION}
488 !insertmacro CheckSection ${DRIVE_5_SECTION}
493 Function SkipUBCDPath
494 !insertmacro CheckSection ${UBCD_SECTION}
500 ; Create smartctl-run.bat
502 Function CreateSmartctlBat
505 FileWrite $0 '@echo off$\r$\nif not "%1" == "" goto run$\r$\n'
506 FileWrite $0 'echo Examples (for first drive):$\r$\n'
507 FileWrite $0 'echo smartctl -i sda Show identify information$\r$\n'
508 FileWrite $0 'echo smartctl -H sda Show SMART health status$\r$\n'
509 FileWrite $0 'echo smartctl -c sda Show SMART capabilities$\r$\n'
510 FileWrite $0 'echo smartctl -A sda Show SMART attributes$\r$\n'
511 FileWrite $0 'echo smartctl -l error sda Show error log$\r$\n'
512 FileWrite $0 'echo smartctl -l selftest sda Show self-test log$\r$\n'
513 FileWrite $0 'echo smartctl -a sda Show all of the above$\r$\n'
514 FileWrite $0 'echo smartctl -t short sda Start short self test$\r$\n'
515 FileWrite $0 'echo smartctl -t long sda Start long self test$\r$\n'
516 FileWrite $0 'echo Use "sdb", "sdc", ... for second, third, ... drive.$\r$\n'
517 FileWrite $0 'echo See man page (smartctl.8.*) for further info.$\r$\n'
518 FileWrite $0 'goto end$\r$\n:run$\r$\n'
519 FileWrite $0 'echo smartctl %1 %2 %3 %4 %5$\r$\n'
520 FileWrite $0 'smartctl %1 %2 %3 %4 %5$\r$\n'
521 FileWrite $0 'pause$\r$\n:end$\r$\n'
527 ;--------------------------------------------------------------------
530 ; Based on example from:
531 ; http://nsis.sourceforge.net/Path_Manipulation
535 !include "WinMessages.nsh"
537 ; Registry Entry for environment (NT4,2000,XP)
539 ;!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
541 !define Environ 'HKCU "Environment"'
544 ; AddToPath - Appends dir to PATH
545 ; (does not work on Win9x/ME)
557 ReadRegStr $1 ${Environ} "PATH"
569 DetailPrint "Add to PATH: $0"
572 StrCpy $1 $1 -1 ; remove trailing ';'
573 StrCmp $1 "" +2 ; no leading ';'
575 WriteRegExpandStr ${Environ} "PATH" $0
576 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
586 ; RemoveFromPath - Removes dir from PATH
590 ; Call RemoveFromPath
592 Function un.RemoveFromPath
601 ReadRegStr $1 ${Environ} "PATH"
604 StrCpy $1 "$1;" ; ensure trailing ';'
608 Pop $2 ; pos of our dir
611 DetailPrint "Remove from PATH: $0"
614 StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove
615 StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
619 StrCpy $3 $3 -1 ; remove trailing ';'
620 WriteRegExpandStr ${Environ} "PATH" $3
621 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
634 ; StrStr - find substring in a string
637 ; Push "this is some string"
640 ; Pop $0 ; "some string"
644 Exch $R1 ; $R1=substring, stack=[old$R1,string,...]
645 Exch ; stack=[string,old$R1,...]
646 Exch $R2 ; $R2=string, stack=[old$R2,old$R1,...]
652 ; $R1=substring, $R2=string, $R3=strlen(substring)
655 StrCpy $R5 $R2 $R3 $R4
661 StrCpy $R1 $R2 "" $R4
666 Exch $R1 ; $R1=old$R1, stack=[result,...]
669 !insertmacro StrStr ""
670 !insertmacro StrStr "un."