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 3457 2011-10-20 16:36:47Z 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"
49 LicenseData "${INPDIR}\doc\COPYING.txt"
51 !include "FileFunc.nsh"
52 !include "Sections.nsh"
54 !insertmacro GetParameters
55 !insertmacro GetOptions
57 RequestExecutionLevel admin
59 ;--------------------------------------------------------------------
64 Page directory SkipProgPath "" ""
66 PageCallbacks SkipUBCDPath "" ""
67 DirText "Setup will install the UBCD4Win plugin in the following folder."
72 UninstPage uninstConfirm
76 InstType "Extract files only"
78 InstType "UBCD4Win plugin"
81 ;--------------------------------------------------------------------
84 SectionGroup "!Program files"
86 Section "smartctl" SMARTCTL_SECTION
90 SetOutPath "$INSTDIR\bin"
91 File "${INPDIR}\bin\smartctl.exe"
95 Section "smartd" SMARTD_SECTION
99 SetOutPath "$INSTDIR\bin"
103 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
104 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
106 ExecWait "net stop smartd" $1
108 File "${INPDIR}\bin\smartd.exe"
110 IfFileExists "$INSTDIR\bin\smartd.conf" 0 +2
111 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Replace existing configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO +2
112 File "${INPDIR}\doc\smartd.conf"
114 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
115 File /nonfatal "${INPDIR}\bin\syslogevt.exe"
119 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Restart smartd service ?" IDYES 0 IDNO +2
120 ExecWait "net start smartd"
124 Section "smartctl-nc (GSmartControl)" SMARTCTL_NC_SECTION
128 SetOutPath "$INSTDIR\bin"
129 File "${INPDIR}\bin\smartctl-nc.exe"
133 Section "drivedb.h (Drive Database)" DRIVEDB_SECTION
137 SetOutPath "$INSTDIR\bin"
138 File "${INPDIR}\bin\drivedb.h"
139 File "${INPDIR}\bin\update-smart-drivedb.exe"
145 Section "!Documentation" DOC_SECTION
149 SetOutPath "$INSTDIR\doc"
150 File "${INPDIR}\doc\AUTHORS.txt"
151 File "${INPDIR}\doc\CHANGELOG.txt"
152 File "${INPDIR}\doc\COPYING.txt"
153 File "${INPDIR}\doc\INSTALL.txt"
154 File "${INPDIR}\doc\NEWS.txt"
155 File "${INPDIR}\doc\README.txt"
156 File "${INPDIR}\doc\TODO.txt"
157 File "${INPDIR}\doc\WARNINGS.txt"
158 File "${INPDIR}\doc\checksums.txt"
159 File "${INPDIR}\doc\smartctl.8.html"
160 File "${INPDIR}\doc\smartctl.8.txt"
161 File "${INPDIR}\doc\smartd.8.html"
162 File "${INPDIR}\doc\smartd.8.txt"
163 File "${INPDIR}\doc\smartd.conf"
164 File "${INPDIR}\doc\smartd.conf.5.html"
165 File "${INPDIR}\doc\smartd.conf.5.txt"
169 Section "Uninstaller" UNINST_SECTION
174 CreateDirectory "$INSTDIR"
176 ; Save installation location
177 WriteRegStr HKLM "Software\smartmontools" "Install_Dir" "$INSTDIR"
179 ; Write uninstall keys and program
180 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayName" "smartmontools"
182 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayVersion" "${VERSTR}"
184 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "Publisher" "smartmontools"
185 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "UninstallString" '"$INSTDIR\uninst-smartmontools.exe"'
186 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLInfoAbout" "http://smartmontools.sourceforge.net/"
187 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "HelpLink" "http://smartmontools.sourceforge.net/"
188 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://sourceforge.net/project/showfiles.php?group_id=64297"
189 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://smartmontools-win32.dyndns.org/"
190 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoModify" 1
191 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoRepair" 1
192 WriteUninstaller "uninst-smartmontools.exe"
196 Section "Start Menu Shortcuts" MENU_SECTION
200 SetShellVarContext all
202 CreateDirectory "$SMPROGRAMS\smartmontools"
204 !macro CreateAdminShortCut link target args
205 CreateShortCut '${link}' '${target}' '${args}'
207 Call ShellLinkSetRunAs
211 IfFileExists "$INSTDIR\bin\smartctl.exe" 0 +2
212 IfFileExists "$INSTDIR\bin\smartd.exe" 0 +4
213 SetOutPath "$INSTDIR\bin"
214 File "${INPDIR}\bin\runcmdu.exe"
215 File "${INPDIR}\bin\runcmdu.exe.manifest"
218 IfFileExists "$INSTDIR\bin\smartctl.exe" 0 noctl
219 SetOutPath "$INSTDIR\bin"
220 IfFileExists "$WINDIR\system32\cmd.exe" 0 nocmd
221 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl (Admin CMD).lnk" "$WINDIR\system32\cmd.exe" '/k PATH=$INSTDIR\bin;%PATH%&cd /d "$INSTDIR\bin"'
223 CreateDirectory "$SMPROGRAMS\smartmontools\smartctl Examples"
224 FileOpen $0 "$SMPROGRAMS\smartmontools\smartctl Examples\!Read this first!.txt" "w"
225 FileWrite $0 "All the example commands in this directory$\r$\napply to the first drive (sda).$\r$\n"
227 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\All info (-a).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -a sda"
228 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Identify drive (-i).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -i sda"
229 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART attributes (-A).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -A sda"
230 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART capabilities (-c).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -c sda"
231 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART health status (-H).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -H sda"
232 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART error log (-l error).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -l error sda"
233 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART selftest log (-l selftest).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -l selftest sda"
234 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start long selftest (-t long).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -t long sda"
235 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start offline test (-t offline).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -t offline sda"
236 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start short selftest (-t short).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -t short sda"
237 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Stop(Abort) selftest (-X).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -X sda"
238 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART off (-s off).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -s off sda"
239 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART on (-s on).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -s on sda"
243 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nod
244 SetOutPath "$INSTDIR\bin"
245 CreateDirectory "$SMPROGRAMS\smartmontools\smartd Examples"
246 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, smartd.log.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd -l local0"
247 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, eventlog.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd"
248 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon stop.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd stop"
249 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Do all tests once (-q onecheck).lnk" "$INSTDIR\bin\runcmdu.exe" "smartd -q onecheck"
250 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Debug mode (-d).lnk" "$INSTDIR\bin\runcmdu.exe" "smartd -d"
251 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\smartd.conf (edit).lnk" "$EDITOR" "$INSTDIR\bin\smartd.conf"
252 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\smartd.conf (view).lnk" "$EDITOR" "$INSTDIR\bin\smartd.conf"
253 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\smartd.log (view).lnk" "$EDITOR" "$INSTDIR\bin\smartd.log"
255 ; smartd service (not on 9x/ME)
256 IfFileExists "$WINDIR\system32\cmd.exe" 0 nosvc
257 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, eventlog, 30min.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd install"
258 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 10min.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd install -l local0 -i 600"
259 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 30min.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd install -l local0"
260 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service remove.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd remove"
261 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service start.lnk" "$INSTDIR\bin\runcmdu.exe" "net start smartd"
262 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service stop.lnk" "$INSTDIR\bin\runcmdu.exe" "net stop smartd"
267 IfFileExists "$INSTDIR\doc\README.TXT" 0 nodoc
268 SetOutPath "$INSTDIR\doc"
269 CreateDirectory "$SMPROGRAMS\smartmontools\Documentation"
270 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (html).lnk" "$INSTDIR\doc\smartctl.8.html"
271 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (html).lnk" "$INSTDIR\doc\smartd.8.html"
272 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (html).lnk" "$INSTDIR\doc\smartd.conf.5.html"
273 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (txt).lnk" "$INSTDIR\doc\smartctl.8.txt"
274 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (txt).lnk" "$INSTDIR\doc\smartd.8.txt"
275 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (txt).lnk" "$INSTDIR\doc\smartd.conf.5.txt"
276 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$EDITOR" "$INSTDIR\doc\smartd.conf"
277 IfFileExists "$INSTDIR\bin\drivedb.h" 0 nodb
278 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb.h (view).lnk" "$EDITOR" "$INSTDIR\bin\drivedb.h"
279 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb-add.h (create, edit).lnk" "$EDITOR" "$INSTDIR\bin\drivedb-add.h"
281 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\AUTHORS.lnk" "$INSTDIR\doc\AUTHORS.txt"
282 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\CHANGELOG.lnk" "$INSTDIR\doc\CHANGELOG.txt"
283 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\COPYING.lnk" "$INSTDIR\doc\COPYING.txt"
284 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\INSTALL.lnk" "$INSTDIR\doc\INSTALL.txt"
285 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\NEWS.lnk" "$INSTDIR\doc\NEWS.txt"
286 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\README.lnk" "$INSTDIR\doc\README.txt"
287 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\TODO.lnk" "$INSTDIR\doc\TODO.txt"
288 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\WARNINGS.lnk" "$INSTDIR\doc\WARNINGS.txt"
289 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\Windows version download page.lnk" "http://smartmontools-win32.dyndns.org/smartmontools/"
293 CreateShortCut "$SMPROGRAMS\smartmontools\smartmontools Home Page.lnk" "http://smartmontools.sourceforge.net/"
296 IfFileExists "$INSTDIR\bin\update-smart-drivedb.exe" 0 noupdb
297 SetOutPath "$INSTDIR\bin"
298 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\drivedb.h update.lnk" "$INSTDIR\bin\update-smart-drivedb.exe" ""
302 IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 noinst
303 SetOutPath "$INSTDIR"
304 !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe" ""
309 Section "Add install dir to PATH" PATH_SECTION
313 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
319 SectionGroup "Add smartctl to drive menu"
321 !macro DriveMenuRemove
322 DetailPrint "Remove drive menu entries"
323 DeleteRegKey HKCR "Drive\shell\smartctl0"
324 DeleteRegKey HKCR "Drive\shell\smartctl1"
325 DeleteRegKey HKCR "Drive\shell\smartctl2"
326 DeleteRegKey HKCR "Drive\shell\smartctl3"
327 DeleteRegKey HKCR "Drive\shell\smartctl4"
328 DeleteRegKey HKCR "Drive\shell\smartctl5"
331 Section "Remove existing entries first" DRIVE_REMOVE_SECTION
333 !insertmacro DriveMenuRemove
336 !macro DriveSection id name args
337 Section 'smartctl ${args} ...' DRIVE_${id}_SECTION
340 DetailPrint 'Add drive menu entry "${name}": smartctl ${args} ...'
341 WriteRegStr HKCR "Drive\shell\smartctl${id}" "" "${name}"
342 WriteRegStr HKCR "Drive\shell\smartctl${id}\command" "" '"$INSTDIR\bin\runcmda.exe" "$INSTDIR\bin\smartctl.exe" ${args} %L'
346 !insertmacro DriveSection 0 "SMART all info" "-a"
347 !insertmacro DriveSection 1 "SMART status" "-Hc"
348 !insertmacro DriveSection 2 "SMART attributes" "-A"
349 !insertmacro DriveSection 3 "SMART short selftest" "-t short"
350 !insertmacro DriveSection 4 "SMART long selftest" "-t long"
351 !insertmacro DriveSection 5 "SMART continue selective selftest" '-t "selective,cont"'
355 Section "UBCD4Win Plugin" UBCD_SECTION
359 SetOutPath "$UBCDDIR"
360 DetailPrint "Create file: smartmontools.inf"
361 FileOpen $0 "$UBCDDIR\smartmontools.inf" "w"
362 FileWrite $0 '; smartmontools.inf$\r$\n; PE Builder v3 plug-in INF file$\r$\n'
363 FileWrite $0 '; Created by smartmontools installer$\r$\n'
364 FileWrite $0 '; http://smartmontools.sourceforge.net/$\r$\n$\r$\n'
365 FileWrite $0 '[Version]$\r$\nSignature= "$$Windows NT$$"$\r$\n$\r$\n'
366 FileWrite $0 '[PEBuilder]$\r$\nName="Disk -Diagnostic: smartmontools"$\r$\n'
367 FileWrite $0 'Enable=1$\r$\nHelp="files\smartctl.8.html"$\r$\n$\r$\n'
368 FileWrite $0 '[WinntDirectories]$\r$\na=Programs\smartmontools,2$\r$\n$\r$\n'
369 FileWrite $0 '[SourceDisksFolders]$\r$\nfiles=a,,1$\r$\n$\r$\n'
370 FileWrite $0 '[Append]$\r$\nnu2menu.xml, smartmontools_nu2menu.xml$\r$\n'
373 DetailPrint "Create file: smartmontools_nu2menu.xml"
374 FileOpen $0 "$UBCDDIR\smartmontools_nu2menu.xml" "w"
375 FileWrite $0 '<!-- Nu2Menu entry for smartmontools -->$\r$\n<NU2MENU>$\r$\n'
376 FileWrite $0 '$\t<MENU ID="Programs">$\r$\n$\t$\t<MITEM TYPE="POPUP" MENUID="Disk Tools">'
377 FileWrite $0 'Disk Tools</MITEM>$\r$\n$\t</MENU>$\r$\n$\t<MENU ID="Disk Tools">$\r$\n'
378 FileWrite $0 '$\t$\t<MITEM TYPE="POPUP" MENUID="Diagnostic">Diagnostic</MITEM>$\r$\n$\t</MENU>'
379 FileWrite $0 '$\r$\n$\t<MENU ID="Diagnostic">$\r$\n$\t$\t<MITEM TYPE="ITEM" DISABLED="'
380 FileWrite $0 '@Not(@FileExists(@GetProgramDrive()\Programs\smartmontools\smartctl.exe))" '
381 FileWrite $0 'CMD="RUN" FUNC="cmd.exe /k cd /d @GetProgramDrive()\Programs\smartmontools&'
382 FileWrite $0 'set PATH=@GetProgramDrive()\Programs\smartmontools;%PATH% ">'
383 FileWrite $0 'smartctl</MITEM>$\r$\n$\t</MENU>$\r$\n</NU2MENU>$\r$\n'
386 SetOutPath "$UBCDDIR\files"
387 File "${INPDIR}\bin\smartctl.exe"
388 File "${INPDIR}\bin\smartd.exe"
389 File "${INPDIR}\doc\smartctl.8.html"
390 File "${INPDIR}\doc\smartctl.8.txt"
391 File "${INPDIR}\doc\smartd.8.html"
392 File "${INPDIR}\doc\smartd.8.txt"
393 File "${INPDIR}\doc\smartd.conf"
398 ;--------------------------------------------------------------------
402 ; Stop & remove service
403 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
404 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
406 ExecWait "net stop smartd"
407 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Remove smartd service ?" IDYES 0 IDNO nosrv
408 ExecWait "$INSTDIR\bin\smartd.exe remove"
411 ; Remove installer registry keys
412 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools"
413 DeleteRegKey HKLM "Software\smartmontools"
416 IfFileExists "$INSTDIR\bin\smartd.conf" 0 noconf
417 ; Assume unchanged if timestamp is equal to sample file
418 GetFileTime "$INSTDIR\bin\smartd.conf" $0 $1
419 GetFileTime "$INSTDIR\doc\smartd.conf" $2 $3
420 StrCmp "$0:$1" "$2:$3" +2 0
421 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO noconf
422 Delete "$INSTDIR\bin\smartd.conf"
426 IfFileExists "$INSTDIR\bin\smartd.log" 0 +3
427 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete log file$\n$INSTDIR\bin\smartd.log ?" IDYES 0 IDNO +2
428 Delete "$INSTDIR\bin\smartd.log"
430 ; Remove drivedb-add file ?
431 IfFileExists "$INSTDIR\bin\drivedb-add.h" 0 +3
432 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete local drive database file$\n$INSTDIR\bin\drivedb-add.h ?" IDYES 0 IDNO +2
433 Delete "$INSTDIR\bin\drivedb-add.h"
436 Delete "$INSTDIR\bin\smartctl.exe"
437 Delete "$INSTDIR\bin\smartctl-nc.exe"
438 Delete "$INSTDIR\bin\smartd.exe"
439 Delete "$INSTDIR\bin\syslogevt.exe"
440 Delete "$INSTDIR\bin\drivedb.h"
441 Delete "$INSTDIR\bin\drivedb.h.error"
442 Delete "$INSTDIR\bin\drivedb.h.lastcheck"
443 Delete "$INSTDIR\bin\drivedb.h.old"
444 Delete "$INSTDIR\bin\update-smart-drivedb.exe"
445 Delete "$INSTDIR\bin\smartctl-run.bat"
446 Delete "$INSTDIR\bin\smartd-run.bat"
447 Delete "$INSTDIR\bin\net-run.bat"
448 Delete "$INSTDIR\bin\runcmda.exe"
449 Delete "$INSTDIR\bin\runcmda.exe.manifest"
450 Delete "$INSTDIR\bin\runcmdu.exe"
451 Delete "$INSTDIR\bin\runcmdu.exe.manifest"
452 Delete "$INSTDIR\doc\AUTHORS.txt"
453 Delete "$INSTDIR\doc\CHANGELOG.txt"
454 Delete "$INSTDIR\doc\COPYING.txt"
455 Delete "$INSTDIR\doc\INSTALL.txt"
456 Delete "$INSTDIR\doc\NEWS.txt"
457 Delete "$INSTDIR\doc\README.txt"
458 Delete "$INSTDIR\doc\TODO.txt"
459 Delete "$INSTDIR\doc\WARNINGS.txt"
460 Delete "$INSTDIR\doc\checksums.txt"
461 Delete "$INSTDIR\doc\smartctl.8.html"
462 Delete "$INSTDIR\doc\smartctl.8.txt"
463 Delete "$INSTDIR\doc\smartd.8.html"
464 Delete "$INSTDIR\doc\smartd.8.txt"
465 Delete "$INSTDIR\doc\smartd.conf"
466 Delete "$INSTDIR\doc\smartd.conf.5.html"
467 Delete "$INSTDIR\doc\smartd.conf.5.txt"
468 Delete "$INSTDIR\uninst-smartmontools.exe"
471 SetShellVarContext all
472 Delete "$SMPROGRAMS\smartmontools\*.*"
473 Delete "$SMPROGRAMS\smartmontools\Documentation\*.*"
474 Delete "$SMPROGRAMS\smartmontools\smartctl Examples\*.*"
475 Delete "$SMPROGRAMS\smartmontools\smartd Examples\*.*"
478 RMDir "$SMPROGRAMS\smartmontools\Documentation"
479 RMDir "$SMPROGRAMS\smartmontools\smartctl Examples"
480 RMDir "$SMPROGRAMS\smartmontools\smartd Examples"
481 RMDir "$SMPROGRAMS\smartmontools"
486 ; Remove install dir from PATH
487 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
489 Call un.RemoveFromPath
491 ; Remove drive menu registry entries
492 !insertmacro DriveMenuRemove
494 ; Check for still existing entries
495 IfFileExists "$INSTDIR\bin\smartd.exe" 0 +3
496 MessageBox MB_OK|MB_ICONEXCLAMATION "$INSTDIR\bin\smartd.exe could not be removed.$\nsmartd is possibly still running."
498 IfFileExists "$INSTDIR" 0 +2
499 MessageBox MB_OK "Note: $INSTDIR could not be removed."
501 IfFileExists "$SMPROGRAMS\smartmontools" 0 +2
502 MessageBox MB_OK "Note: $SMPROGRAMS\smartmontools could not be removed."
506 ;--------------------------------------------------------------------
511 ; Use Notepad++ if installed
512 StrCpy $EDITOR "$PROGRAMFILES\Notepad++\notepad++.exe"
513 IfFileExists "$EDITOR" +2 0
514 StrCpy $EDITOR "notepad.exe"
516 ; Get UBCD4Win install location
517 ReadRegStr $0 HKLM "Software\UBCD4Win" "InstallPath"
519 StrCpy $0 "C:\UBCD4Win"
520 StrCpy $UBCDDIR "$0\plugin\Disk\Diagnostic\smartmontools"
522 ; Hide "Add install dir to PATH" on 9x/ME
523 IfFileExists "$WINDIR\system32\cmd.exe" +2 0
524 SectionSetText ${PATH_SECTION} ""
529 ; Command line parsing
530 !macro CheckCmdLineOption name section
531 StrCpy $allopts "$allopts,${name}"
536 StrCmp $0 "" 0 sel_${name}
537 !insertmacro UnselectSection ${section}
540 !insertmacro SelectSection ${section}
545 Function ParseCmdLine
549 ${GetOptions} $R0 "/SO" $opts
556 ; turn sections on or off
557 !insertmacro CheckCmdLineOption "smartctl" ${SMARTCTL_SECTION}
558 !insertmacro CheckCmdLineOption "smartd" ${SMARTD_SECTION}
559 !insertmacro CheckCmdLineOption "smartctlnc" ${SMARTCTL_NC_SECTION}
560 !insertmacro CheckCmdLineOption "drivedb" ${DRIVEDB_SECTION}
561 !insertmacro CheckCmdLineOption "doc" ${DOC_SECTION}
562 !insertmacro CheckCmdLineOption "uninst" ${UNINST_SECTION}
563 !insertmacro CheckCmdLineOption "menu" ${MENU_SECTION}
564 !insertmacro CheckCmdLineOption "path" ${PATH_SECTION}
565 !insertmacro CheckCmdLineOption "driveremove" ${DRIVE_REMOVE_SECTION}
566 !insertmacro CheckCmdLineOption "drive0" ${DRIVE_0_SECTION}
567 !insertmacro CheckCmdLineOption "drive1" ${DRIVE_1_SECTION}
568 !insertmacro CheckCmdLineOption "drive2" ${DRIVE_2_SECTION}
569 !insertmacro CheckCmdLineOption "drive3" ${DRIVE_3_SECTION}
570 !insertmacro CheckCmdLineOption "drive4" ${DRIVE_4_SECTION}
571 !insertmacro CheckCmdLineOption "drive5" ${DRIVE_5_SECTION}
572 !insertmacro CheckCmdLineOption "ubcd" ${UBCD_SECTION}
573 StrCmp $opts "-" done
574 StrCmp $nomatch "" done
575 StrCpy $0 "$allopts,-" "" 1
576 MessageBox MB_OK "Usage: smartmontools-VERSION.win32-setup [/S] [/SO component,...] [/D=INSTDIR]$\n$\ncomponents:$\n $0"
581 ; Directory page callbacks
583 !macro CheckSection section
584 SectionGetFlags ${section} $0
589 Function SkipProgPath
590 !insertmacro CheckSection ${SMARTCTL_SECTION}
591 !insertmacro CheckSection ${SMARTCTL_NC_SECTION}
592 !insertmacro CheckSection ${SMARTD_SECTION}
593 !insertmacro CheckSection ${DRIVEDB_SECTION}
594 !insertmacro CheckSection ${DOC_SECTION}
595 !insertmacro CheckSection ${MENU_SECTION}
596 !insertmacro CheckSection ${PATH_SECTION}
597 !insertmacro CheckSection ${DRIVE_0_SECTION}
598 !insertmacro CheckSection ${DRIVE_1_SECTION}
599 !insertmacro CheckSection ${DRIVE_2_SECTION}
600 !insertmacro CheckSection ${DRIVE_3_SECTION}
601 !insertmacro CheckSection ${DRIVE_4_SECTION}
602 !insertmacro CheckSection ${DRIVE_5_SECTION}
607 Function SkipUBCDPath
608 !insertmacro CheckSection ${UBCD_SECTION}
614 ; Install runcmda.exe if missing
616 Function CheckRunCmdA
617 IfFileExists "$INSTDIR\bin\runcmda.exe" done 0
618 SetOutPath "$INSTDIR\bin"
619 File "${INPDIR}\bin\runcmda.exe"
620 File "${INPDIR}\bin\runcmda.exe.manifest"
625 ;--------------------------------------------------------------------
628 ; Based on example from:
629 ; http://nsis.sourceforge.net/Path_Manipulation
633 !include "WinMessages.nsh"
635 ; Registry Entry for environment (NT4,2000,XP)
637 ;!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
639 !define Environ 'HKCU "Environment"'
642 ; AddToPath - Appends dir to PATH
643 ; (does not work on Win9x/ME)
655 ReadRegStr $1 ${Environ} "PATH"
667 DetailPrint "Add to PATH: $0"
670 StrCpy $1 $1 -1 ; remove trailing ';'
671 StrCmp $1 "" +2 ; no leading ';'
673 WriteRegExpandStr ${Environ} "PATH" $0
674 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
684 ; RemoveFromPath - Removes dir from PATH
688 ; Call RemoveFromPath
690 Function un.RemoveFromPath
699 ReadRegStr $1 ${Environ} "PATH"
702 StrCpy $1 "$1;" ; ensure trailing ';'
706 Pop $2 ; pos of our dir
709 DetailPrint "Remove from PATH: $0"
712 StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove
713 StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
717 StrCpy $3 $3 -1 ; remove trailing ';'
718 WriteRegExpandStr ${Environ} "PATH" $3
719 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
732 ; StrStr - find substring in a string
735 ; Push "this is some string"
738 ; Pop $0 ; "some string"
742 Exch $R1 ; $R1=substring, stack=[old$R1,string,...]
743 Exch ; stack=[string,old$R1,...]
744 Exch $R2 ; $R2=string, stack=[old$R2,old$R1,...]
750 ; $R1=substring, $R2=string, $R3=strlen(substring)
753 StrCpy $R5 $R2 $R3 $R4
759 StrCpy $R1 $R2 "" $R4
764 Exch $R1 ; $R1=old$R1, stack=[result,...]
767 !insertmacro StrStr ""
768 !insertmacro StrStr "un."
771 ;--------------------------------------------------------------------
772 ; Set Run As Administrator flag in shortcut
774 ; Slightly modified version from:
775 ; http://nsis.sourceforge.net/IShellLink_Set_RunAs_flag
778 !include "LogicLib.nsh"
780 !define IPersistFile {0000010b-0000-0000-c000-000000000046}
781 !define CLSID_ShellLink {00021401-0000-0000-C000-000000000046}
782 !define IID_IShellLinkA {000214EE-0000-0000-C000-000000000046}
783 !define IID_IShellLinkW {000214F9-0000-0000-C000-000000000046}
784 !define IShellLinkDataList {45e2b4ae-b1c3-11d0-b92f-00a0c90312e1}
786 !define IID_IShellLink ${IID_IShellLinkW}
788 !define IID_IShellLink ${IID_IShellLinkA}
791 Function ShellLinkSetRunAs
792 System::Store S ; push $0-$9, $R0-$R9
794 ; $0 = CoCreateInstance(CLSID_ShellLink, 0, CLSCTX_INPROC_SERVER, IID_IShellLink, &$1)
795 System::Call "ole32::CoCreateInstance(g'${CLSID_ShellLink}',i0,i1,g'${IID_IShellLink}',*i.r1)i.r0"
797 System::Call "$1->0(g'${IPersistFile}',*i.r2)i.r0" ; $0 = $1->QueryInterface(IPersistFile, &$2)
799 System::Call "$2->5(w '$9',i 0)i.r0" ; $0 = $2->Load($9, STGM_READ)
801 System::Call "$1->0(g'${IShellLinkDataList}',*i.r3)i.r0" ; $0 = $1->QueryInterface(IShellLinkDataList, &$3)
803 System::Call "$3->6(*i.r4)i.r0"; $0 = $3->GetFlags(&$4)
805 System::Call "$3->7(i $4|0x2000)i.r0" ; $0 = $3->SetFlags($4|SLDF_RUNAS_USER)
807 System::Call "$2->6(w '$9',i1)i.r0" ; $2->Save($9, TRUE)
810 System::Call "$3->2()" ; $3->Release()
812 System::Call "$2->2()" ; $2->Release()
815 System::Call "$1->2()" ; $1->Release()
818 DetailPrint "Set RunAsAdmin: $9 failed ($0)"
820 DetailPrint "Set RunAsAdmin: $9"
822 System::Store L ; push $0-$9, $R0-$R9