2 ; installer.nsi - NSIS install script for smartmontools
4 ; Copyright (C) 2006-8 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.29)
11 ; $Id: installer.nsi,v 1.4 2008/03/04 22:09:48 ballen4705 Exp $
15 ;--------------------------------------------------------------------
16 ; Command line arguments:
17 ; makensis /DINPDIR=<input-dir> /DOUTFILE=<output-file> 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"
111 Section "!Documentation" DOC_SECTION
115 SetOutPath "$INSTDIR\doc"
116 File "${INPDIR}\doc\AUTHORS.txt"
117 File "${INPDIR}\doc\CHANGELOG.txt"
118 File "${INPDIR}\doc\COPYING.txt"
119 File "${INPDIR}\doc\INSTALL.txt"
120 File "${INPDIR}\doc\NEWS.txt"
121 File "${INPDIR}\doc\README.txt"
122 File "${INPDIR}\doc\TODO.txt"
123 File "${INPDIR}\doc\WARNINGS.txt"
124 File "${INPDIR}\doc\smartctl.8.html"
125 File "${INPDIR}\doc\smartctl.8.txt"
126 File "${INPDIR}\doc\smartd.8.html"
127 File "${INPDIR}\doc\smartd.8.txt"
128 File "${INPDIR}\doc\smartd.conf"
129 File "${INPDIR}\doc\smartd.conf.5.html"
130 File "${INPDIR}\doc\smartd.conf.5.txt"
134 Section "Uninstaller" UNINST_SECTION
139 CreateDirectory "$INSTDIR"
141 ; Save installation location
142 WriteRegStr HKLM "Software\smartmontools" "Install_Dir" "$INSTDIR"
144 ; Write uninstall keys and program
145 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayName" "smartmontools"
146 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "Publisher" "smartmontools"
147 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "UninstallString" '"$INSTDIR\uninst-smartmontools.exe"'
148 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLInfoAbout" "http://smartmontools.sourceforge.net/"
149 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "HelpLink" "http://smartmontools.sourceforge.net/"
150 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://sourceforge.net/project/showfiles.php?group_id=64297"
151 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://smartmontools-win32.dyndns.org/"
152 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoModify" 1
153 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoRepair" 1
154 WriteUninstaller "uninst-smartmontools.exe"
158 Section "Start Menu Shortcuts" MENU_SECTION
162 CreateDirectory "$SMPROGRAMS\smartmontools"
165 IfFileExists "$INSTDIR\bin\smartctl.exe" 0 noctl
166 SetOutPath "$INSTDIR\bin"
167 DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat"
168 Push "$INSTDIR\bin\smartctl-run.bat"
169 Call CreateSmartctlBat
170 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
171 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl (CMD).lnk" "cmd.exe" "/k smartctl-run.bat"
172 CreateDirectory "$SMPROGRAMS\smartmontools\smartctl Examples"
173 FileOpen $0 "$SMPROGRAMS\smartmontools\smartctl Examples\!Read this first!.txt" "w"
174 FileWrite $0 "All the example commands in this directory$\r$\napply to the first drive (sda).$\r$\n"
176 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\All info (-a).lnk" "$INSTDIR\bin\smartctl-run.bat" "-a sda"
177 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Identify drive (-i).lnk" "$INSTDIR\bin\smartctl-run.bat" "-i sda"
178 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART attributes (-A).lnk" "$INSTDIR\bin\smartctl-run.bat" "-A sda"
179 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART capabilities (-c).lnk" "$INSTDIR\bin\smartctl-run.bat" "-c sda"
180 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART health status (-H).lnk" "$INSTDIR\bin\smartctl-run.bat" "-H sda"
181 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART error log (-l error).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l error sda"
182 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART selftest log (-l selftest).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l selftest sda"
183 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start long selftest (-t long).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t long sda"
184 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start offline test (-t offline).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t offline sda"
185 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start short selftest (-t short).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t short sda"
186 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Stop(Abort) selftest (-X).lnk" "$INSTDIR\bin\smartctl-run.bat" "-X sda"
187 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART off (-s off).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s off sda"
188 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART on (-s on).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s on sda"
192 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nod
193 SetOutPath "$INSTDIR\bin"
194 DetailPrint "Create file: $INSTDIR\bin\smartd-run.bat"
195 FileOpen $0 "$INSTDIR\bin\smartd-run.bat" "w"
196 FileWrite $0 "@echo off$\r$\necho smartd %1 %2 %3 %4 %5$\r$\nsmartd %1 %2 %3 %4 %5$\r$\npause$\r$\n"
198 CreateDirectory "$SMPROGRAMS\smartmontools\smartd Examples"
199 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, smartd.log.lnk" "$INSTDIR\bin\smartd-run.bat" "-l local0"
200 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
201 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, eventlog.lnk" "$INSTDIR\bin\smartd-run.bat" ""
202 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon stop.lnk" "$INSTDIR\bin\smartd-run.bat" "stop"
203 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Do all tests once (-q onecheck).lnk" "$INSTDIR\bin\smartd-run.bat" "-q onecheck"
204 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Debug mode (-d).lnk" "$INSTDIR\bin\smartd-run.bat" "-d"
205 IfFileExists "$WINDIR\notepad.exe" 0 nopad
206 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Edit smartd.conf.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.conf"
207 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\View smartd.log.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.log"
210 ; smartd service (not on 9x/ME)
211 IfFileExists "$WINDIR\system32\cmd.exe" 0 nosvc
212 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, eventlog, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install"
213 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 10min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0 -i 600"
214 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0"
215 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service remove.lnk" "$INSTDIR\bin\smartd-run.bat" "remove"
216 DetailPrint "Create file: $INSTDIR\bin\net-run.bat"
217 FileOpen $0 "$INSTDIR\bin\net-run.bat" "w"
218 FileWrite $0 "@echo off$\r$\necho net %1 %2 %3 %4 %5$\r$\nnet %1 %2 %3 %4 %5$\r$\npause$\r$\n"
220 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service start.lnk" "$INSTDIR\bin\net-run.bat" "start smartd"
221 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service stop.lnk" "$INSTDIR\bin\net-run.bat" "stop smartd"
226 IfFileExists "$INSTDIR\doc\README.TXT" 0 nodoc
227 SetOutPath "$INSTDIR\doc"
228 CreateDirectory "$SMPROGRAMS\smartmontools\Documentation"
229 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (html).lnk" "$INSTDIR\doc\smartctl.8.html"
230 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (html).lnk" "$INSTDIR\doc\smartd.8.html"
231 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (html).lnk" "$INSTDIR\doc\smartd.conf.5.html"
232 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (txt).lnk" "$INSTDIR\doc\smartctl.8.txt"
233 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (txt).lnk" "$INSTDIR\doc\smartd.8.txt"
234 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (txt).lnk" "$INSTDIR\doc\smartd.conf.5.txt"
235 IfFileExists "$WINDIR\notepad.exe" 0 +2
236 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$WINDIR\notepad.exe" "$INSTDIR\doc\smartd.conf"
237 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\AUTHORS.lnk" "$INSTDIR\doc\AUTHORS.txt"
238 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\CHANGELOG.lnk" "$INSTDIR\doc\CHANGELOG.txt"
239 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\COPYING.lnk" "$INSTDIR\doc\COPYING.txt"
240 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\INSTALL.lnk" "$INSTDIR\doc\INSTALL.txt"
241 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\NEWS.lnk" "$INSTDIR\doc\NEWS.txt"
242 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\README.lnk" "$INSTDIR\doc\README.txt"
243 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\TODO.lnk" "$INSTDIR\doc\TODO.txt"
244 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\WARNINGS.lnk" "$INSTDIR\doc\WARNINGS.txt"
245 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\Windows version download page.lnk" "http://smartmontools-win32.dyndns.org/smartmontools/"
249 CreateShortCut "$SMPROGRAMS\smartmontools\smartmontools Home Page.lnk" "http://smartmontools.sourceforge.net/"
252 IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 +2
253 CreateShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe"
257 Section "Add install dir to PATH" PATH_SECTION
261 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
267 SectionGroup "Add smartctl to drive menu"
269 !macro DriveMenuRemove
270 DetailPrint "Remove drive menu entries"
271 DeleteRegKey HKCR "Drive\shell\smartctl0"
272 DeleteRegKey HKCR "Drive\shell\smartctl1"
273 DeleteRegKey HKCR "Drive\shell\smartctl2"
274 DeleteRegKey HKCR "Drive\shell\smartctl3"
275 DeleteRegKey HKCR "Drive\shell\smartctl4"
276 DeleteRegKey HKCR "Drive\shell\smartctl5"
279 Section "Remove existing entries first"
281 !insertmacro DriveMenuRemove
284 !macro DriveSection id name args
285 Section 'smartctl ${args} ...' DRIVE_${id}_SECTION
287 DetailPrint 'Add drive menu entry "${name}": smartctl ${args} ...'
288 WriteRegStr HKCR "Drive\shell\smartctl${id}" "" "${name}"
289 WriteRegStr HKCR "Drive\shell\smartctl${id}\command" "" '"$INSTDIR\bin\smartctl-run.bat" ${args} %L'
293 !insertmacro DriveSection 0 "SMART all info" "-a"
294 !insertmacro DriveSection 1 "SMART status" "-Hc"
295 !insertmacro DriveSection 2 "SMART attributes" "-A"
296 !insertmacro DriveSection 3 "SMART short selftest" "-t short"
297 !insertmacro DriveSection 4 "SMART long selftest" "-t long"
298 !insertmacro DriveSection 5 "SMART continue selective selftest" '-t "selective,cont"'
302 Section "UBCD4Win Plugin" UBCD_SECTION
306 SetOutPath "$UBCDDIR"
307 DetailPrint "Create file: smartmontools.inf"
308 FileOpen $0 "$UBCDDIR\smartmontools.inf" "w"
309 FileWrite $0 '; smartmontools.inf$\r$\n; PE Builder v3 plug-in INF file$\r$\n'
310 FileWrite $0 '; Created by smartmontools installer$\r$\n'
311 FileWrite $0 '; http://smartmontools.sourceforge.net/$\r$\n$\r$\n'
312 FileWrite $0 '[Version]$\r$\nSignature= "$$Windows NT$$"$\r$\n$\r$\n'
313 FileWrite $0 '[PEBuilder]$\r$\nName="Disk -Diagnostic: smartmontools"$\r$\n'
314 FileWrite $0 'Enable=1$\r$\nHelp="files\smartctl.8.html"$\r$\n$\r$\n'
315 FileWrite $0 '[WinntDirectories]$\r$\na=Programs\smartmontools,2$\r$\n$\r$\n'
316 FileWrite $0 '[SourceDisksFolders]$\r$\nfiles=a,,1$\r$\n$\r$\n'
317 FileWrite $0 '[Append]$\r$\nnu2menu.xml, smartmontools_nu2menu.xml$\r$\n'
320 DetailPrint "Create file: smartmontools_nu2menu.xml"
321 FileOpen $0 "$UBCDDIR\smartmontools_nu2menu.xml" "w"
322 FileWrite $0 '<!-- Nu2Menu entry for smartmontools -->$\r$\n<NU2MENU>$\r$\n'
323 FileWrite $0 '$\t<MENU ID="Programs">$\r$\n$\t$\t<MITEM TYPE="POPUP" MENUID="Disk Tools">'
324 FileWrite $0 'Disk Tools</MITEM>$\r$\n$\t</MENU>$\r$\n$\t<MENU ID="Disk Tools">$\r$\n'
325 FileWrite $0 '$\t$\t<MITEM TYPE="POPUP" MENUID="Diagnostic">Diagnostic</MITEM>$\r$\n$\t</MENU>'
326 FileWrite $0 '$\r$\n$\t<MENU ID="Diagnostic">$\r$\n$\t$\t<MITEM TYPE="ITEM" DISABLED="'
327 FileWrite $0 '@Not(@FileExists(@GetProgramDrive()\Programs\smartmontools\smartctl.exe))" '
328 FileWrite $0 'CMD="RUN" FUNC="cmd.exe /k cd /d @GetProgramDrive()\Programs\smartmontools&'
329 FileWrite $0 'set PATH=@GetProgramDrive()\Programs\smartmontools;%PATH%&smartctl-run.bat ">'
330 FileWrite $0 'smartctl</MITEM>$\r$\n$\t</MENU>$\r$\n</NU2MENU>$\r$\n'
333 SetOutPath "$UBCDDIR\files"
334 DetailPrint "Create file: smartctl-run.bat"
335 Push "$UBCDDIR\files\smartctl-run.bat"
336 Call CreateSmartctlBat
337 File "${INPDIR}\bin\smartctl.exe"
338 File "${INPDIR}\bin\smartd.exe"
339 File "${INPDIR}\doc\smartctl.8.html"
340 File "${INPDIR}\doc\smartctl.8.txt"
341 File "${INPDIR}\doc\smartd.8.html"
342 File "${INPDIR}\doc\smartd.8.txt"
343 File "${INPDIR}\doc\smartd.conf"
348 ;--------------------------------------------------------------------
352 ; Stop & remove service
353 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
354 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
356 ExecWait "net stop smartd"
357 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Remove smartd service ?" IDYES 0 IDNO nosrv
358 ExecWait "$INSTDIR\bin\smartd.exe remove"
361 ; Remove installer registry keys
362 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools"
363 DeleteRegKey HKLM "Software\smartmontools"
365 ; Remove conf and log file
366 IfFileExists "$INSTDIR\bin\smartd.conf" 0 noconf
367 ; Assume unchanged if timestamp is equal to sample file
368 GetFileTime "$INSTDIR\bin\smartd.conf" $0 $1
369 GetFileTime "$INSTDIR\doc\smartd.conf" $2 $3
370 StrCmp "$0:$1" "$2:$3" +2 0
371 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO noconf
372 Delete "$INSTDIR\bin\smartd.conf"
375 IfFileExists "$INSTDIR\bin\smartd.log" 0 +3
376 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete log file$\n$INSTDIR\bin\smartd.log ?" IDYES 0 IDNO +2
377 Delete "$INSTDIR\bin\smartd.log"
380 Delete "$INSTDIR\bin\smartctl.exe"
381 Delete "$INSTDIR\bin\smartd.exe"
382 Delete "$INSTDIR\bin\syslogevt.exe"
383 Delete "$INSTDIR\bin\smartctl-run.bat"
384 Delete "$INSTDIR\bin\smartd-run.bat"
385 Delete "$INSTDIR\bin\net-run.bat"
386 Delete "$INSTDIR\doc\AUTHORS.txt"
387 Delete "$INSTDIR\doc\CHANGELOG.txt"
388 Delete "$INSTDIR\doc\COPYING.txt"
389 Delete "$INSTDIR\doc\INSTALL.txt"
390 Delete "$INSTDIR\doc\NEWS.txt"
391 Delete "$INSTDIR\doc\README.txt"
392 Delete "$INSTDIR\doc\TODO.txt"
393 Delete "$INSTDIR\doc\WARNINGS.txt"
394 Delete "$INSTDIR\doc\smartctl.8.html"
395 Delete "$INSTDIR\doc\smartctl.8.txt"
396 Delete "$INSTDIR\doc\smartd.8.html"
397 Delete "$INSTDIR\doc\smartd.8.txt"
398 Delete "$INSTDIR\doc\smartd.conf"
399 Delete "$INSTDIR\doc\smartd.conf.5.html"
400 Delete "$INSTDIR\doc\smartd.conf.5.txt"
401 Delete "$INSTDIR\uninst-smartmontools.exe"
404 Delete "$SMPROGRAMS\smartmontools\*.*"
405 Delete "$SMPROGRAMS\smartmontools\Documentation\*.*"
406 Delete "$SMPROGRAMS\smartmontools\smartctl Examples\*.*"
407 Delete "$SMPROGRAMS\smartmontools\smartd Examples\*.*"
410 RMDir "$SMPROGRAMS\smartmontools\Documentation"
411 RMDir "$SMPROGRAMS\smartmontools\smartctl Examples"
412 RMDir "$SMPROGRAMS\smartmontools\smartd Examples"
413 RMDir "$SMPROGRAMS\smartmontools"
418 ; Remove install dir from PATH
419 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
421 Call un.RemoveFromPath
423 ; Remove drive menu registry entries
424 !insertmacro DriveMenuRemove
426 ; Check for still existing entries
427 IfFileExists "$INSTDIR\bin\smartd.exe" 0 +3
428 MessageBox MB_OK|MB_ICONEXCLAMATION "$INSTDIR\bin\smartd.exe could not be removed.$\nsmartd is possibly still running."
430 IfFileExists "$INSTDIR" 0 +2
431 MessageBox MB_OK "Note: $INSTDIR could not be removed."
433 IfFileExists "$SMPROGRAMS\smartmontools" 0 +2
434 MessageBox MB_OK "Note: $SMPROGRAMS\smartmontools could not be removed."
438 ;--------------------------------------------------------------------
443 ; Get UBCD4Win install location
444 ReadRegStr $0 HKLM "Software\UBCD4Win" "InstallPath"
446 StrCpy $0 "C:\UBCD4Win"
447 StrCpy $UBCDDIR "$0\plugin\Disk\Diagnostic\smartmontools"
449 ; Hide "Add install dir to PATH" on 9x/ME
450 IfFileExists "$WINDIR\system32\cmd.exe" +2 0
451 SectionSetText ${PATH_SECTION} ""
455 ; Directory page callbacks
457 !macro CheckSection section
458 SectionGetFlags ${section} $0
463 Function SkipProgPath
464 !insertmacro CheckSection ${SMARTCTL_SECTION}
465 !insertmacro CheckSection ${SMARTD_SECTION}
466 !insertmacro CheckSection ${DOC_SECTION}
467 !insertmacro CheckSection ${MENU_SECTION}
468 !insertmacro CheckSection ${PATH_SECTION}
469 !insertmacro CheckSection ${DRIVE_0_SECTION}
470 !insertmacro CheckSection ${DRIVE_1_SECTION}
471 !insertmacro CheckSection ${DRIVE_2_SECTION}
472 !insertmacro CheckSection ${DRIVE_3_SECTION}
473 !insertmacro CheckSection ${DRIVE_4_SECTION}
474 !insertmacro CheckSection ${DRIVE_5_SECTION}
479 Function SkipUBCDPath
480 !insertmacro CheckSection ${UBCD_SECTION}
486 ; Create smartctl-run.bat
488 Function CreateSmartctlBat
491 FileWrite $0 '@echo off$\r$\nif not "%1" == "" goto run$\r$\n'
492 FileWrite $0 'echo Examples (for first drive):$\r$\n'
493 FileWrite $0 'echo smartctl -i sda Show identify information$\r$\n'
494 FileWrite $0 'echo smartctl -H sda Show SMART health status$\r$\n'
495 FileWrite $0 'echo smartctl -c sda Show SMART capabilities$\r$\n'
496 FileWrite $0 'echo smartctl -A sda Show SMART attributes$\r$\n'
497 FileWrite $0 'echo smartctl -l error sda Show error log$\r$\n'
498 FileWrite $0 'echo smartctl -l selftest sda Show self-test log$\r$\n'
499 FileWrite $0 'echo smartctl -a sda Show all of the above$\r$\n'
500 FileWrite $0 'echo smartctl -t short sda Start short self test$\r$\n'
501 FileWrite $0 'echo smartctl -t long sda Start long self test$\r$\n'
502 FileWrite $0 'echo Use "sdb", "sdc", ... for second, third, ... drive.$\r$\n'
503 FileWrite $0 'echo See man page (smartctl.8.*) for further info.$\r$\n'
504 FileWrite $0 'goto end$\r$\n:run$\r$\n'
505 FileWrite $0 'echo smartctl %1 %2 %3 %4 %5$\r$\n'
506 FileWrite $0 'smartctl %1 %2 %3 %4 %5$\r$\n'
507 FileWrite $0 'pause$\r$\n:end$\r$\n'
513 ;--------------------------------------------------------------------
516 ; Based on example from:
517 ; http://nsis.sourceforge.net/Path_Manipulation
521 !include "WinMessages.nsh"
523 ; Registry Entry for environment (NT4,2000,XP)
525 ;!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
527 !define Environ 'HKCU "Environment"'
530 ; AddToPath - Appends dir to PATH
531 ; (does not work on Win9x/ME)
543 ReadRegStr $1 ${Environ} "PATH"
555 DetailPrint "Add to PATH: $0"
558 StrCpy $1 $1 -1 ; remove trailing ';'
559 StrCmp $1 "" +2 ; no leading ';'
561 WriteRegExpandStr ${Environ} "PATH" $0
562 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
572 ; RemoveFromPath - Removes dir from PATH
576 ; Call RemoveFromPath
578 Function un.RemoveFromPath
587 ReadRegStr $1 ${Environ} "PATH"
590 StrCpy $1 "$1;" ; ensure trailing ';'
594 Pop $2 ; pos of our dir
597 DetailPrint "Remove from PATH: $0"
600 StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove
601 StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
605 StrCpy $3 $3 -1 ; remove trailing ';'
606 WriteRegExpandStr ${Environ} "PATH" $3
607 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
620 ; StrStr - find substring in a string
623 ; Push "this is some string"
626 ; Pop $0 ; "some string"
630 Exch $R1 ; $R1=substring, stack=[old$R1,string,...]
631 Exch ; stack=[string,old$R1,...]
632 Exch $R2 ; $R2=string, stack=[old$R2,old$R1,...]
638 ; $R1=substring, $R2=string, $R3=strlen(substring)
641 StrCpy $R5 $R2 $R3 $R4
647 StrCpy $R1 $R2 "" $R4
652 Exch $R1 ; $R1=old$R1, stack=[result,...]
655 !insertmacro StrStr ""
656 !insertmacro StrStr "un."