📄 installer.nsi
字号:
;; installer.nsi - NSIS install script for smartmontools;; Copyright (C) 2006-8 Christian Franke <smartmontools-support@lists.sourceforge.net>;; Project home page is: http://smartmontools.sourceforge.net;; Download and install NSIS from: http://nsis.sourceforge.net/Download; Process with makensis to create installer (tested with NSIS 2.29);; $Id: installer.nsi,v 1.4 2008/03/04 22:09:48 ballen4705 Exp $;;--------------------------------------------------------------------; Command line arguments:; makensis /DINPDIR=<input-dir> /DOUTFILE=<output-file> installer.nsi!ifndef INPDIR !define INPDIR "."!endif!ifndef OUTFILE !define OUTFILE "smartmontools.win32-setup.exe"!endif;--------------------------------------------------------------------; GeneralName "smartmontools"OutFile "${OUTFILE}"SetCompressor /solid lzmaXPStyle onInstallColors /windowsInstallDir "$PROGRAMFILES\smartmontools"InstallDirRegKey HKLM "Software\smartmontools" "Install_Dir"Var UBCDDIRLicenseData "${INPDIR}\doc\COPYING.txt";--------------------------------------------------------------------; PagesPage licensePage componentsPage directory SkipProgPath "" ""PageEx directory PageCallbacks SkipUBCDPath "" "" DirText "Setup will install the UBCD4Win plugin in the following folder." DirVar $UBCDDIRPageExEndPage instfilesUninstPage uninstConfirmUninstPage instfilesInstType "Full"InstType "Extract files only"InstType "Drive menu"InstType "UBCD4Win plugin";--------------------------------------------------------------------; SectionsSectionGroup "!Program files" Section "smartctl" SMARTCTL_SECTION SectionIn 1 2 SetOutPath "$INSTDIR\bin" File "${INPDIR}\bin\smartctl.exe" SectionEnd Section "smartd" SMARTD_SECTION SectionIn 1 2 SetOutPath "$INSTDIR\bin" ; Stop service ? StrCpy $1 "" IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath" StrCmp $0 "" nosrv ExecWait "net stop smartd" $1 nosrv: File "${INPDIR}\bin\smartd.exe" IfFileExists "$INSTDIR\bin\smartd.conf" 0 +2 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Replace existing configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO +2 File "${INPDIR}\doc\smartd.conf" IfFileExists "$WINDIR\system32\cmd.exe" 0 +2 File /nonfatal "${INPDIR}\bin\syslogevt.exe" ; Restart service ? StrCmp $1 "0" 0 +3 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Restart smartd service ?" IDYES 0 IDNO +2 ExecWait "net start smartd" SectionEndSectionGroupEndSection "!Documentation" DOC_SECTION SectionIn 1 2 SetOutPath "$INSTDIR\doc" File "${INPDIR}\doc\AUTHORS.txt" File "${INPDIR}\doc\CHANGELOG.txt" File "${INPDIR}\doc\COPYING.txt" File "${INPDIR}\doc\INSTALL.txt" File "${INPDIR}\doc\NEWS.txt" File "${INPDIR}\doc\README.txt" File "${INPDIR}\doc\TODO.txt" File "${INPDIR}\doc\WARNINGS.txt" File "${INPDIR}\doc\smartctl.8.html" File "${INPDIR}\doc\smartctl.8.txt" File "${INPDIR}\doc\smartd.8.html" File "${INPDIR}\doc\smartd.8.txt" File "${INPDIR}\doc\smartd.conf" File "${INPDIR}\doc\smartd.conf.5.html" File "${INPDIR}\doc\smartd.conf.5.txt"SectionEndSection "Uninstaller" UNINST_SECTION SectionIn 1 AddSize 35 CreateDirectory "$INSTDIR" ; Save installation location WriteRegStr HKLM "Software\smartmontools" "Install_Dir" "$INSTDIR" ; Write uninstall keys and program WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayName" "smartmontools" ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "Publisher" "smartmontools" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "UninstallString" '"$INSTDIR\uninst-smartmontools.exe"' ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLInfoAbout" "http://smartmontools.sourceforge.net/" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "HelpLink" "http://smartmontools.sourceforge.net/" ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://sourceforge.net/project/showfiles.php?group_id=64297" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://smartmontools-win32.dyndns.org/" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoRepair" 1 WriteUninstaller "uninst-smartmontools.exe"SectionEndSection "Start Menu Shortcuts" MENU_SECTION SectionIn 1 CreateDirectory "$SMPROGRAMS\smartmontools" ; smartctl IfFileExists "$INSTDIR\bin\smartctl.exe" 0 noctl SetOutPath "$INSTDIR\bin" DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat" Push "$INSTDIR\bin\smartctl-run.bat" Call CreateSmartctlBat IfFileExists "$WINDIR\system32\cmd.exe" 0 +2 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl (CMD).lnk" "cmd.exe" "/k smartctl-run.bat" CreateDirectory "$SMPROGRAMS\smartmontools\smartctl Examples" FileOpen $0 "$SMPROGRAMS\smartmontools\smartctl Examples\!Read this first!.txt" "w" FileWrite $0 "All the example commands in this directory$\r$\napply to the first drive (sda).$\r$\n" FileClose $0 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\All info (-a).lnk" "$INSTDIR\bin\smartctl-run.bat" "-a sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Identify drive (-i).lnk" "$INSTDIR\bin\smartctl-run.bat" "-i sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART attributes (-A).lnk" "$INSTDIR\bin\smartctl-run.bat" "-A sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART capabilities (-c).lnk" "$INSTDIR\bin\smartctl-run.bat" "-c sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART health status (-H).lnk" "$INSTDIR\bin\smartctl-run.bat" "-H sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART error log (-l error).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l error sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART selftest log (-l selftest).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l selftest sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start long selftest (-t long).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t long sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start offline test (-t offline).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t offline sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start short selftest (-t short).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t short sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Stop(Abort) selftest (-X).lnk" "$INSTDIR\bin\smartctl-run.bat" "-X sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART off (-s off).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s off sda" CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART on (-s on).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s on sda" noctl: ; smartd IfFileExists "$INSTDIR\bin\smartd.exe" 0 nod SetOutPath "$INSTDIR\bin" DetailPrint "Create file: $INSTDIR\bin\smartd-run.bat" FileOpen $0 "$INSTDIR\bin\smartd-run.bat" "w" FileWrite $0 "@echo off$\r$\necho smartd %1 %2 %3 %4 %5$\r$\nsmartd %1 %2 %3 %4 %5$\r$\npause$\r$\n" FileClose $0 CreateDirectory "$SMPROGRAMS\smartmontools\smartd Examples" CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, smartd.log.lnk" "$INSTDIR\bin\smartd-run.bat" "-l local0" IfFileExists "$WINDIR\system32\cmd.exe" 0 +2 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, eventlog.lnk" "$INSTDIR\bin\smartd-run.bat" "" CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon stop.lnk" "$INSTDIR\bin\smartd-run.bat" "stop" CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Do all tests once (-q onecheck).lnk" "$INSTDIR\bin\smartd-run.bat" "-q onecheck" CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Debug mode (-d).lnk" "$INSTDIR\bin\smartd-run.bat" "-d" IfFileExists "$WINDIR\notepad.exe" 0 nopad CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Edit smartd.conf.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.conf" CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\View smartd.log.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.log" nopad: ; smartd service (not on 9x/ME) IfFileExists "$WINDIR\system32\cmd.exe" 0 nosvc CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, eventlog, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install" CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 10min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0 -i 600" CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0" CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service remove.lnk" "$INSTDIR\bin\smartd-run.bat" "remove" DetailPrint "Create file: $INSTDIR\bin\net-run.bat" FileOpen $0 "$INSTDIR\bin\net-run.bat" "w" FileWrite $0 "@echo off$\r$\necho net %1 %2 %3 %4 %5$\r$\nnet %1 %2 %3 %4 %5$\r$\npause$\r$\n" FileClose $0 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service start.lnk" "$INSTDIR\bin\net-run.bat" "start smartd" CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service stop.lnk" "$INSTDIR\bin\net-run.bat" "stop smartd" nosvc: nod: ; Documentation IfFileExists "$INSTDIR\doc\README.TXT" 0 nodoc SetOutPath "$INSTDIR\doc" CreateDirectory "$SMPROGRAMS\smartmontools\Documentation" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (html).lnk" "$INSTDIR\doc\smartctl.8.html" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (html).lnk" "$INSTDIR\doc\smartd.8.html" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (html).lnk" "$INSTDIR\doc\smartd.conf.5.html" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (txt).lnk" "$INSTDIR\doc\smartctl.8.txt" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (txt).lnk" "$INSTDIR\doc\smartd.8.txt" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (txt).lnk" "$INSTDIR\doc\smartd.conf.5.txt" IfFileExists "$WINDIR\notepad.exe" 0 +2 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$WINDIR\notepad.exe" "$INSTDIR\doc\smartd.conf" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\AUTHORS.lnk" "$INSTDIR\doc\AUTHORS.txt" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\CHANGELOG.lnk" "$INSTDIR\doc\CHANGELOG.txt" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\COPYING.lnk" "$INSTDIR\doc\COPYING.txt" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\INSTALL.lnk" "$INSTDIR\doc\INSTALL.txt" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\NEWS.lnk" "$INSTDIR\doc\NEWS.txt" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\README.lnk" "$INSTDIR\doc\README.txt" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\TODO.lnk" "$INSTDIR\doc\TODO.txt" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\WARNINGS.lnk" "$INSTDIR\doc\WARNINGS.txt" CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\Windows version download page.lnk" "http://smartmontools-win32.dyndns.org/smartmontools/" nodoc: ; Homepage CreateShortCut "$SMPROGRAMS\smartmontools\smartmontools Home Page.lnk" "http://smartmontools.sourceforge.net/" ; Uninstall IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 +2 CreateShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe"SectionEndSection "Add install dir to PATH" PATH_SECTION SectionIn 1 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3 Push "$INSTDIR\bin" Call AddToPath SectionEndSectionGroup "Add smartctl to drive menu"!macro DriveMenuRemove DetailPrint "Remove drive menu entries" DeleteRegKey HKCR "Drive\shell\smartctl0" DeleteRegKey HKCR "Drive\shell\smartctl1" DeleteRegKey HKCR "Drive\shell\smartctl2" DeleteRegKey HKCR "Drive\shell\smartctl3" DeleteRegKey HKCR "Drive\shell\smartctl4" DeleteRegKey HKCR "Drive\shell\smartctl5"!macroend Section "Remove existing entries first" SectionIn 3 !insertmacro DriveMenuRemove SectionEnd!macro DriveSection id name args Section 'smartctl ${args} ...' DRIVE_${id}_SECTION SectionIn 3 DetailPrint 'Add drive menu entry "${name}": smartctl ${args} ...' WriteRegStr HKCR "Drive\shell\smartctl${id}" "" "${name}" WriteRegStr HKCR "Drive\shell\smartctl${id}\command" "" '"$INSTDIR\bin\smartctl-run.bat" ${args} %L' SectionEnd!macroend !insertmacro DriveSection 0 "SMART all info" "-a" !insertmacro DriveSection 1 "SMART status" "-Hc" !insertmacro DriveSection 2 "SMART attributes" "-A" !insertmacro DriveSection 3 "SMART short selftest" "-t short" !insertmacro DriveSection 4 "SMART long selftest" "-t long" !insertmacro DriveSection 5 "SMART continue selective selftest" '-t "selective,cont"'SectionGroupEndSection "UBCD4Win Plugin" UBCD_SECTION SectionIn 4 SetOutPath "$UBCDDIR" DetailPrint "Create file: smartmontools.inf" FileOpen $0 "$UBCDDIR\smartmontools.inf" "w" FileWrite $0 '; smartmontools.inf$\r$\n; PE Builder v3 plug-in INF file$\r$\n' FileWrite $0 '; Created by smartmontools installer$\r$\n' FileWrite $0 '; http://smartmontools.sourceforge.net/$\r$\n$\r$\n' FileWrite $0 '[Version]$\r$\nSignature= "$$Windows NT$$"$\r$\n$\r$\n' FileWrite $0 '[PEBuilder]$\r$\nName="Disk -Diagnostic: smartmontools"$\r$\n' FileWrite $0 'Enable=1$\r$\nHelp="files\smartctl.8.html"$\r$\n$\r$\n' FileWrite $0 '[WinntDirectories]$\r$\na=Programs\smartmontools,2$\r$\n$\r$\n' FileWrite $0 '[SourceDisksFolders]$\r$\nfiles=a,,1$\r$\n$\r$\n' FileWrite $0 '[Append]$\r$\nnu2menu.xml, smartmontools_nu2menu.xml$\r$\n' FileClose $0 DetailPrint "Create file: smartmontools_nu2menu.xml" FileOpen $0 "$UBCDDIR\smartmontools_nu2menu.xml" "w" FileWrite $0 '<!-- Nu2Menu entry for smartmontools -->$\r$\n<NU2MENU>$\r$\n' FileWrite $0 '$\t<MENU ID="Programs">$\r$\n$\t$\t<MITEM TYPE="POPUP" MENUID="Disk Tools">' FileWrite $0 'Disk Tools</MITEM>$\r$\n$\t</MENU>$\r$\n$\t<MENU ID="Disk Tools">$\r$\n' FileWrite $0 '$\t$\t<MITEM TYPE="POPUP" MENUID="Diagnostic">Diagnostic</MITEM>$\r$\n$\t</MENU>' FileWrite $0 '$\r$\n$\t<MENU ID="Diagnostic">$\r$\n$\t$\t<MITEM TYPE="ITEM" DISABLED="' FileWrite $0 '@Not(@FileExists(@GetProgramDrive()\Programs\smartmontools\smartctl.exe))" ' FileWrite $0 'CMD="RUN" FUNC="cmd.exe /k cd /d @GetProgramDrive()\Programs\smartmontools&' FileWrite $0 'set PATH=@GetProgramDrive()\Programs\smartmontools;%PATH%&smartctl-run.bat ">'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -