experienceui-setup.nsi
changeset 14 61f1654b7734
child 15 d3e8fdadd6d6
equal deleted inserted replaced
13:2ae1abe546fd 14:61f1654b7734
       
     1 ; ExperienceUI installation
       
     2 Name "ExperienceUI SDK"
       
     3 
       
     4 SetCompressor /final /solid lzma
       
     5 
       
     6 !define XPUI_SYSDIR ".\Contrib\ExperienceUI"
       
     7 !include "${XPUI_SYSDIR}\XPUI.nsh"
       
     8 OutFile "experienceui-${XPUI_VERSION}.exe"
       
     9 InstallDir "$PROGRAMFILES\NSIS\ExperienceUI"
       
    10 InstallDirRegKey HKLM "Software\NSIS\ExperienceUI" ""
       
    11 RequestExecutionLevel admin
       
    12 
       
    13 ${Page} Welcome2
       
    14 ${LicensePage} "Contrib\ExperienceUI\License.rtf"
       
    15 ${Page} Directory
       
    16 ${Page} InstConfirm
       
    17 ${Page} InstFiles
       
    18 
       
    19 ${UnPage} Welcome2
       
    20 ${UnPage} UnConfirm
       
    21 ${UnPage} InstFiles
       
    22 ${UnPage} Finish
       
    23 
       
    24 ${Language} English
       
    25 
       
    26 Function .onInit
       
    27   ClearErrors
       
    28   ReadRegStr $0 HKLM "Software\NSIS" ""
       
    29   IfErrors 0 +2
       
    30     Return
       
    31     
       
    32   ; Set installation dir only if the ExUI is not installed
       
    33   ClearErrors
       
    34   ReadRegStr $R0 HKLM "Software\NSIS\ExperienceUI" ""
       
    35   IfErrors +2
       
    36     Return
       
    37     
       
    38   StrCpy $INSTDIR "$0\ExperienceUI"
       
    39 FunctionEnd
       
    40 
       
    41 Section
       
    42   SetOutPath $INSTDIR
       
    43   File /r Contrib
       
    44   File /r Docs
       
    45   File /r Examples
       
    46   File /r Include
       
    47   File /r Plugins
       
    48   
       
    49   ; Write install dir
       
    50   WriteRegStr HKLM "Software\NSIS\ExperienceUI" "" "$INSTDIR"
       
    51   
       
    52   ; Write uninstaller
       
    53   WriteUninstaller "$INSTDIR\uninstall-exui.exe"
       
    54   
       
    55   ; Registry stuff
       
    56   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" "DisplayName" "$(^Name)"
       
    57   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" "UninstallString" "$INSTDIR\uninstall-exui.exe"
       
    58   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" "DisplayIcon" "$INSTDIR\Contrib\Graphics\Icons\XPUI-install.ico"
       
    59   
       
    60   ; Register with NSIS
       
    61   ClearErrors
       
    62   ReadRegStr $0 HKLM "Software\NSIS" ""
       
    63   IfErrors 0 +3
       
    64     ; NSIS not found
       
    65     MessageBox MB_OK|MB_ICONEXCLAMATION "Setup did not detect NSIS on your system. Integrating the ExperienceUI with NSIS will be your job once you install NSIS."
       
    66     Return
       
    67     
       
    68   MessageBox MB_YESNO|MB_ICONQUESTION "Found NSIS installation at $0. Do you want to register the ExperienceUI SDK with this copy of NSIS?$\n$\n(If you don't, you'll have to specify the full path to XPUI.nsh in your scripts.)" IDYES +2
       
    69     Return
       
    70     
       
    71   ; Write in .nsh
       
    72   ; $0 = NSIS installation dir
       
    73   ClearErrors
       
    74   FileOpen $1  "$0\Include\XPUI.nsh" "w"
       
    75   FileWrite $1 "!define XPUI_SYSDIR $\"$INSTDIR\Contrib\ExperienceUI$\"$\r$\n"
       
    76   FileWrite $1 "!include $\"$$"
       
    77   ; stupid compiler bugs...
       
    78   FileWrite $1 "{XPUI_SYSDIR}\XPUI.nsh$\"$\r$\n"
       
    79   FileClose $0
       
    80 SectionEnd
       
    81 
       
    82 Section "Uninstall"
       
    83   Delete "$INSTDIR\uninstall-exui.exe"
       
    84   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
       
    85   DeleteRegKey HKLM "Software\NSIS\ExperienceUI"
       
    86   
       
    87   ; The goal here: completely clean up the ExperienceUI, but if
       
    88   ; there's other stuff, don't touch it
       
    89   
       
    90   ; Remember, only RmDir /r removes directories with files.
       
    91   ; Otherwise, it only removes fully empty directories.
       
    92 
       
    93   ; Contrib
       
    94   RmDir /r "$INSTDIR\Contrib\ExperienceUI"
       
    95   Delete "$INSTDIR\Contrib\Graphics\Icons\XPUI-install.ico"
       
    96   Delete "$INSTDIR\Contrib\Graphics\Icons\XPUI-uninstall.ico"
       
    97   RmDir  "$INSTDIR\Contrib\Graphics\Icons"
       
    98   RmDir  "$INSTDIR\Contrib\Graphics"
       
    99   RmDir  "$INSTDIR\Contrib"
       
   100   
       
   101   ; Docs
       
   102   RmDir /r "$INSTDIR\Docs\ExperienceUI"
       
   103   RmDir "$INSTDIR\Docs"
       
   104   
       
   105   ; Examples
       
   106   RmDir /r "$INSTDIR\Examples\ExperienceUI"
       
   107   RmDir "$INSTDIR\Examples"
       
   108   
       
   109   ; Include
       
   110   Delete "$INSTDIR\Include\NSISArray.nsh"
       
   111   Delete "$INSTDIR\Include\RecFind.nsh"
       
   112   Delete "$INSTDIR\Include\system.nsh"
       
   113   Delete "$INSTDIR\Include\XPUI.nsh"
       
   114   RmDir "$INSTDIR\Include"
       
   115   
       
   116   ; Plugins
       
   117   Delete "$INSTDIR\Plugins\DcryptDll.dll"
       
   118   Delete "$INSTDIR\Plugins\messagebox.dll"
       
   119   Delete "$INSTDIR\Plugins\newadvsplash.dll"
       
   120   Delete "$INSTDIR\Plugins\NSISArray.dll"
       
   121   Delete "$INSTDIR\Plugins\WAnsis.dll"
       
   122   Delete "$INSTDIR\Plugins\ZipDLL.dll"
       
   123   RmDir "$INSTDIR\Plugins"
       
   124   
       
   125   RmDir "$INSTDIR"
       
   126   
       
   127   ClearErrors
       
   128   ReadRegStr $0 HKLM "Software\NSIS" ""
       
   129   IfErrors +2
       
   130     Return
       
   131     
       
   132   Delete "$0\Include\XPUI.nsh"
       
   133   
       
   134 SectionEnd