Advertisement
Anders

makensis2011 / Future

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