Advertisement
Anders

makensis2011b

Mar 22nd, 2011
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. makensis2011b
  4. +Make sure NT4 user is admin in .onInit
  5. *Does not force default verb to be "open" (open is default if not set)
  6. *Minor optimizations
  7.  
  8. makensis2011
  9. +Single User & All Users install types
  10. +Safer filetype uninstall logic
  11. +Filetypes:PerceivedType for XP+
  12. *Separated Startmenu and Desktop shortcuts into sections
  13. *Desktop shortcut is unselected by default
  14.  
  15. */
  16.  
  17.  
  18. ;NSIS Setup Script
  19. ;--------------------------------
  20.  
  21. !ifndef VERSION
  22.   !define VERSION 'anonymous-build'
  23. !endif
  24.  
  25. ;--------------------------------
  26. ;Configuration
  27.  
  28. !ifdef OUTFILE
  29.   OutFile "${OUTFILE}"
  30. !else
  31.   OutFile ..\nsis-${VERSION}-setup.exe
  32. !endif
  33.  
  34. SetCompressor /SOLID lzma
  35.  
  36. InstType "Full"
  37. InstType "Lite"
  38. InstType "Minimal"
  39.  
  40. RequestExecutionLevel highest
  41.  
  42. ;--------------------------------
  43. ;Header Files
  44.  
  45. !include "MUI2.nsh"
  46. !include "Sections.nsh"
  47. !include "LogicLib.nsh"
  48. !include "Memento.nsh"
  49. !include "WordFunc.nsh"
  50. !include "FileFunc.nsh"
  51. !include "WinVer.nsh"
  52.  
  53. ;--------------------------------
  54. ;Prepare external functions
  55.  
  56. !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
  57.  
  58.   !insertmacro VersionCompare
  59.  
  60. !endif
  61.  
  62. ;--------------------------------
  63. ;Definitions
  64.  
  65. !define SHCNE_ASSOCCHANGED 0x8000000
  66. !define SHCNF_IDLIST 0
  67.  
  68. !define REGPATH_MSWIN_UNINST "Software\Microsoft\Windows\CurrentVersion\Uninstall"
  69.  
  70. ;--------------------------------
  71. ;Configuration
  72.  
  73. ;Names
  74. Name "NSIS"
  75. Caption "NSIS ${VERSION} Setup"
  76.  
  77. ;Memento Settings
  78. !define MEMENTO_REGISTRY_ROOT SHCTX
  79. !define MEMENTO_REGISTRY_KEY "${REGPATH_MSWIN_UNINST}\NSIS"
  80.  
  81. ;Interface Settings
  82. !define MUI_ABORTWARNING
  83.  
  84. !define MUI_HEADERIMAGE
  85. !define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\nsis.bmp"
  86.  
  87. !define MUI_COMPONENTSPAGE_SMALLDESC
  88.  
  89. !define MULTIUSER_INSTALLMODEPAGE ;We are using some multiuser strings, make sure MUI_LANGUAGE includes those for us...
  90.  
  91. ;--------------------------------
  92. ;Global variables
  93.  
  94. Var InstMode ;1=current/single user, 2=all users/machine
  95. Var InstModeDefUserDir
  96. Var InstModeDefMachineDir
  97.  
  98. ;--------------------------------
  99. ;Pages
  100.  
  101. !define MUI_WELCOMEPAGE_TITLE "Welcome to the NSIS ${VERSION} Setup Wizard"
  102. !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of NSIS (Nullsoft Scriptable Install System) ${VERSION}, the next generation of the Windows installer and uninstaller system that doesn't suck and isn't huge.$\r$\n$\r$\nNSIS 2 includes a new Modern User Interface, LZMA compression, support for multiple languages and an easy plug-in system.$\r$\n$\r$\n$_CLICK"
  103.  
  104. !insertmacro MUI_PAGE_WELCOME
  105. !insertmacro MUI_PAGE_LICENSE "..\COPYING"
  106. Page custom PageInstallmode PageLeaveInstallmode ""
  107. !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
  108. Page custom PageReinstall PageLeaveReinstall
  109. !endif
  110. !insertmacro MUI_PAGE_COMPONENTS
  111. !insertmacro MUI_PAGE_DIRECTORY
  112. !insertmacro MUI_PAGE_INSTFILES
  113.  
  114. !define MUI_FINISHPAGE_LINK "Visit the NSIS site for the latest news, FAQs and support"
  115. !define MUI_FINISHPAGE_LINK_LOCATION "http://nsis.sf.net/"
  116.  
  117. !define MUI_FINISHPAGE_RUN "$INSTDIR\NSIS.exe"
  118. !define MUI_FINISHPAGE_NOREBOOTSUPPORT
  119.  
  120. !define MUI_FINISHPAGE_SHOWREADME
  121. !define MUI_FINISHPAGE_SHOWREADME_TEXT "Show release notes"
  122. !define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowReleaseNotes
  123.  
  124. !insertmacro MUI_PAGE_FINISH
  125.  
  126. !insertmacro MUI_UNPAGE_CONFIRM
  127. !insertmacro MUI_UNPAGE_INSTFILES
  128.  
  129. ;--------------------------------
  130. ;Languages
  131.  
  132. !insertmacro MUI_LANGUAGE "English"
  133. LangString PageInstallmodeCaption 0 "Install mode"
  134.  
  135. ;--------------------------------
  136. ;Installer Sections
  137.  
  138. ${MementoSection} "NSIS Core Files (required)" SecCore
  139.  
  140.   SetDetailsPrint textonly
  141.   DetailPrint "Installing NSIS Core Files..."
  142.   SetDetailsPrint listonly
  143.  
  144.   SectionIn 1 2 3 RO
  145.   SetOutPath $INSTDIR
  146.   RMDir /r $SMPROGRAMS\NSIS
  147.  
  148.   SetOverwrite on
  149.   File /oname=makensis.exe ..\Bin\substart.exe
  150.   File ..\makensisw.exe
  151.   File ..\COPYING
  152.   File ..\NSIS.chm
  153.   File ..\NSIS.exe
  154.   File /nonfatal ..\NSIS.exe.manifest
  155.   SetOutPath $INSTDIR\Bin
  156.   File ..\Bin\makensis.exe
  157.   File ..\Bin\zlib1.dll
  158.  
  159.   IfFileExists $INSTDIR\nsisconf.nsi "" +2
  160.   Rename $INSTDIR\nsisconf.nsi $INSTDIR\nsisconf.nsh
  161.   SetOverwrite off
  162.   File ..\nsisconf.nsh
  163.   SetOverwrite on
  164.  
  165.   SetOutPath $INSTDIR\Stubs
  166.   File ..\Stubs\bzip2
  167.   File ..\Stubs\bzip2_solid
  168.   File ..\Stubs\lzma
  169.   File ..\Stubs\lzma_solid
  170.   File ..\Stubs\zlib
  171.   File ..\Stubs\zlib_solid
  172.   File ..\Stubs\uninst
  173.  
  174.   SetOutPath $INSTDIR\Include
  175.   File ..\Include\WinMessages.nsh
  176.   File ..\Include\Sections.nsh
  177.   File ..\Include\Library.nsh
  178.   File ..\Include\UpgradeDLL.nsh
  179.   File ..\Include\LogicLib.nsh
  180.   File ..\Include\StrFunc.nsh
  181.   File ..\Include\Colors.nsh
  182.   File ..\Include\FileFunc.nsh
  183.   File ..\Include\TextFunc.nsh
  184.   File ..\Include\WordFunc.nsh
  185.   File ..\Include\WinVer.nsh
  186.   File ..\Include\x64.nsh
  187.   File ..\Include\Memento.nsh
  188.   File ..\Include\LangFile.nsh
  189.   File ..\Include\InstallOptions.nsh
  190.   File ..\Include\MultiUser.nsh
  191.   File ..\Include\VB6RunTime.nsh
  192.   File ..\Include\Util.nsh
  193.   File ..\Include\WinCore.nsh
  194.  
  195.   SetOutPath $INSTDIR\Include\Win
  196.   File ..\Include\Win\WinDef.nsh
  197.   File ..\Include\Win\WinError.nsh
  198.   File ..\Include\Win\WinNT.nsh
  199.   File ..\Include\Win\WinUser.nsh
  200.   File ..\Include\Win\COM.nsh
  201.   File ..\Include\Win\Propkey.nsh
  202.  
  203.   SetOutPath $INSTDIR\Docs\StrFunc
  204.   File ..\Docs\StrFunc\StrFunc.txt
  205.  
  206.   SetOutPath $INSTDIR\Docs\MultiUser
  207.   File ..\Docs\MultiUser\Readme.html
  208.  
  209.   SetOutPath $INSTDIR\Docs\makensisw
  210.   File ..\Docs\makensisw\*.txt
  211.  
  212.   SetOutPath $INSTDIR\Menu
  213.   File ..\Menu\*.html
  214.   SetOutPath $INSTDIR\Menu\images
  215.   File ..\Menu\images\header.gif
  216.   File ..\Menu\images\line.gif
  217.   File ..\Menu\images\site.gif
  218.  
  219.   Delete $INSTDIR\makensis.htm
  220.   Delete $INSTDIR\Docs\*.html
  221.   Delete $INSTDIR\Docs\style.css
  222.   RMDir $INSTDIR\Docs
  223.  
  224.   SetOutPath $INSTDIR\Bin
  225.   File ..\Bin\LibraryLocal.exe
  226.   File ..\Bin\RegTool.bin
  227.  
  228.   SetOutPath $INSTDIR\Plugins
  229.   File ..\Plugins\TypeLib.dll
  230.  
  231.   ;Remove legacy .nsi ProgID
  232.   ReadRegStr $R0 SHCTX "Software\Classes\.nsi" ""
  233.   StrCmp $R0 "NSISFile" 0 +2
  234.     DeleteRegKey SHCTX "Software\Classes\NSISFile"
  235.  
  236.   WriteRegStr SHCTX "Software\Classes\.nsi" "" "NSIS.Script"
  237.   WriteRegStr SHCTX "Software\Classes\.nsi" "PerceivedType" "text"
  238.   WriteRegStr SHCTX "Software\Classes\NSIS.Script" "" "NSIS Script File"
  239.   WriteRegStr SHCTX "Software\Classes\NSIS.Script\DefaultIcon" "" "$INSTDIR\makensisw.exe,1"
  240.   ReadRegStr $R0 SHCTX "Software\Classes\NSIS.Script\shell\open\command" ""
  241.   StrCmp $R0 "" 0 no_nsiopen
  242.     ;Open is default anyway: WriteRegStr SHCTX "Software\Classes\NSIS.Script\shell" "" "open"
  243.     WriteRegStr SHCTX "Software\Classes\NSIS.Script\shell\open\command" "" 'notepad.exe "%1"'
  244.   no_nsiopen:
  245.   WriteRegStr SHCTX "Software\Classes\NSIS.Script\shell\compile" "" "Compile NSIS Script"
  246.   WriteRegStr SHCTX "Software\Classes\NSIS.Script\shell\compile\command" "" '"$INSTDIR\makensisw.exe" "%1"'
  247.   WriteRegStr SHCTX "Software\Classes\NSIS.Script\shell\compile-compressor" "" "Compile NSIS Script (Choose Compressor)"
  248.   WriteRegStr SHCTX "Software\Classes\NSIS.Script\shell\compile-compressor\command" "" '"$INSTDIR\makensisw.exe" /ChooseCompressor "%1"'
  249.  
  250.   ;Remove legacy .nsh ProgID
  251.   ReadRegStr $R0 SHCTX "Software\Classes\.nsh" ""
  252.   StrCmp $R0 "NSHFile" 0 +2
  253.     DeleteRegKey SHCTX "Software\Classes\NSHFile"
  254.  
  255.   WriteRegStr SHCTX "Software\Classes\.nsh" "" "NSIS.Header"
  256.   WriteRegStr SHCTX "Software\Classes\.nsh" "PerceivedType" "text"
  257.   WriteRegStr SHCTX "Software\Classes\NSIS.Header" "" "NSIS Header File"
  258.   WriteRegStr SHCTX "Software\Classes\NSIS.Header\DefaultIcon" "" "$INSTDIR\makensisw.exe,1"
  259.   ReadRegStr $R0 SHCTX "Software\Classes\NSIS.Header\shell\open\command" ""
  260.   StrCmp $R0 "" 0 no_nshopen
  261.     ;Open is default anyway: WriteRegStr SHCTX "Software\Classes\NSIS.Header\shell" "" "open"
  262.     WriteRegStr SHCTX "Software\Classes\NSIS.Header\shell\open\command" "" 'notepad.exe "%1"'
  263.   no_nshopen:
  264.  
  265.   System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)'
  266.  
  267. ${MementoSectionEnd}
  268.  
  269. ${MementoSection} "Script Examples" SecExample
  270.  
  271.   SetDetailsPrint textonly
  272.   DetailPrint "Installing Script Examples..."
  273.   SetDetailsPrint listonly
  274.  
  275.   SectionIn 1 2
  276.   SetOutPath $INSTDIR\Examples
  277.   File ..\Examples\makensis.nsi
  278.   File ..\Examples\example1.nsi
  279.   File ..\Examples\example2.nsi
  280.   File ..\Examples\viewhtml.nsi
  281.   File ..\Examples\waplugin.nsi
  282.   File ..\Examples\bigtest.nsi
  283.   File ..\Examples\primes.nsi
  284.   File ..\Examples\rtest.nsi
  285.   File ..\Examples\gfx.nsi
  286.   File ..\Examples\one-section.nsi
  287.   File ..\Examples\languages.nsi
  288.   File ..\Examples\Library.nsi
  289.   File ..\Examples\VersionInfo.nsi
  290.   File ..\Examples\UserVars.nsi
  291.   File ..\Examples\LogicLib.nsi
  292.   File ..\Examples\silent.nsi
  293.   File ..\Examples\StrFunc.nsi
  294.   File ..\Examples\FileFunc.nsi
  295.   File ..\Examples\FileFunc.ini
  296.   File ..\Examples\FileFuncTest.nsi
  297.   File ..\Examples\TextFunc.nsi
  298.   File ..\Examples\TextFunc.ini
  299.   File ..\Examples\TextFuncTest.nsi
  300.   File ..\Examples\WordFunc.nsi
  301.   File ..\Examples\WordFunc.ini
  302.   File ..\Examples\WordFuncTest.nsi
  303.   File ..\Examples\Memento.nsi
  304.  
  305.   SetOutPath $INSTDIR\Examples\Plugin
  306.   File ..\Examples\Plugin\exdll.c
  307.   File ..\Examples\Plugin\exdll.dpr
  308.   File ..\Examples\Plugin\exdll.dsp
  309.   File ..\Examples\Plugin\exdll.dsw
  310.   File ..\Examples\Plugin\exdll_with_unit.dpr
  311.   File ..\Examples\Plugin\exdll-vs2008.sln
  312.   File ..\Examples\Plugin\exdll-vs2008.vcproj
  313.   File ..\Examples\Plugin\extdll.inc
  314.   File ..\Examples\Plugin\nsis.pas
  315.  
  316.   SetOutPath $INSTDIR\Examples\Plugin\nsis
  317.   File ..\Examples\Plugin\nsis\pluginapi.h
  318.   File ..\Examples\Plugin\nsis\pluginapi.lib
  319.   File ..\Examples\Plugin\nsis\api.h
  320.   File ..\Examples\Plugin\nsis\nsis_tchar.h
  321.  
  322. ${MementoSectionEnd}
  323.  
  324. Section
  325.   SetDetailsPrint textonly
  326.   !ifndef NO_STARTMENUSHORTCUTS
  327.   DetailPrint "Installing Start Menu and Desktop Shortcuts..."
  328.   !else
  329.   DetailPrint "Installing Desktop Shortcut..."
  330.   !endif
  331.   SetDetailsPrint listonly
  332.   SetOutPath $INSTDIR
  333. SectionEnd
  334.  
  335. !ifndef NO_STARTMENUSHORTCUTS
  336. SectionGroup "Shortcuts" SecShortcuts
  337.  
  338. ${MementoSection} "Start Menu Shortcuts" SecSMShortcuts
  339.   SectionIn 1 2
  340.   CreateShortCut "$SMPROGRAMS\NSIS.lnk" "$INSTDIR\NSIS.exe"
  341. ${MementoSectionEnd}
  342.  
  343. ${MementoUnselectedSection} "Desktop Shortcut" SecDeskShortcuts
  344.   CreateShortCut "$DESKTOP\NSIS.lnk" "$INSTDIR\NSIS.exe"
  345. ${MementoSectionEnd}
  346.  
  347. SectionGroupEnd
  348. !else
  349. ${MementoSection} "Desktop Shortcut" SecShortcuts
  350.   CreateShortCut "$DESKTOP\NSIS.lnk" "$INSTDIR\NSIS.exe"
  351. ${MementoSectionEnd}
  352. !endif
  353.  
  354.  
  355. SectionGroup "User Interfaces" SecInterfaces
  356.  
  357. ${MementoSection} "Modern User Interface" SecInterfacesModernUI
  358.  
  359.   SetDetailsPrint textonly
  360.   DetailPrint "Installing User Interfaces | Modern User Interface..."
  361.   SetDetailsPrint listonly
  362.  
  363.   SectionIn 1 2
  364.  
  365.   SetOutPath "$INSTDIR\Examples\Modern UI"
  366.   File "..\Examples\Modern UI\Basic.nsi"
  367.   File "..\Examples\Modern UI\HeaderBitmap.nsi"
  368.   File "..\Examples\Modern UI\MultiLanguage.nsi"
  369.   File "..\Examples\Modern UI\StartMenu.nsi"
  370.   File "..\Examples\Modern UI\WelcomeFinish.nsi"
  371.  
  372.   SetOutPath "$INSTDIR\Contrib\Modern UI"
  373.   File "..\Contrib\Modern UI\System.nsh"
  374.   File "..\Contrib\Modern UI\ioSpecial.ini"
  375.  
  376.   SetOutPath "$INSTDIR\Docs\Modern UI"
  377.   File "..\Docs\Modern UI\Readme.html"
  378.   File "..\Docs\Modern UI\Changelog.txt"
  379.   File "..\Docs\Modern UI\License.txt"
  380.  
  381.   SetOutPath "$INSTDIR\Docs\Modern UI\images"
  382.   File "..\Docs\Modern UI\images\header.gif"
  383.   File "..\Docs\Modern UI\images\screen1.png"
  384.   File "..\Docs\Modern UI\images\screen2.png"
  385.   File "..\Docs\Modern UI\images\open.gif"
  386.   File "..\Docs\Modern UI\images\closed.gif"
  387.  
  388.   SetOutPath $INSTDIR\Contrib\UIs
  389.   File "..\Contrib\UIs\modern.exe"
  390.   File "..\Contrib\UIs\modern_headerbmp.exe"
  391.   File "..\Contrib\UIs\modern_headerbmpr.exe"
  392.   File "..\Contrib\UIs\modern_nodesc.exe"
  393.   File "..\Contrib\UIs\modern_smalldesc.exe"
  394.  
  395.   SetOutPath $INSTDIR\Include
  396.   File "..\Include\MUI.nsh"
  397.  
  398.   SetOutPath "$INSTDIR\Contrib\Modern UI 2"
  399.   File "..\Contrib\Modern UI 2\Deprecated.nsh"
  400.   File "..\Contrib\Modern UI 2\Interface.nsh"
  401.   File "..\Contrib\Modern UI 2\Localization.nsh"
  402.   File "..\Contrib\Modern UI 2\MUI2.nsh"
  403.   File "..\Contrib\Modern UI 2\Pages.nsh"
  404.  
  405.   SetOutPath "$INSTDIR\Contrib\Modern UI 2\Pages"
  406.   File "..\Contrib\Modern UI 2\Pages\Components.nsh"
  407.   File "..\Contrib\Modern UI 2\Pages\Directory.nsh"
  408.   File "..\Contrib\Modern UI 2\Pages\Finish.nsh"
  409.   File "..\Contrib\Modern UI 2\Pages\InstallFiles.nsh"
  410.   File "..\Contrib\Modern UI 2\Pages\License.nsh"
  411.   File "..\Contrib\Modern UI 2\Pages\StartMenu.nsh"
  412.   File "..\Contrib\Modern UI 2\Pages\UninstallConfirm.nsh"
  413.   File "..\Contrib\Modern UI 2\Pages\Welcome.nsh"
  414.  
  415.   SetOutPath "$INSTDIR\Docs\Modern UI 2"
  416.   File "..\Docs\Modern UI 2\Readme.html"
  417.   File "..\Docs\Modern UI 2\License.txt"
  418.  
  419.   SetOutPath "$INSTDIR\Docs\Modern UI 2\images"
  420.   File "..\Docs\Modern UI 2\images\header.gif"
  421.   File "..\Docs\Modern UI 2\images\screen1.png"
  422.   File "..\Docs\Modern UI 2\images\screen2.png"
  423.   File "..\Docs\Modern UI 2\images\open.gif"
  424.   File "..\Docs\Modern UI 2\images\closed.gif"
  425.  
  426.   SetOutPath $INSTDIR\Include
  427.   File "..\Include\MUI2.nsh"
  428.  
  429. ${MementoSectionEnd}
  430.  
  431. ${MementoSection} "Default User Interface" SecInterfacesDefaultUI
  432.  
  433.   SetDetailsPrint textonly
  434.   DetailPrint "Installing User Interfaces | Default User Interface..."
  435.   SetDetailsPrint listonly
  436.  
  437.   SectionIn 1
  438.  
  439.   SetOutPath "$INSTDIR\Contrib\UIs"
  440.   File "..\Contrib\UIs\default.exe"
  441.  
  442. ${MementoSectionEnd}
  443.  
  444. ${MementoSection} "Tiny User Interface" SecInterfacesTinyUI
  445.  
  446.   SetDetailsPrint textonly
  447.   DetailPrint "Installing User Interfaces | Tiny User Interface..."
  448.   SetDetailsPrint listonly
  449.  
  450.   SectionIn 1
  451.  
  452.   SetOutPath "$INSTDIR\Contrib\UIs"
  453.   File "..\Contrib\UIs\sdbarker_tiny.exe"
  454.  
  455. ${MementoSectionEnd}
  456.  
  457. SectionGroupEnd
  458.  
  459. ${MementoSection} "Graphics" SecGraphics
  460.  
  461.   SetDetailsPrint textonly
  462.   DetailPrint "Installing Graphics..."
  463.   SetDetailsPrint listonly
  464.  
  465.   SectionIn 1
  466.  
  467.   Delete $INSTDIR\Contrib\Icons\*.ico
  468.   Delete $INSTDIR\Contrib\Icons\*.bmp
  469.   RMDir $INSTDIR\Contrib\Icons
  470.   SetOutPath $INSTDIR\Contrib\Graphics
  471.   File /r "..\Contrib\Graphics\*.ico"
  472.   File /r "..\Contrib\Graphics\*.bmp"
  473. ${MementoSectionEnd}
  474.  
  475. ${MementoSection} "Language Files" SecLangFiles
  476.  
  477.   SetDetailsPrint textonly
  478.   DetailPrint "Installing Language Files..."
  479.   SetDetailsPrint listonly
  480.  
  481.   SectionIn 1
  482.  
  483.   SetOutPath "$INSTDIR\Contrib\Language files"
  484.   File "..\Contrib\Language files\*.nlf"
  485.  
  486.   SetOutPath $INSTDIR\Bin
  487.   File ..\Bin\MakeLangID.exe
  488.  
  489.   !insertmacro SectionFlagIsSet ${SecInterfacesModernUI} ${SF_SELECTED} mui nomui
  490.   mui:
  491.     SetOutPath "$INSTDIR\Contrib\Language files"
  492.     File "..\Contrib\Language files\*.nsh"
  493.   nomui:
  494.  
  495. ${MementoSectionEnd}
  496.  
  497. SectionGroup "Tools" SecTools
  498.  
  499. ${MementoSection} "Zip2Exe" SecToolsZ2E
  500.  
  501.   SetDetailsPrint textonly
  502.   DetailPrint "Installing Tools | Zip2Exe..."
  503.   SetDetailsPrint listonly
  504.  
  505.   SectionIn 1
  506.  
  507.   SetOutPath $INSTDIR\Bin
  508.   File ..\Bin\zip2exe.exe
  509.   SetOutPath $INSTDIR\Contrib\zip2exe
  510.   File ..\Contrib\zip2exe\Base.nsh
  511.   File ..\Contrib\zip2exe\Modern.nsh
  512.   File ..\Contrib\zip2exe\Classic.nsh
  513.  
  514. ${MementoSectionEnd}
  515.  
  516. SectionGroupEnd
  517.  
  518. SectionGroup "Plug-ins" SecPluginsPlugins
  519.  
  520. ${MementoSection} "Banner" SecPluginsBanner
  521.  
  522.   SetDetailsPrint textonly
  523.   DetailPrint "Installing Plug-ins | Banner..."
  524.   SetDetailsPrint listonly
  525.  
  526.   SectionIn 1
  527.  
  528.   SetOutPath $INSTDIR\Plugins
  529.   File ..\Plugins\Banner.dll
  530.   SetOutPath $INSTDIR\Docs\Banner
  531.   File ..\Docs\Banner\Readme.txt
  532.   SetOutPath $INSTDIR\Examples\Banner
  533.   File ..\Examples\Banner\Example.nsi
  534. ${MementoSectionEnd}
  535.  
  536. ${MementoSection} "Language DLL" SecPluginsLangDLL
  537.  
  538.   SetDetailsPrint textonly
  539.   DetailPrint "Installing Plug-ins | Language DLL..."
  540.   SetDetailsPrint listonly
  541.  
  542.   SectionIn 1
  543.   SetOutPath $INSTDIR\Plugins
  544.   File ..\Plugins\LangDLL.dll
  545. ${MementoSectionEnd}
  546.  
  547. ${MementoSection} "nsExec" SecPluginsnsExec
  548.  
  549.   SetDetailsPrint textonly
  550.   DetailPrint "Installing Plug-ins | nsExec..."
  551.   SetDetailsPrint listonly
  552.  
  553.   SectionIn 1
  554.  
  555.   SetOutPath $INSTDIR\Plugins
  556.   File ..\Plugins\nsExec.dll
  557.   SetOutPath $INSTDIR\Docs\nsExec
  558.   File ..\Docs\nsExec\nsExec.txt
  559.   SetOutPath $INSTDIR\Examples\nsExec
  560.   File ..\Examples\nsExec\test.nsi
  561. ${MementoSectionEnd}
  562.  
  563. ${MementoSection} "Splash" SecPluginsSplash
  564.  
  565.   SetDetailsPrint textonly
  566.   DetailPrint "Installing Plug-ins | Splash..."
  567.   SetDetailsPrint listonly
  568.  
  569.   SectionIn 1
  570.  
  571.   SetOutPath $INSTDIR\Plugins
  572.   File ..\Plugins\splash.dll
  573.   SetOutPath $INSTDIR\Docs\Splash
  574.   File ..\Docs\Splash\splash.txt
  575.   SetOutPath $INSTDIR\Examples\Splash
  576.   File ..\Examples\Splash\Example.nsi
  577. ${MementoSectionEnd}
  578.  
  579. ${MementoSection} "AdvSplash" SecPluginsSplashT
  580.  
  581.   SetDetailsPrint textonly
  582.   DetailPrint "Installing Plug-ins | AdvSplash..."
  583.   SetDetailsPrint listonly
  584.  
  585.   SectionIn 1
  586.  
  587.   SetOutPath $INSTDIR\Plugins
  588.   File ..\Plugins\advsplash.dll
  589.   SetOutPath $INSTDIR\Docs\AdvSplash
  590.   File ..\Docs\AdvSplash\advsplash.txt
  591.   SetOutPath $INSTDIR\Examples\AdvSplash
  592.   File ..\Examples\AdvSplash\Example.nsi
  593. ${MementoSectionEnd}
  594.  
  595. ${MementoSection} "BgImage" SecPluginsBgImage
  596.  
  597.   SetDetailsPrint textonly
  598.   DetailPrint "Installing Plug-ins | BgImage..."
  599.   SetDetailsPrint listonly
  600.  
  601.   SectionIn 1
  602.  
  603.   SetOutPath $INSTDIR\Plugins
  604.   File ..\Plugins\BgImage.dll
  605.   SetOutPath $INSTDIR\Docs\BgImage
  606.   File ..\Docs\BgImage\BgImage.txt
  607.   SetOutPath $INSTDIR\Examples\BgImage
  608.   File ..\Examples\BgImage\Example.nsi
  609. ${MementoSectionEnd}
  610.  
  611. ${MementoSection} "InstallOptions" SecPluginsIO
  612.  
  613.   SetDetailsPrint textonly
  614.   DetailPrint "Installing Plug-ins | InstallOptions..."
  615.   SetDetailsPrint listonly
  616.  
  617.   SectionIn 1
  618.  
  619.   SetOutPath $INSTDIR\Plugins
  620.   File ..\Plugins\InstallOptions.dll
  621.   SetOutPath $INSTDIR\Docs\InstallOptions
  622.   File ..\Docs\InstallOptions\Readme.html
  623.   File ..\Docs\InstallOptions\Changelog.txt
  624.   SetOutPath $INSTDIR\Examples\InstallOptions
  625.   File ..\Examples\InstallOptions\test.ini
  626.   File ..\Examples\InstallOptions\test.nsi
  627.   File ..\Examples\InstallOptions\testimgs.ini
  628.   File ..\Examples\InstallOptions\testimgs.nsi
  629.   File ..\Examples\InstallOptions\testlink.ini
  630.   File ..\Examples\InstallOptions\testlink.nsi
  631.   File ..\Examples\InstallOptions\testnotify.ini
  632.   File ..\Examples\InstallOptions\testnotify.nsi
  633. ${MementoSectionEnd}
  634.  
  635. ${MementoSection} "nsDialogs" SecPluginsDialogs
  636.  
  637.   SetDetailsPrint textonly
  638.   DetailPrint "Installing Plug-ins | nsDialogs..."
  639.   SetDetailsPrint listonly
  640.  
  641.   SectionIn 1
  642.  
  643.   SetOutPath $INSTDIR\Plugins
  644.   File ..\Plugins\nsDialogs.dll
  645.   SetOutPath $INSTDIR\Examples\nsDialogs
  646.   File ..\Examples\nsDialogs\example.nsi
  647.   File ..\Examples\nsDialogs\InstallOptions.nsi
  648.   File ..\Examples\nsDialogs\timer.nsi
  649.   File ..\Examples\nsDialogs\welcome.nsi
  650.   SetOutPath $INSTDIR\Include
  651.   File ..\Include\nsDialogs.nsh
  652.   SetOutPath $INSTDIR\Docs\nsDialogs
  653.   File ..\Docs\nsDialogs\Readme.html
  654. ${MementoSectionEnd}
  655.  
  656. ${MementoSection} "Math" SecPluginsMath
  657.  
  658.   SetDetailsPrint textonly
  659.   DetailPrint "Installing Plug-ins | Math..."
  660.   SetDetailsPrint listonly
  661.  
  662.   SectionIn 1
  663.  
  664.   SetOutPath $INSTDIR\Plugins
  665.   File ..\Plugins\Math.dll
  666.   SetOutPath $INSTDIR\Docs\Math
  667.   File ..\Docs\Math\Math.txt
  668.   SetOutPath $INSTDIR\Examples\Math
  669.   File ..\Examples\Math\math.nsi
  670.   File ..\Examples\Math\mathtest.txt
  671.   File ..\Examples\Math\mathtest.nsi
  672.   File ..\Examples\Math\mathtest.ini
  673.  
  674. ${MementoSectionEnd}
  675.  
  676. ${MementoSection} "NSISdl" SecPluginsNSISDL
  677.  
  678.   SetDetailsPrint textonly
  679.   DetailPrint "Installing Plug-ins | NSISdl..."
  680.   SetDetailsPrint listonly
  681.  
  682.   SectionIn 1
  683.  
  684.   SetOutPath $INSTDIR\Plugins
  685.   File ..\Plugins\nsisdl.dll
  686.   SetOutPath $INSTDIR\Docs\NSISdl
  687.   File ..\Docs\NSISdl\ReadMe.txt
  688.   File ..\Docs\NSISdl\License.txt
  689. ${MementoSectionEnd}
  690.  
  691. ${MementoSection} "System" SecPluginsSystem
  692.  
  693.   SetDetailsPrint textonly
  694.   DetailPrint "Installing Plug-ins | System..."
  695.   SetDetailsPrint listonly
  696.  
  697.   SectionIn 1
  698.  
  699.   SetOutPath $INSTDIR\Plugins
  700.   File ..\Plugins\System.dll
  701.   SetOutPath $INSTDIR\Docs\System
  702.   File ..\Docs\System\System.html
  703.   File ..\Docs\System\WhatsNew.txt
  704.   SetOutPath $INSTDIR\Examples\System
  705.   File ..\Examples\System\Resource.dll
  706.   File ..\Examples\System\SysFunc.nsh
  707.   File ..\Examples\System\System.nsh
  708.   File ..\Examples\System\System.nsi
  709. ${MementoSectionEnd}
  710.  
  711. ${MementoSection} "StartMenu" SecPluginsStartMenu
  712.  
  713.   SetDetailsPrint textonly
  714.   DetailPrint "Installing Plug-ins | StartMenu..."
  715.   SetDetailsPrint listonly
  716.  
  717.   SectionIn 1
  718.  
  719.   SetOutPath $INSTDIR\Plugins
  720.   File ..\Plugins\StartMenu.dll
  721.   SetOutPath $INSTDIR\Docs\StartMenu
  722.   File ..\Docs\StartMenu\Readme.txt
  723.   SetOutPath $INSTDIR\Examples\StartMenu
  724.   File ..\Examples\StartMenu\Example.nsi
  725. ${MementoSectionEnd}
  726.  
  727. ${MementoSection} "UserInfo" SecPluginsUserInfo
  728.  
  729.   SetDetailsPrint textonly
  730.   DetailPrint "Installing Plug-ins | UserInfo..."
  731.   SetDetailsPrint listonly
  732.  
  733.   SectionIn 1
  734.  
  735.   SetOutPath $INSTDIR\Plugins
  736.   File ..\Plugins\UserInfo.dll
  737.   SetOutPath $INSTDIR\Examples\UserInfo
  738.   File ..\Examples\UserInfo\UserInfo.nsi
  739. ${MementoSectionEnd}
  740.  
  741. ${MementoSection} "Dialer" SecPluginsDialer
  742.  
  743.   SetDetailsPrint textonly
  744.   DetailPrint "Installing Plug-ins | Dialer..."
  745.   SetDetailsPrint listonly
  746.  
  747.   SectionIn 1
  748.  
  749.   SetOutPath $INSTDIR\Plugins
  750.   File ..\Plugins\Dialer.dll
  751.   SetOutPath $INSTDIR\Docs\Dialer
  752.   File ..\Docs\Dialer\Dialer.txt
  753. ${MementoSectionEnd}
  754.  
  755. ${MementoSection} "VPatch" SecPluginsVPatch
  756.  
  757.   SetDetailsPrint textonly
  758.   DetailPrint "Installing Plug-ins | VPatch..."
  759.   SetDetailsPrint listonly
  760.  
  761.   SectionIn 1
  762.  
  763.   SetOutPath $INSTDIR\Plugins
  764.   File ..\Plugins\VPatch.dll
  765.   SetOutPath $INSTDIR\Examples\VPatch
  766.   File ..\Examples\VPatch\example.nsi
  767.   File ..\Examples\VPatch\oldfile.txt
  768.   File ..\Examples\VPatch\newfile.txt
  769.   File ..\Examples\VPatch\patch.pat
  770.   SetOutPath $INSTDIR\Docs\VPatch
  771.   File ..\Docs\VPatch\Readme.html
  772.   SetOutPath $INSTDIR\Bin
  773.   File ..\Bin\GenPat.exe
  774.   SetOutPath $INSTDIR\Include
  775.   File ..\Include\VPatchLib.nsh
  776. ${MementoSectionEnd}
  777.  
  778. ${MementoSectionDone}
  779.  
  780. SectionGroupEnd
  781.  
  782. Section -post
  783.  
  784.   ; When Modern UI is installed:
  785.   ; * Always install the English language file
  786.   ; * Always install default icons / bitmaps
  787.  
  788.   !insertmacro SectionFlagIsSet ${SecInterfacesModernUI} ${SF_SELECTED} mui nomui
  789.  
  790.     mui:
  791.  
  792.     SetDetailsPrint textonly
  793.     DetailPrint "Configuring Modern UI..."
  794.     SetDetailsPrint listonly
  795.  
  796.     !insertmacro SectionFlagIsSet ${SecLangFiles} ${SF_SELECTED} langfiles nolangfiles
  797.  
  798.       nolangfiles:
  799.  
  800.       SetOutPath "$INSTDIR\Contrib\Language files"
  801.       File "..\Contrib\Language files\English.nlf"
  802.       SetOutPath "$INSTDIR\Contrib\Language files"
  803.       File "..\Contrib\Language files\English.nsh"
  804.  
  805.     langfiles:
  806.  
  807.     !insertmacro SectionFlagIsSet ${SecGraphics} ${SF_SELECTED} graphics nographics
  808.  
  809.       nographics:
  810.  
  811.       SetOutPath $INSTDIR\Contrib\Graphics
  812.       SetOutPath $INSTDIR\Contrib\Graphics\Checks
  813.       File "..\Contrib\Graphics\Checks\modern.bmp"
  814.       SetOutPath $INSTDIR\Contrib\Graphics\Icons
  815.       File "..\Contrib\Graphics\Icons\modern-install.ico"
  816.       File "..\Contrib\Graphics\Icons\modern-uninstall.ico"
  817.       SetOutPath $INSTDIR\Contrib\Graphics\Header
  818.       File "..\Contrib\Graphics\Header\nsis.bmp"
  819.       SetOutPath $INSTDIR\Contrib\Graphics\Wizard
  820.       File "..\Contrib\Graphics\Wizard\win.bmp"
  821.  
  822.     graphics:
  823.  
  824.   nomui:
  825.  
  826.   SetDetailsPrint textonly
  827.   DetailPrint "Creating Registry Keys..."
  828.   SetDetailsPrint listonly
  829.  
  830.   SetOutPath $INSTDIR
  831.  
  832.   WriteRegStr SHCTX "Software\NSIS" "" $INSTDIR
  833. !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
  834.   WriteRegDword SHCTX "Software\NSIS" "VersionMajor" "${VER_MAJOR}"
  835.   WriteRegDword SHCTX "Software\NSIS" "VersionMinor" "${VER_MINOR}"
  836.   WriteRegDword SHCTX "Software\NSIS" "VersionRevision" "${VER_REVISION}"
  837.   WriteRegDword SHCTX "Software\NSIS" "VersionBuild" "${VER_BUILD}"
  838. !endif
  839.  
  840.   WriteRegExpandStr SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "UninstallString" '"$INSTDIR\uninst-nsis.exe"'
  841.   WriteRegExpandStr SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "InstallLocation" "$INSTDIR"
  842.   WriteRegStr SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "DisplayName" "Nullsoft Install System"
  843.   WriteRegStr SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "DisplayIcon" "$INSTDIR\NSIS.exe,0"
  844.   WriteRegStr SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "DisplayVersion" "${VERSION}"
  845.   WriteRegStr SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "URLInfoAbout" "http://nsis.sourceforge.net/"
  846.   WriteRegStr SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "HelpLink" "http://nsis.sourceforge.net/Support"
  847. !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
  848.   WriteRegDWORD SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "VersionMajor" "${VER_MAJOR}"
  849.   WriteRegDWORD SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "VersionMinor" "${VER_MINOR}.${VER_REVISION}"
  850. !endif
  851.   WriteRegDWORD SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "NoModify" "1"
  852.   WriteRegDWORD SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "NoRepair" "1"
  853.  
  854.   WriteUninstaller $INSTDIR\uninst-nsis.exe
  855.  
  856.   ;Save InstMode in uninstaller
  857.   FileOpen $0 "$INSTDIR\uninst-nsis.exe" a
  858.   FileSeek $0 0 END
  859.   FileWrite $0 "$\n@INSTMODE=$InstMode$\n"
  860.   FileClose $0
  861.  
  862.   ${MementoSectionSave}
  863.  
  864.   SetDetailsPrint both
  865.  
  866. SectionEnd
  867.  
  868. ;--------------------------------
  869. ;Descriptions
  870.  
  871. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  872.   !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "The core files required to use NSIS (compiler etc.)"
  873.   !insertmacro MUI_DESCRIPTION_TEXT ${SecExample} "Example installation scripts that show you how to use NSIS"
  874.   !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} "Adds icons to your start menu and your desktop for easy access"
  875.   !insertmacro MUI_DESCRIPTION_TEXT ${SecSMShortcuts} "Adds icons to your start menu"
  876.   !insertmacro MUI_DESCRIPTION_TEXT ${SecDeskShortcuts} "Adds a icon to your desktop for easy access"
  877.   !insertmacro MUI_DESCRIPTION_TEXT ${SecInterfaces} "User interface designs that can be used to change the installer look and feel"
  878.   !insertmacro MUI_DESCRIPTION_TEXT ${SecInterfacesModernUI} "A modern user interface like the wizards of recent Windows versions"
  879.   !insertmacro MUI_DESCRIPTION_TEXT ${SecInterfacesDefaultUI} "The default NSIS user interface which you can customize to make your own UI"
  880.   !insertmacro MUI_DESCRIPTION_TEXT ${SecInterfacesTinyUI} "A tiny version of the default user interface"
  881.   !insertmacro MUI_DESCRIPTION_TEXT ${SecTools} "Tools that help you with NSIS development"
  882.   !insertmacro MUI_DESCRIPTION_TEXT ${SecToolsZ2E} "A utility that converts a ZIP file to a NSIS installer"
  883.   !insertmacro MUI_DESCRIPTION_TEXT ${SecGraphics} "Icons, checkbox images and other graphics"
  884.   !insertmacro MUI_DESCRIPTION_TEXT ${SecLangFiles} "Language files used to support multiple languages in an installer"
  885.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsPlugins} "Useful plugins that extend NSIS's functionality"
  886.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsBanner} "Plugin that lets you show a banner before installation starts"
  887.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsLangDLL} "Plugin that lets you add a language select dialog to your installer"
  888.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsnsExec} "Plugin that executes console programs and prints its output in the NSIS log window or hides it"
  889.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsSplash} "Splash screen add-on that lets you add a splash screen to an installer"
  890.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsSplashT} "Splash screen add-on with transparency support that lets you add a splash screen to an installer"
  891.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsSystem} "Plugin that lets you call Win32 API or external DLLs"
  892.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsMath} "Plugin that lets you evaluate complicated mathematical expressions"
  893.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsDialer} "Plugin that provides internet connection functions"
  894.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsIO} "Plugin that lets you add custom pages to an installer"
  895.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsDialogs} "Plugin that lets you add custom pages to an installer"
  896.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsStartMenu} "Plugin that lets the user select the start menu folder"
  897.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsBgImage} "Plugin that lets you show a persistent background image plugin and play sounds"
  898.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsUserInfo} "Plugin that that gives you the user name and the user account type"
  899.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsNSISDL} "Plugin that lets you create a web based installer"
  900.   !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsVPatch} "Plugin that lets you create patches to upgrade older files"
  901. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  902.  
  903. ;--------------------------------
  904. ;Installer Functions
  905.  
  906. Function .onInit
  907.  
  908.   ${GetParameters} $0
  909.   ClearErrors
  910.   ${GetOptions} $0 "/AllUsers" $1
  911.   ${IfNot} ${Errors}
  912.     StrCpy $InstMode 2
  913.   ${Else}
  914.     ${GetOptions} $0 "/CurrentUser" $1
  915.     ${IfNot} ${Errors}
  916.       StrCpy $InstMode 1
  917.     ${EndIf}
  918.   ${EndIf}
  919.  
  920.   UserInfo::GetAccountType
  921.  Pop $0
  922.  
  923.   ;We block single user installs on Win9x and NT4, we cannot continue if we are not admin
  924.   ${IfNot} ${AtLeastWin2000}
  925.   ${AndIf} $0 != "admin"
  926.     MessageBox MB_IconStop "Administrator privileges required!"
  927.     SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
  928.     Quit
  929.   ${EndIf}
  930.  
  931.   ;If /D was not used, try to find existing install
  932.   ${If} $Instdir == ""
  933.     ReadRegStr $InstModeDefUserDir HKCU "Software\NSIS" ""
  934.     ${IfThen} $InstModeDefUserDir == "" ${|} ReadRegStr $InstModeDefUserDir HKCU "${REGPATH_MSWIN_UNINST}\NSIS" "InstallLocation" ${|}
  935.     ${If} $InstModeDefUserDir != ""
  936.       StrCpy $InstMode 1
  937.     ${ElseIf} $0 == "admin"
  938.       ReadRegStr $InstModeDefMachineDir HKLM "Software\NSIS" ""
  939.       ${IfThen} $InstModeDefMachineDir == "" ${|} ReadRegStr $InstModeDefMachineDir HKLM "${REGPATH_MSWIN_UNINST}\NSIS" "InstallLocation" ${|}
  940.       ${If} $InstModeDefMachineDir != ""
  941.         StrCpy $InstMode 2
  942.       ${EndIf}
  943.     ${EndIf}
  944.   ${EndIf}
  945.  
  946.   ${IfThen} $InstModeDefUserDir    == "" ${|} StrCpy $InstModeDefUserDir    "$LOCALAPPDATA\Programs\NSIS" ${|}
  947.   ${IfThen} $InstModeDefMachineDir == "" ${|} StrCpy $InstModeDefMachineDir "$PROGRAMFILES\NSIS" ${|}
  948.  
  949.   ${If} $InstMode = 0
  950.     StrCpy $InstMode 1
  951.     ;Old installers only supported all user installs, prefer that if possible
  952.     ${IfThen} $0 == "admin" ${|} StrCpy $InstMode 2 ${|}
  953.   ${EndIf}
  954.  
  955.   ${If} $InstMode = 1
  956.     ;Implied: SetShellVarContext current
  957.     StrCpy $1 $InstModeDefUserDir
  958.   ${Else}
  959.     SetShellVarContext all
  960.     StrCpy $1 $InstModeDefMachineDir
  961.   ${EndIf}
  962.   ${IfThen} $Instdir == "" ${|} StrCpy $Instdir $1 ${|}
  963.  
  964.   ${MementoSectionRestore}
  965.  
  966. FunctionEnd
  967.  
  968. Function un.onInit
  969.  
  970.   ;Implied: ClearErrors
  971.   FileOpen $0 "$EXEPATH" r
  972.   FileSeek $0 -20 END ;-20 is more than enough for our single property
  973.   next:
  974.     FileRead $0 $1
  975.     IfErrors done
  976.     StrCpy $2 $1 10
  977.     StrCmp $2 "@INSTMODE=" 0 next
  978.     StrCpy $InstMode $1 -1 10 ;Remove "@name=" prefix and $\n suffix
  979.   done:
  980.   FileClose $0
  981.  
  982.   ;Implied: SetShellVarContext current
  983.   ${If} $InstMode <> 1
  984.     SetShellVarContext all
  985.     UserInfo::GetAccountType
  986.    Pop $0
  987.     ${If} $0 != "admin"
  988.       MessageBox MB_IconStop "Administrator privileges required!"
  989.       SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
  990.       Quit
  991.     ${EndIf}
  992.   ${EndIf}
  993.  
  994. FunctionEnd
  995.  
  996.  
  997. Function PageInstallmode
  998.   !insertmacro MUI_HEADER_TEXT "$(PageInstallmodeCaption)" "$(MULTIUSER_TEXT_INSTALLMODE_SUBTITLE)"
  999.   nsDialogs::Create 1018
  1000.   Pop $0
  1001.  
  1002.   ${NSD_CreateLabel} 0u 0u 300u 20u "$(MULTIUSER_INNERTEXT_INSTALLMODE_TOP)"
  1003.   Pop $0
  1004.  
  1005.   ${NSD_CreateRadioButton} 20u 50u 280u 10u "$(MULTIUSER_INNERTEXT_INSTALLMODE_ALLUSERS)"
  1006.   Pop $1
  1007.    
  1008.   ${NSD_CreateRadioButton} 20u 70u 280u 10u "$(MULTIUSER_INNERTEXT_INSTALLMODE_CURRENTUSER)"
  1009.   Pop $2
  1010.  
  1011.   StrCpy $3 $1
  1012.   ${If} $InstMode = 1
  1013.     StrCpy $3 $2
  1014.   ${EndIf}
  1015.  
  1016.   UserInfo::GetAccountType
  1017.  Pop $0
  1018.   ${If} $0 != "admin"
  1019.       StrCpy $3 $2 ;We are not admin, set current user radio
  1020.       EnableWindow $1 0
  1021.   ${EndIf}
  1022.  
  1023.   ;HKCU\...\Uninstall and HKCU to HKCR mapping does not work on older systems
  1024.   ${IfNot} ${AtLeastWin2000}
  1025.     EnableWindow $2 0
  1026.   ${EndIf}
  1027.  
  1028.   ${NSD_SetFocus} $3
  1029.   SendMessage $3 ${BM_CLICK} 0 0
  1030.  
  1031.   nsDialogs::Show
  1032. FunctionEnd
  1033.  
  1034. Function PageLeaveInstallmode
  1035. SendMessage $1 ${BM_GETCHECK} 0 0 $0
  1036. ${If} $0 = ${BST_CHECKED}
  1037.   StrCpy $InstMode 2
  1038.   SetShellVarContext all
  1039.   StrCpy $InstDir $InstModeDefMachineDir
  1040. ${Else}
  1041.   StrCpy $InstMode 1
  1042.   SetShellVarContext current
  1043.   StrCpy $InstDir $InstModeDefUserDir
  1044. ${EndIf}
  1045. FunctionEnd
  1046.  
  1047. !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
  1048.  
  1049. Var /Global ReinstallPageCheck
  1050.  
  1051. Function PageReinstall
  1052.  
  1053.   ReadRegStr $R0 SHCTX "Software\NSIS" ""
  1054.  
  1055.   ${If} $R0 == ""
  1056.     Abort
  1057.   ${EndIf}
  1058.  
  1059.   ReadRegDWORD $R0 SHCTX "Software\NSIS" "VersionMajor"
  1060.   ReadRegDWORD $R1 SHCTX "Software\NSIS" "VersionMinor"
  1061.   ReadRegDWORD $R2 SHCTX "Software\NSIS" "VersionRevision"
  1062.   ReadRegDWORD $R3 SHCTX "Software\NSIS" "VersionBuild"
  1063.   StrCpy $R0 $R0.$R1.$R2.$R3
  1064.  
  1065.   ${VersionCompare} ${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}.${VER_BUILD} $R0 $R0
  1066.   ${If} $R0 == 0
  1067.     StrCpy $R1 "NSIS ${VERSION} is already installed. Select the operation you want to perform and click Next to continue."
  1068.     StrCpy $R2 "Add/Reinstall components"
  1069.     StrCpy $R3 "Uninstall NSIS"
  1070.     !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform."
  1071.     StrCpy $R0 "2"
  1072.   ${ElseIf} $R0 == 1
  1073.     StrCpy $R1 "An older version of NSIS is installed on your system. It's recommended that you uninstall the current version before installing. Select the operation you want to perform and click Next to continue."
  1074.     StrCpy $R2 "Uninstall before installing"
  1075.     StrCpy $R3 "Do not uninstall"
  1076.     !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install NSIS."
  1077.     StrCpy $R0 "1"
  1078.   ${ElseIf} $R0 == 2
  1079.     StrCpy $R1 "A newer version of NSIS is already installed! It is not recommended that you install an older version. If you really want to install this older version, it's better to uninstall the current version first. Select the operation you want to perform and click Next to continue."
  1080.     StrCpy $R2 "Uninstall before installing"
  1081.     StrCpy $R3 "Do not uninstall"
  1082.     !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install NSIS."
  1083.     StrCpy $R0 "1"
  1084.   ${Else}
  1085.     Abort
  1086.   ${EndIf}
  1087.  
  1088.   nsDialogs::Create 1018
  1089.   Pop $R4
  1090.  
  1091.   ${NSD_CreateLabel} 0 0 100% 24u $R1
  1092.   Pop $R1
  1093.  
  1094.   ${NSD_CreateRadioButton} 30u 50u -30u 8u $R2
  1095.   Pop $R2
  1096.   ${NSD_OnClick} $R2 PageReinstallUpdateSelection
  1097.  
  1098.   ${NSD_CreateRadioButton} 30u 70u -30u 8u $R3
  1099.   Pop $R3
  1100.   ${NSD_OnClick} $R3 PageReinstallUpdateSelection
  1101.  
  1102.   ${If} $ReinstallPageCheck != 2
  1103.     SendMessage $R2 ${BM_SETCHECK} ${BST_CHECKED} 0
  1104.   ${Else}
  1105.     SendMessage $R3 ${BM_SETCHECK} ${BST_CHECKED} 0
  1106.   ${EndIf}
  1107.  
  1108.   ${NSD_SetFocus} $R2
  1109.  
  1110.   nsDialogs::Show
  1111.  
  1112. FunctionEnd
  1113.  
  1114. Function PageReinstallUpdateSelection
  1115.  
  1116.   Pop $R1
  1117.  
  1118.   ${NSD_GetState} $R2 $R1
  1119.  
  1120.   ${If} $R1 == ${BST_CHECKED}
  1121.     StrCpy $ReinstallPageCheck 1
  1122.   ${Else}
  1123.     StrCpy $ReinstallPageCheck 2
  1124.   ${EndIf}
  1125.  
  1126. FunctionEnd
  1127.  
  1128. Function PageLeaveReinstall
  1129.  
  1130.   ${NSD_GetState} $R2 $R1
  1131.  
  1132.   StrCmp $R0 "1" 0 +2
  1133.     StrCmp $R1 "1" reinst_uninstall reinst_done
  1134.  
  1135.   StrCmp $R0 "2" 0 +3
  1136.     StrCmp $R1 "1" reinst_done reinst_uninstall
  1137.  
  1138.   reinst_uninstall:
  1139.   ReadRegStr $R1 SHCTX "${REGPATH_MSWIN_UNINST}\NSIS" "UninstallString"
  1140.  
  1141.   ;Run uninstaller
  1142.   HideWindow
  1143.  
  1144.     ClearErrors
  1145.     ExecWait '$R1 _?=$INSTDIR'
  1146.  
  1147.     IfErrors no_remove_uninstaller
  1148.     IfFileExists "$INSTDIR\Bin\makensis.exe" no_remove_uninstaller
  1149.  
  1150.       Delete $R1
  1151.       RMDir $INSTDIR
  1152.  
  1153.     no_remove_uninstaller:
  1154.  
  1155.   StrCmp $R0 "2" 0 +2
  1156.     Quit
  1157.  
  1158.   BringToFront
  1159.  
  1160.   reinst_done:
  1161.  
  1162. FunctionEnd
  1163.  
  1164. !endif # VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
  1165.  
  1166. Function ShowReleaseNotes
  1167.   StrCpy $0 $WINDIR\hh.exe
  1168.   ${IfNot} ${FileExists} $0
  1169.     SearchPath $0 hh.exe
  1170.   ${EndIf}
  1171.   ${If} ${FileExists} $0
  1172.     Exec '"$0" mk:@MSITStore:$INSTDIR\NSIS.chm::/SectionF.1.html'
  1173.   ${Else}
  1174.     ExecShell "" "http://nsis.sourceforge.net/Docs/AppendixF.html#F.1"
  1175.   ${EndIf}
  1176. FunctionEnd
  1177.  
  1178. ;--------------------------------
  1179. ;Uninstaller Section
  1180.  
  1181. Section Uninstall
  1182.  
  1183.   SetDetailsPrint textonly
  1184.   DetailPrint "Uninstalling NSIS Development Shell Extensions..."
  1185.   SetDetailsPrint listonly
  1186.  
  1187.   IfFileExists $INSTDIR\Bin\makensis.exe nsis_installed
  1188.     MessageBox MB_YESNO "It does not appear that NSIS is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES nsis_installed
  1189.     Abort "Uninstall aborted by user"
  1190.   nsis_installed:
  1191.  
  1192.   SetDetailsPrint textonly
  1193.   DetailPrint "Deleting Registry Keys..."
  1194.   SetDetailsPrint listonly
  1195.  
  1196.   !macro FileType_UnregisterDefaultNSISOpenVerb ProgID
  1197.   ReadRegStr $0 SHCTX "Software\Classes\${ProgID}\shell\open\command" ""
  1198.   ${If} $0 == 'notepad.exe "%1"'
  1199.     DeleteRegKey SHCTX "Software\Classes\${ProgID}\shell\open"
  1200.   ${EndIf}
  1201.   !macroend
  1202.  
  1203.   !insertmacro FileType_UnregisterDefaultNSISOpenVerb "NSIS.Script"
  1204.   !insertmacro FileType_UnregisterDefaultNSISOpenVerb "NSIS.Header"
  1205.  
  1206.   DeleteRegKey SHCTX "Software\Classes\NSIS.Script\shell\compile"
  1207.   DeleteRegKey SHCTX "Software\Classes\NSIS.Script\shell\compile-compressor"
  1208.   StrLen $1 $INSTDIR
  1209.   ReadRegStr $0 SHCTX "Software\Classes\NSIS.Script\DefaultIcon" ""
  1210.   StrCpy $0 $0 $1
  1211.   StrCmp $0 $INSTDIR "" +2
  1212.     DeleteRegKey SHCTX "Software\Classes\NSIS.Script\DefaultIcon"
  1213.   DeleteRegKey /IfEmpty SHCTX "Software\Classes\NSIS.Script\shell"
  1214.   DeleteRegKey /IfEmpty SHCTX "Software\Classes\NSIS.Script"
  1215.  
  1216.   ;Assuming length of $INSTDIR is still in $1
  1217.   ReadRegStr $0 SHCTX "Software\Classes\NSIS.Header\DefaultIcon" ""
  1218.   StrCpy $0 $0 $1
  1219.   StrCmp $0 $INSTDIR "" +2
  1220.     DeleteRegKey SHCTX "Software\Classes\NSIS.Header\DefaultIcon"
  1221.   DeleteRegKey /IfEmpty SHCTX "Software\Classes\NSIS.Header\shell"
  1222.   DeleteRegKey /IfEmpty SHCTX "Software\Classes\NSIS.Header"
  1223.  
  1224.   !macro FileType_UnregisterExt dotExt ProgID
  1225.     ;Is the .ext still using our ProgID?
  1226.     ReadRegStr $0 SHCTX "Software\Classes\${dotExt}" ""
  1227.     StrCmp $0 "${ProgID}" 0 filetype_keep_${dotExt}
  1228.       ;Has someone else added keys to the ProgID?
  1229.       EnumRegKey $0 SHCTX "Software\Classes\${ProgID}" ""
  1230.       StrCmp $0 "" 0 filetype_keep_${dotExt}
  1231.         DeleteRegValue SHCTX "Software\Classes\${dotExt}" ""
  1232.         DeleteRegKey /IfEmpty SHCTX "Software\Classes\${dotExt}" ;Don't delete HKCR\.ext\OpenWithProgIDs etc
  1233.     filetype_keep_${dotExt}:
  1234.   !macroend
  1235.  
  1236.   !insertmacro FileType_UnregisterExt .nsi "NSIS.Script"
  1237.   !insertmacro FileType_UnregisterExt .nsh "NSIS.Header"
  1238.  
  1239.   System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)'
  1240.  
  1241.   DeleteRegKey SHCTX "${REGPATH_MSWIN_UNINST}\NSIS"
  1242.   DeleteRegKey SHCTX "Software\NSIS"
  1243.  
  1244.   SetDetailsPrint textonly
  1245.   DetailPrint "Deleting Files..."
  1246.   SetDetailsPrint listonly
  1247.  
  1248.   Delete $SMPROGRAMS\NSIS.lnk
  1249.   Delete $DESKTOP\NSIS.lnk
  1250.   Delete $INSTDIR\makensis.exe
  1251.   Delete $INSTDIR\makensisw.exe
  1252.   Delete $INSTDIR\NSIS.exe
  1253.   Delete $INSTDIR\NSIS.exe.manifest
  1254.   Delete $INSTDIR\license.txt
  1255.   Delete $INSTDIR\COPYING
  1256.   Delete $INSTDIR\uninst-nsis.exe
  1257.   Delete $INSTDIR\nsisconf.nsi
  1258.   Delete $INSTDIR\nsisconf.nsh
  1259.   Delete $INSTDIR\NSIS.chm
  1260.   RMDir /r $INSTDIR\Bin
  1261.   RMDir /r $INSTDIR\Contrib
  1262.   RMDir /r $INSTDIR\Docs
  1263.   RMDir /r $INSTDIR\Examples
  1264.   RMDir /r $INSTDIR\Include
  1265.   RMDir /r $INSTDIR\Menu
  1266.   RMDir /r $INSTDIR\Plugins
  1267.   RMDir /r $INSTDIR\Stubs
  1268.   RMDir $INSTDIR
  1269.  
  1270.   SetDetailsPrint both
  1271.  
  1272. SectionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement