]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - os_win32/installer.nsi
Imported Upstream version 5.42+svn3561
[mirror_smartmontools-debian.git] / os_win32 / installer.nsi
index 74c02f23ddf5368308f99af69ad9ec8eeed2294d..d918ac6fd7726a05971fcf5ff40123fbeb8618df 100644 (file)
@@ -3,7 +3,7 @@
 ;
 ; Home page of code is: http://smartmontools.sourceforge.net
 ;
-; Copyright (C) 2006-11 Christian Franke <smartmontools-support@lists.sourceforge.net>
+; Copyright (C) 2006-12 Christian Franke <smartmontools-support@lists.sourceforge.net>
 ;
 ; This program is free software; you can redistribute it and/or modify
 ; it under the terms of the GNU General Public License as published by
 ; You should have received a copy of the GNU General Public License
 ; (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
 ;
-; $Id: installer.nsi 3298 2011-03-22 18:36:44Z chrfranke $
+; $Id: installer.nsi 3545 2012-05-25 21:19:03Z chrfranke $
 ;
 
 
 ;--------------------------------------------------------------------
 ; Command line arguments:
-; makensis -DINPDIR=<input-dir> -DOUTFILE=<output-file> -DVERSTR=<version-string> installer.nsi
+; makensis -DINPDIR=<input-dir> -DINPDIR64=<input-dir-64-bit> \
+;   -DOUTFILE=<output-file> -DVERSTR=<version-string> installer.nsi
 
 !ifndef INPDIR
   !define INPDIR "."
@@ -40,9 +41,17 @@ SetCompressor /solid lzma
 XPStyle on
 InstallColors /windows
 
-InstallDir "$PROGRAMFILES\smartmontools"
-InstallDirRegKey HKLM "Software\smartmontools" "Install_Dir"
-Var UBCDDIR
+; Set in .onInit
+;InstallDir "$PROGRAMFILES\smartmontools"
+;InstallDirRegKey HKLM "Software\smartmontools" "Install_Dir"
+
+Var EDITOR
+
+!ifdef INPDIR64
+  Var X64
+  Var INSTDIR32
+  Var INSTDIR64
+!endif
 
 LicenseData "${INPDIR}\doc\COPYING.txt"
 
@@ -59,12 +68,11 @@ RequestExecutionLevel admin
 
 Page license
 Page components
-Page directory SkipProgPath "" ""
-PageEx directory
-  PageCallbacks SkipUBCDPath "" ""
-  DirText "Setup will install the UBCD4Win plugin in the following folder."
-  DirVar $UBCDDIR
-PageExEnd
+!ifdef INPDIR64
+  Page directory CheckX64
+!else
+  Page directory
+!endif
 Page instfiles
 
 UninstPage uninstConfirm
@@ -73,20 +81,41 @@ UninstPage instfiles
 InstType "Full"
 InstType "Extract files only"
 InstType "Drive menu"
-InstType "UBCD4Win plugin"
 
 
 ;--------------------------------------------------------------------
 ; Sections
 
+!ifdef INPDIR64
+  Section "64-bit version (EXPERIMENTAL)" X64_SECTION
+    ; Handled in Function CheckX64
+  SectionEnd
+!endif
+
 SectionGroup "!Program files"
 
+  !macro FileExe path option
+    !ifdef INPDIR64
+      ; Use dummy SetOutPath to control archive location of executables
+      StrCmp $X64 "" +5
+        Goto +2
+          SetOutPath "$INSTDIR\bin64"
+        File ${option} '${INPDIR64}\${path}'
+      GoTo +4
+        Goto +2
+          SetOutPath "$INSTDIR\bin"
+        File ${option} '${INPDIR}\${path}'
+    !else
+      File ${option} '${INPDIR}\${path}'
+    !endif
+  !macroend
+
   Section "smartctl" SMARTCTL_SECTION
 
     SectionIn 1 2
 
     SetOutPath "$INSTDIR\bin"
-    File "${INPDIR}\bin\smartctl.exe"
+    !insertmacro FileExe "bin\smartctl.exe" ""
 
   SectionEnd
 
@@ -103,14 +132,15 @@ SectionGroup "!Program files"
       StrCmp $0 "" nosrv
         ExecWait "net stop smartd" $1
   nosrv:
-    File "${INPDIR}\bin\smartd.exe"
+    !insertmacro FileExe "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"
+    IfFileExists "$WINDIR\system32\cmd.exe" 0 nosysl
+      !insertmacro FileExe "bin\syslogevt.exe" /nonfatal
+    nosysl:
 
     ; Restart service ?
     StrCmp $1 "0" 0 +3
@@ -124,7 +154,7 @@ SectionGroup "!Program files"
     SectionIn 1 2
 
     SetOutPath "$INSTDIR\bin"
-    File "${INPDIR}\bin\smartctl-nc.exe"
+    !insertmacro FileExe "bin\smartctl-nc.exe" ""
 
   SectionEnd
 
@@ -153,7 +183,14 @@ Section "!Documentation" DOC_SECTION
   File "${INPDIR}\doc\README.txt"
   File "${INPDIR}\doc\TODO.txt"
   File "${INPDIR}\doc\WARNINGS.txt"
-  File "${INPDIR}\doc\checksums.txt"
+!ifdef INPDIR64
+  StrCmp $X64 "" +3
+    File "${INPDIR64}\doc\checksums64.txt"
+  GoTo +2
+    File "${INPDIR}\doc\checksums32.txt"
+!else
+  File "${INPDIR}\doc\checksums??.txt"
+!endif
   File "${INPDIR}\doc\smartctl.8.html"
   File "${INPDIR}\doc\smartctl.8.txt"
   File "${INPDIR}\doc\smartd.8.html"
@@ -167,7 +204,7 @@ SectionEnd
 Section "Uninstaller" UNINST_SECTION
 
   SectionIn 1
-  AddSize 35
+  AddSize 40
 
   CreateDirectory "$INSTDIR"
 
@@ -199,64 +236,66 @@ Section "Start Menu Shortcuts" MENU_SECTION
 
   CreateDirectory "$SMPROGRAMS\smartmontools"
 
+  !macro CreateAdminShortCut link target args
+    CreateShortCut '${link}' '${target}' '${args}'
+    push '${link}'
+    Call ShellLinkSetRunAs
+  !macroend
+
+  ; runcmdu
+  IfFileExists "$INSTDIR\bin\smartctl.exe" 0 +2
+  IfFileExists "$INSTDIR\bin\smartd.exe" 0 noruncmd
+    SetOutPath "$INSTDIR\bin"
+    !insertmacro FileExe "bin\runcmdu.exe" ""
+    File "${INPDIR}\bin\runcmdu.exe.manifest"
+  noruncmd:
+
   ; 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"
+    IfFileExists "$WINDIR\system32\cmd.exe" 0 nocmd
+      !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl (Admin CMD).lnk" "$WINDIR\system32\cmd.exe" '/k PATH=$INSTDIR\bin;%PATH%&cd /d "$INSTDIR\bin"'
+    nocmd:
     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"  
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\All info (-a).lnk"                    "$INSTDIR\bin\runcmdu.exe" "smartctl -a sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Identify drive (-i).lnk"              "$INSTDIR\bin\runcmdu.exe" "smartctl -i sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART attributes (-A).lnk"            "$INSTDIR\bin\runcmdu.exe" "smartctl -A sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART capabilities (-c).lnk"          "$INSTDIR\bin\runcmdu.exe" "smartctl -c sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART health status (-H).lnk"         "$INSTDIR\bin\runcmdu.exe" "smartctl -H sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART error log (-l error).lnk"       "$INSTDIR\bin\runcmdu.exe" "smartctl -l error sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART selftest log (-l selftest).lnk" "$INSTDIR\bin\runcmdu.exe" "smartctl -l selftest sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start long selftest (-t long).lnk"    "$INSTDIR\bin\runcmdu.exe" "smartctl -t long sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start offline test (-t offline).lnk"  "$INSTDIR\bin\runcmdu.exe" "smartctl -t offline sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start short selftest (-t short).lnk"  "$INSTDIR\bin\runcmdu.exe" "smartctl -t short sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Stop(Abort) selftest (-X).lnk"        "$INSTDIR\bin\runcmdu.exe" "smartctl -X sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART off (-s off).lnk"          "$INSTDIR\bin\runcmdu.exe" "smartctl -s off sda"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART on (-s on).lnk"            "$INSTDIR\bin\runcmdu.exe" "smartctl -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$\n"$INSTDIR\bin\smartd" %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:
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, smartd.log.lnk"           "$INSTDIR\bin\runcmdu.exe" "smartd -l local0"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, eventlog.lnk"             "$INSTDIR\bin\runcmdu.exe" "smartd"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon stop.lnk"                        "$INSTDIR\bin\runcmdu.exe" "smartd stop"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Do all tests once (-q onecheck).lnk"    "$INSTDIR\bin\runcmdu.exe" "smartd -q onecheck"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Debug mode (-d).lnk"                    "$INSTDIR\bin\runcmdu.exe" "smartd -d"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\smartd.conf (edit).lnk" "$EDITOR" "$INSTDIR\bin\smartd.conf"
+    CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\smartd.conf (view).lnk"                   "$EDITOR" "$INSTDIR\bin\smartd.conf"
+    CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\smartd.log (view).lnk"                    "$EDITOR" "$INSTDIR\bin\smartd.log"
 
     ; 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"
+      !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, eventlog, 30min.lnk"   "$INSTDIR\bin\runcmdu.exe" "smartd install"
+      !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 10min.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd install -l local0 -i 600"
+      !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 30min.lnk" "$INSTDIR\bin\runcmdu.exe" "smartd install -l local0"
+      !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service remove.lnk"                     "$INSTDIR\bin\runcmdu.exe" "smartd remove"
+      !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service start.lnk"                      "$INSTDIR\bin\runcmdu.exe" "net start smartd"
+      !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service stop.lnk"                       "$INSTDIR\bin\runcmdu.exe" "net stop smartd"
     nosvc:
   nod:
 
@@ -270,11 +309,11 @@ Section "Start Menu Shortcuts" MENU_SECTION
     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 +5
-      CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$WINDIR\notepad.exe" "$INSTDIR\doc\smartd.conf"
-      IfFileExists "$INSTDIR\bin\drivedb.h" 0 +3
-        CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb.h (view).lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\drivedb.h"
-        CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb-add.h (create, edit).lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\drivedb-add.h"
+    CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$EDITOR" "$INSTDIR\doc\smartd.conf"
+    IfFileExists "$INSTDIR\bin\drivedb.h" 0 nodb
+        CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb.h (view).lnk" "$EDITOR" "$INSTDIR\bin\drivedb.h"
+        !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb-add.h (create, edit).lnk" "$EDITOR" "$INSTDIR\bin\drivedb-add.h"
+    nodb:
     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"
@@ -290,12 +329,16 @@ Section "Start Menu Shortcuts" MENU_SECTION
   CreateShortCut "$SMPROGRAMS\smartmontools\smartmontools Home Page.lnk" "http://smartmontools.sourceforge.net/"
 
   ; drivedb.h update
-  IfFileExists "$INSTDIR\bin\update-smart-drivedb.exe" 0 +2
-    CreateShortCut "$SMPROGRAMS\smartmontools\drivedb.h update.lnk" "$INSTDIR\bin\update-smart-drivedb.exe"
+  IfFileExists "$INSTDIR\bin\update-smart-drivedb.exe" 0 noupdb
+    SetOutPath "$INSTDIR\bin"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\drivedb.h update.lnk" "$INSTDIR\bin\update-smart-drivedb.exe" ""
+  noupdb:
 
   ; Uninstall
-  IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 +2
-    CreateShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe"
+  IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 noinst
+    SetOutPath "$INSTDIR"
+    !insertmacro CreateAdminShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe" ""
+  noinst:
 
 SectionEnd
 
@@ -329,10 +372,10 @@ SectionGroup "Add smartctl to drive menu"
 !macro DriveSection id name args
   Section 'smartctl ${args} ...' DRIVE_${id}_SECTION
     SectionIn 3
-    Call CheckSmartctlBat
+    Call CheckRunCmdA
     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'
+    WriteRegStr HKCR "Drive\shell\smartctl${id}\command" "" '"$INSTDIR\bin\runcmda.exe" "$INSTDIR\bin\smartctl.exe" ${args} %L'
   SectionEnd
 !macroend
 
@@ -345,52 +388,6 @@ SectionGroup "Add smartctl to drive menu"
 
 SectionGroupEnd
 
-Section "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  ">'
-  FileWrite $0 'smartctl</MITEM>$\r$\n$\t</MENU>$\r$\n</NU2MENU>$\r$\n'
-  FileClose $0
-  
-  SetOutPath "$UBCDDIR\files"
-  DetailPrint "Create file: smartctl-run.bat"
-  Push "$UBCDDIR\files\smartctl-run.bat"
-  Call CreateSmartctlBat
-  File "${INPDIR}\bin\smartctl.exe"
-  File "${INPDIR}\bin\smartd.exe"
-  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"
-
-SectionEnd
-
-
 ;--------------------------------------------------------------------
 
 Section "Uninstall"
@@ -441,6 +438,10 @@ Section "Uninstall"
   Delete "$INSTDIR\bin\smartctl-run.bat"
   Delete "$INSTDIR\bin\smartd-run.bat"
   Delete "$INSTDIR\bin\net-run.bat"
+  Delete "$INSTDIR\bin\runcmda.exe"
+  Delete "$INSTDIR\bin\runcmda.exe.manifest"
+  Delete "$INSTDIR\bin\runcmdu.exe"
+  Delete "$INSTDIR\bin\runcmdu.exe.manifest"
   Delete "$INSTDIR\doc\AUTHORS.txt"
   Delete "$INSTDIR\doc\CHANGELOG.txt"
   Delete "$INSTDIR\doc\COPYING.txt"
@@ -449,7 +450,7 @@ Section "Uninstall"
   Delete "$INSTDIR\doc\README.txt"
   Delete "$INSTDIR\doc\TODO.txt"
   Delete "$INSTDIR\doc\WARNINGS.txt"
-  Delete "$INSTDIR\doc\checksums.txt"
+  Delete "$INSTDIR\doc\checksums*.txt"
   Delete "$INSTDIR\doc\smartctl.8.html"
   Delete "$INSTDIR\doc\smartctl.8.txt"
   Delete "$INSTDIR\doc\smartd.8.html"
@@ -498,13 +499,36 @@ SectionEnd
 ;--------------------------------------------------------------------
 ; Functions
 
+!macro AdjustSectionSize section
+  SectionGetSize ${section} $0
+  IntOp $0 $0 / 2
+  SectionSetSize ${section} $0
+!macroend
+
 Function .onInit
 
-  ; Get UBCD4Win install location
-  ReadRegStr $0 HKLM "Software\UBCD4Win" "InstallPath"
-  StrCmp $0 "" 0 +2
-    StrCpy $0 "C:\UBCD4Win"
-  StrCpy $UBCDDIR "$0\plugin\Disk\Diagnostic\smartmontools"
+  ; Set default install directories
+  StrCmp $INSTDIR "" 0 endinst ; /D=PATH option specified ?
+  ReadRegStr $INSTDIR HKLM "Software\smartmontools" "Install_Dir"
+  StrCmp $INSTDIR "" 0 endinst ; Already installed ?
+    StrCpy $INSTDIR "$PROGRAMFILES\smartmontools"
+!ifdef INPDIR64
+    StrCpy $INSTDIR32 $INSTDIR
+    StrCpy $INSTDIR64 "$PROGRAMFILES64\smartmontools"
+!endif
+  endinst:
+
+!ifdef INPDIR64
+  ; Sizes of binary sections include 32-bit and 64-bit executables
+  !insertmacro AdjustSectionSize ${SMARTCTL_SECTION}
+  !insertmacro AdjustSectionSize ${SMARTD_SECTION}
+  !insertmacro AdjustSectionSize ${SMARTCTL_NC_SECTION}
+!endif
+
+  ; Use Notepad++ if installed
+  StrCpy $EDITOR "$PROGRAMFILES\Notepad++\notepad++.exe"
+  IfFileExists "$EDITOR" +2 0
+    StrCpy $EDITOR "notepad.exe"
 
   ; Hide "Add install dir to PATH" on 9x/ME
   IfFileExists "$WINDIR\system32\cmd.exe" +2 0
@@ -513,6 +537,27 @@ Function .onInit
   Call ParseCmdLine
 FunctionEnd
 
+; Check x64 section and update INSTDIR accordingly
+
+!ifdef INPDIR64
+Function CheckX64
+  SectionGetFlags ${X64_SECTION} $0
+  IntOp $0 $0 & ${SF_SELECTED}
+  IntCmp $0 ${SF_SELECTED} x64
+    StrCpy $X64 ""
+    StrCmp $INSTDIR32 "" +3
+      StrCpy $INSTDIR $INSTDIR32
+      StrCpy $INSTDIR32 ""
+    Goto done
+  x64:
+    StrCpy $X64 "t"
+    StrCmp $INSTDIR64 "" +3
+      StrCpy $INSTDIR $INSTDIR64
+      StrCpy $INSTDIR64 ""
+  done:
+FunctionEnd
+!endif
+
 ; Command line parsing
 !macro CheckCmdLineOption name section
   StrCpy $allopts "$allopts,${name}"
@@ -541,6 +586,12 @@ Function ParseCmdLine
   Var /global nomatch
   StrCpy $nomatch "t"
   ; turn sections on or off
+!ifdef INPDIR64
+  !insertmacro CheckCmdLineOption "x64" ${X64_SECTION}
+  Call CheckX64
+  StrCmp $opts "x64" 0 +2
+    Return ; leave sections unchanged if only "x64" is specified
+!endif
   !insertmacro CheckCmdLineOption "smartctl" ${SMARTCTL_SECTION}
   !insertmacro CheckCmdLineOption "smartd" ${SMARTD_SECTION}
   !insertmacro CheckCmdLineOption "smartctlnc" ${SMARTCTL_NC_SECTION}
@@ -556,7 +607,6 @@ Function ParseCmdLine
   !insertmacro CheckCmdLineOption "drive3" ${DRIVE_3_SECTION}
   !insertmacro CheckCmdLineOption "drive4" ${DRIVE_4_SECTION}
   !insertmacro CheckCmdLineOption "drive5" ${DRIVE_5_SECTION}
-  !insertmacro CheckCmdLineOption "ubcd" ${UBCD_SECTION}
   StrCmp $opts "-" done
   StrCmp $nomatch "" done
     StrCpy $0 "$allopts,-" "" 1
@@ -565,73 +615,13 @@ Function ParseCmdLine
 done:
 FunctionEnd
 
-; Directory page callbacks
-
-!macro CheckSection section
-  SectionGetFlags ${section} $0
-  IntOp $0 $0 & 1
-  IntCmp $0 1 done
-!macroend
-
-Function SkipProgPath
-  !insertmacro CheckSection ${SMARTCTL_SECTION}
-  !insertmacro CheckSection ${SMARTCTL_NC_SECTION}
-  !insertmacro CheckSection ${SMARTD_SECTION}
-  !insertmacro CheckSection ${DRIVEDB_SECTION}
-  !insertmacro CheckSection ${DOC_SECTION}
-  !insertmacro CheckSection ${MENU_SECTION}
-  !insertmacro CheckSection ${PATH_SECTION}
-  !insertmacro CheckSection ${DRIVE_0_SECTION}
-  !insertmacro CheckSection ${DRIVE_1_SECTION}
-  !insertmacro CheckSection ${DRIVE_2_SECTION}
-  !insertmacro CheckSection ${DRIVE_3_SECTION}
-  !insertmacro CheckSection ${DRIVE_4_SECTION}
-  !insertmacro CheckSection ${DRIVE_5_SECTION}
-  Abort
-done:
-FunctionEnd
-
-Function SkipUBCDPath
-  !insertmacro CheckSection ${UBCD_SECTION}
-  Abort
-done:
-FunctionEnd
-
-
-; Create smartctl-run.bat
+; Install runcmda.exe if missing
 
-Function CreateSmartctlBat
-  Exch $0
-  FileOpen $0 $0 "w"
-  FileWrite $0 '@echo off$\r$\nif not "%1" == "" goto run$\r$\n'
-  FileWrite $0 'echo Examples (for first drive):$\r$\n'
-  FileWrite $0 'echo smartctl -i sda            Show identify information$\r$\n'
-  FileWrite $0 'echo smartctl -H sda            Show SMART health status$\r$\n'
-  FileWrite $0 'echo smartctl -c sda            Show SMART capabilities$\r$\n'
-  FileWrite $0 'echo smartctl -A sda            Show SMART attributes$\r$\n'
-  FileWrite $0 'echo smartctl -l error sda      Show error log$\r$\n'
-  FileWrite $0 'echo smartctl -l selftest sda   Show self-test log$\r$\n'
-  FileWrite $0 'echo smartctl -a sda            Show all of the above$\r$\n'
-  FileWrite $0 'echo smartctl -t short sda      Start short self test$\r$\n'
-  FileWrite $0 'echo smartctl -t long sda       Start long self test$\r$\n'
-  FileWrite $0 'echo Use "sdb", "sdc", ... for second, third, ... drive.$\r$\n'
-  FileWrite $0 'echo See man page (smartctl.8.*) for further info.$\r$\n'
-  FileWrite $0 'goto end$\r$\n:run$\r$\n'
-  FileWrite $0 'echo smartctl %1 %2 %3 %4 %5$\r$\n'
-  FileWrite $0 '"$INSTDIR\bin\smartctl" %1 %2 %3 %4 %5$\r$\n'
-  FileWrite $0 'pause$\r$\n:end$\r$\n'
-  FileClose $0
-  Pop $0
-FunctionEnd
-
-; Create smartctl-run.bat if missing
-
-Function CheckSmartctlBat
-  IfFileExists "$INSTDIR\bin\smartctl-run.bat" done 0
+Function CheckRunCmdA
+  IfFileExists "$INSTDIR\bin\runcmda.exe" done 0
     SetOutPath "$INSTDIR\bin"
-    DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat"
-    Push "$INSTDIR\bin\smartctl-run.bat"
-    Call CreateSmartctlBat
+    !insertmacro FileExe "bin\runcmda.exe" ""
+    File "${INPDIR}\bin\runcmda.exe.manifest"
   done:
 FunctionEnd
 
@@ -780,3 +770,62 @@ FunctionEnd
 !macroend
 !insertmacro StrStr ""
 !insertmacro StrStr "un."
+
+
+;--------------------------------------------------------------------
+; Set Run As Administrator flag in shortcut
+;
+; Slightly modified version from:
+; http://nsis.sourceforge.net/IShellLink_Set_RunAs_flag
+;
+
+!include "LogicLib.nsh"
+
+!define IPersistFile {0000010b-0000-0000-c000-000000000046}
+!define CLSID_ShellLink {00021401-0000-0000-C000-000000000046}
+!define IID_IShellLinkA {000214EE-0000-0000-C000-000000000046}
+!define IID_IShellLinkW {000214F9-0000-0000-C000-000000000046}
+!define IShellLinkDataList {45e2b4ae-b1c3-11d0-b92f-00a0c90312e1}
+!ifdef NSIS_UNICODE
+  !define IID_IShellLink ${IID_IShellLinkW}
+!else
+  !define IID_IShellLink ${IID_IShellLinkA}
+!endif
+
+Function ShellLinkSetRunAs
+  ; Set archive location of $PLUGINSDIR
+  Goto +2
+    SetOutPath "$INSTDIR"
+
+  System::Store S ; push $0-$9, $R0-$R9
+  pop $9
+  ; $0 = CoCreateInstance(CLSID_ShellLink, 0, CLSCTX_INPROC_SERVER, IID_IShellLink, &$1)
+  System::Call "ole32::CoCreateInstance(g'${CLSID_ShellLink}',i0,i1,g'${IID_IShellLink}',*i.r1)i.r0"
+  ${If} $0 = 0
+    System::Call "$1->0(g'${IPersistFile}',*i.r2)i.r0" ; $0 = $1->QueryInterface(IPersistFile, &$2)
+    ${If} $0 = 0
+      System::Call "$2->5(w '$9',i 0)i.r0" ; $0 = $2->Load($9, STGM_READ)
+      ${If} $0 = 0
+        System::Call "$1->0(g'${IShellLinkDataList}',*i.r3)i.r0" ; $0 = $1->QueryInterface(IShellLinkDataList, &$3)
+        ${If} $0 = 0
+          System::Call "$3->6(*i.r4)i.r0"; $0 = $3->GetFlags(&$4)
+          ${If} $0 = 0
+            System::Call "$3->7(i $4|0x2000)i.r0" ; $0 = $3->SetFlags($4|SLDF_RUNAS_USER)
+            ${If} $0 = 0
+              System::Call "$2->6(w '$9',i1)i.r0" ; $2->Save($9, TRUE)
+            ${EndIf}
+          ${EndIf}
+          System::Call "$3->2()" ; $3->Release()
+        ${EndIf}
+        System::Call "$2->2()" ; $2->Release()
+      ${EndIf}
+    ${EndIf}
+    System::Call "$1->2()" ; $1->Release()
+  ${EndIf}
+  ${If} $0 <> 0
+    DetailPrint "Set RunAsAdmin: $9 failed ($0)"
+  ${Else}
+    DetailPrint "Set RunAsAdmin: $9"
+  ${EndIf}
+  System::Store L ; push $0-$9, $R0-$R9
+FunctionEnd