⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 installer.nsi

📁 现在很火的邮件客户端软件thunderbird的源码
💻 NSI
📖 第 1 页 / 共 3 页
字号:
# ***** BEGIN LICENSE BLOCK *****# Version: MPL 1.1/GPL 2.0/LGPL 2.1## The contents of this file are subject to the Mozilla Public License Version# 1.1 (the "License"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at# http://www.mozilla.org/MPL/## Software distributed under the License is distributed on an "AS IS" basis,# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License# for the specific language governing rights and limitations under the# License.## The Original Code is the Mozilla Installer code.## The Initial Developer of the Original Code is Mozilla Foundation# Portions created by the Initial Developer are Copyright (C) 2006# the Initial Developer. All Rights Reserved.## Contributor(s):#  Robert Strong <robert.bugzilla@gmail.com>#  Scott MacGregor <mscott@mozilla.org>## Alternatively, the contents of this file may be used under the terms of# either the GNU General Public License Version 2 or later (the "GPL"), or# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),# in which case the provisions of the GPL or the LGPL are applicable instead# of those above. If you wish to allow use of your version of this file only# under the terms of either the GPL or the LGPL, and not to allow others to# use your version of this file under the terms of the MPL, indicate your# decision by deleting the provisions above and replace them with the notice# and other provisions required by the GPL or the LGPL. If you do not delete# the provisions above, a recipient may use your version of this file under# the terms of any one of the MPL, the GPL or the LGPL.## ***** END LICENSE BLOCK *****# Also requires:# ShellLink plugin http://nsis.sourceforge.net/ShellLink_plug-in; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs!verbose 3; 7-Zip provides better compression than the lzma from NSIS so we add the files; uncompressed and use 7-Zip to create a SFX archive of itSetDatablockOptimize onSetCompress offCRCCheck on!addplugindir ./; empty files - except for the comment line - for generating custom pages.!system 'echo ; > options.ini'!system 'echo ; > components.ini'!system 'echo ; > shortcuts.ini'Var TmpValVar StartMenuDirVar InstallTypeVar AddStartMenuSCVar AddQuickLaunchSCVar AddDesktopSCVar fhInstallLogVar fhUninstallLogVar ShortPathNameToExe; Other included files may depend upon these includes!; The following includes are provided by NSIS.!include FileFunc.nsh!include LogicLib.nsh!include TextFunc.nsh!include WinMessages.nsh!include WordFunc.nsh!include MUI.nsh!insertmacro FileJoin!insertmacro GetTime!insertmacro LineFind!insertmacro TrimNewLines!insertmacro WordFind!insertmacro WordReplace!insertmacro GetSize!insertmacro GetParameters!insertmacro GetOptions!insertmacro GetRoot!insertmacro DriveSpace; The following includes are custom.!include branding.nsi!include defines.nsi!include common.nsh!include locales.nsi!include version.nsh!insertmacro RegCleanMain!insertmacro RegCleanUninstall!insertmacro CloseApp!insertmacro WriteRegStr2!insertmacro WriteRegDWORD2!insertmacro CanWriteToInstallDir!insertmacro CheckDiskSpace!include overrides.nsh!insertmacro LocateNoDetails!insertmacro TextCompareNoDetailsName "${BrandFullName}"OutFile "setup.exe"InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})" "InstallLocation"InstallDir "$PROGRAMFILES\${BrandFullName}"ShowInstDetails nevershowReserveFile options.iniReserveFile components.iniReserveFile shortcuts.ini################################################################################# Modern User Interface - MUI; WIZ_IMAGE_SUFFIX, HDR_IMAGE_SUFFIX, and MUI_HEADER_SUFFIX are defined in; locales.nsi!define MUI_ABORTWARNING!define MUI_ICON setup.ico!define MUI_UNICON setup.ico!define MUI_WELCOMEPAGE_TITLE_3LINES!define MUI_WELCOMEFINISHPAGE_BITMAP wizWatermark${WIZ_IMAGE_SUFFIX}.bmp!define MUI_HEADERIMAGE!define MUI_HEADERIMAGE_RIGHT!define MUI_HEADERIMAGE_BITMAP${MUI_HEADER_SUFFIX} wizHeader${HDR_IMAGE_SUFFIX}.bmp/** * Installation Pages */; Welcome Page!insertmacro MUI_PAGE_WELCOME; License Page!define MUI_LICENSEPAGE_RADIOBUTTONS!insertmacro MUI_PAGE_LICENSE license.txt; Custom Options PagePage custom preOptions leaveOptions; Custom Components PagePage custom preComponents leaveComponents; Select Install Directory Page!define MUI_PAGE_CUSTOMFUNCTION_PRE preDirectory!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveDirectory!define MUI_DIRECTORYPAGE_VERIFYONLEAVE!insertmacro MUI_PAGE_DIRECTORY; Custom Shortcuts PagePage custom preShortcuts leaveShortcuts; Start Menu Folder Page Configuration!define MUI_PAGE_CUSTOMFUNCTION_PRE preStartMenu!define MUI_STARTMENUPAGE_NODISABLE!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Main"!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"!insertmacro MUI_PAGE_STARTMENU Application $StartMenuDir; Install Files Page!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveInstFiles!insertmacro MUI_PAGE_INSTFILES; Finish Page!define MUI_FINISHPAGE_NOREBOOTSUPPORT!define MUI_FINISHPAGE_TITLE_3LINES!define MUI_FINISHPAGE_RUN!define MUI_FINISHPAGE_RUN_FUNCTION LaunchApp!define MUI_FINISHPAGE_RUN_TEXT $(LAUNCH_TEXT)!define MUI_PAGE_CUSTOMFUNCTION_PRE preFinish!insertmacro MUI_PAGE_FINISH################################################################################# Install SectionsSection "-Application" Section1  SectionIn 1 RO  SetDetailsPrint textonly  DetailPrint $(STATUS_CLEANUP)  SetDetailsPrint none  SetOutPath $INSTDIR  ; Try to delete the app executable and if we can't delete it try to close the  ; app. This allows running an instance that is located in another directory.  ClearErrors  ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"    ${DeleteFile} "$INSTDIR\${FileMainEXE}"  ${EndIf}  ${If} ${Errors}    ClearErrors    ${CloseApp} "true" $(WARN_APP_RUNNING_INSTALL)    ; Try to delete it again to prevent launching the app while we are    ; installing.    ${DeleteFile} "$INSTDIR\${FileMainEXE}"    ClearErrors  ${EndIf}  ; For a "Standard" upgrade without talkback installed add the InstallDisabled  ; file to the talkback source files so it will be disabled by the extension  ; manager. This is done at the start of the installation since we check for  ; the existence of a directory to determine if this is an upgrade.  ${If} $InstallType == 1  ${AndIf} ${FileExists} "$INSTDIR\greprefs"  ${AndIf} ${FileExists} "$EXEDIR\optional\extensions\talkback@mozilla.org"    ${Unless} ${FileExists} "$INSTDIR\extensions\talkback@mozilla.org"      ${Unless} ${FileExists} "$INSTDIR\extensions"        CreateDirectory "$INSTDIR\extensions"      ${EndUnless}      CreateDirectory "$INSTDIR\extensions\talkback@mozilla.org"      FileOpen $2 "$EXEDIR\optional\extensions\talkback@mozilla.org\InstallDisabled" w      FileWrite $2 "$\r$\n"      FileClose $2    ${EndUnless}  ${Else}    ; Custom installs.    ; If DOMi is installed and this install includes DOMi remove it from    ; the installation directory. This will remove it if the user deselected    ; DOMi on the components page.    ${If} ${FileExists} "$INSTDIR\extensions\inspector@mozilla.org"    ${AndIf} ${FileExists} "$EXEDIR\optional\extensions\inspector@mozilla.org"      RmDir /r "$INSTDIR\extensions\inspector@mozilla.org"    ${EndIf}    ; If TalkBack is installed and this install includes TalkBack remove it from    ; the installation directory. This will remove it if the user deselected    ; TalkBack on the components page.    ${If} ${FileExists} "$INSTDIR\extensions\talkback@mozilla.org"    ${AndIf} ${FileExists} "$EXEDIR\optional\extensions\talkback@mozilla.org"      RmDir /r "$INSTDIR\extensions\talkback@mozilla.org"    ${EndIf}  ${EndIf}  Call CleanupOldLogs  ${If} ${FileExists} "$INSTDIR\uninstall\uninstall.log"    ; Diff cleanup.log with uninstall.bak    ${LogHeader} "Updating Uninstall Log With XPInstall Wizard Logs"    StrCpy $R0 "$INSTDIR\uninstall\uninstall.log"    StrCpy $R1 "$INSTDIR\uninstall\cleanup.log"    GetTempFileName $R2    FileOpen $R3 $R2 w    ${TextCompareNoDetails} "$R1" "$R0" "SlowDiff" "GetDiff"    FileClose $R3    ${Unless} ${Errors}      ${FileJoin} "$INSTDIR\uninstall\uninstall.log" "$R2" "$INSTDIR\uninstall\uninstall.log"    ${EndUnless}    ${DeleteFile} "$INSTDIR\uninstall\cleanup.log"    ${DeleteFile} "$R2"    ${DeleteFile} "$INSTDIR\uninstall\uninstall.bak"    Rename "$INSTDIR\uninstall\uninstall.log" "$INSTDIR\uninstall\uninstall.bak"  ${EndIf}  ${Unless} ${FileExists} "$INSTDIR\uninstall"    CreateDirectory "$INSTDIR\uninstall"  ${EndUnless}  FileOpen $fhUninstallLog "$INSTDIR\uninstall\uninstall.log" w  FileOpen $fhInstallLog "$INSTDIR\install.log" w  ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6  FileWrite $fhInstallLog "${BrandFullName} Installation Started: $2-$1-$0 $4:$5:$6"  Call WriteLogSeparator  ${LogHeader} "Installation Details"  ${LogMsg} "Install Dir: $INSTDIR"  ${LogMsg} "Locale     : ${AB_CD}"  ${LogMsg} "App Version: ${AppVersion}"  ${LogMsg} "GRE Version: ${GREVersion}"  ${If} ${FileExists} "$EXEDIR\removed-files.log"    ${LogHeader} "Removing Obsolete Files and Directories"    ${LineFind} "$EXEDIR\removed-files.log" "/NUL" "1:-1" "onInstallDeleteFile"    ${LineFind} "$EXEDIR\removed-files.log" "/NUL" "1:-1" "onInstallRemoveDir"  ${EndIf}  ${DeleteFile} "$INSTDIR\install_wizard.log"  ${DeleteFile} "$INSTDIR\install_status.log"  SetDetailsPrint textonly  DetailPrint $(STATUS_INSTALL_APP)  SetDetailsPrint none  ${LogHeader} "Installing Main Files"  StrCpy $R0 "$EXEDIR\nonlocalized"  StrCpy $R1 "$INSTDIR"  Call DoCopyFiles  ; Register DLLs  ; XXXrstrong - AccessibleMarshal.dll can be used by multiple applications but  ; is only registered for the last application installed. When the last  ; application installed is uninstalled AccessibleMarshal.dll will no longer be  ; registered. bug 338878  ${LogHeader} "DLL Registration"  ClearErrors  RegDLL "$INSTDIR\AccessibleMarshal.dll"  ${If} ${Errors}    ${LogMsg} "** ERROR Registering: $INSTDIR\AccessibleMarshal.dll **"  ${Else}    ${LogUninstall} "DLLReg: \AccessibleMarshal.dll"    ${LogMsg} "Registered: $INSTDIR\AccessibleMarshal.dll"  ${EndIf}    ; MapiProxy.dll can be used by multiple applications but  ; is only registered for the last application installed. When the last  ; application installed is uninstalled MapiProxy.dll will no longer be  ; registered.   ClearErrors  RegDLL "$INSTDIR\MapiProxy.dll"  ${If} ${Errors}    ${LogMsg} "** ERROR Registering: $INSTDIR\MapiProxy.dll **"  ${Else}    ${LogUninstall} "DLLReg: \MapiProxy.dll"    ${LogMsg} "Registered: $INSTDIR\MapiProxy.dll"  ${EndIf}      ; Write extra files created by the application to the uninstall.log so they  ; will be removed when the application is uninstalled. To remove an empty  ; directory write a bogus filename to the deepest directory and all empty  ; parent directories will be removed.  ${LogUninstall} "File: \components\compreg.dat"  ${LogUninstall} "File: \components\xpti.dat"  ${LogUninstall} "File: \.autoreg"  ${LogUninstall} "File: \active-update.xml"  ${LogUninstall} "File: \install.log"  ${LogUninstall} "File: \install_status.log"  ${LogUninstall} "File: \install_wizard.log"  ${LogUninstall} "File: \updates.xml"  SetDetailsPrint textonly  DetailPrint $(STATUS_INSTALL_LANG)  SetDetailsPrint none  ${LogHeader} "Installing Localized Files"  StrCpy $R0 "$EXEDIR\localized"  StrCpy $R1 "$INSTDIR"  Call DoCopyFiles  ${If} $InstallType != 4    Call installTalkback    ${If} ${FileExists} "$INSTDIR\extensions\inspector@mozilla.org"      Call installInspector    ${EndIf}  ${EndIf}  ; Default for creating Start Menu folder and shortcuts  ; (1 = create, 0 = don't create)  ${If} $AddStartMenuSC == ""    StrCpy $AddStartMenuSC "1"  ${EndIf}  ; Default for creating Quick Launch shortcut (1 = create, 0 = don't create)  ${If} $AddQuickLaunchSC == ""    StrCpy $AddQuickLaunchSC "1"  ${EndIf}  ; Default for creating Desktop shortcut (1 = create, 0 = don't create)  ${If} $AddDesktopSC == ""    StrCpy $AddDesktopSC "1"  ${EndIf}  ; Remove registry entries for non-existent apps and for apps that point to our  ; install location in the Software\Mozilla key.  SetShellVarContext current  ; Set SHCTX to HKCU  ${RegCleanMain} "Software\Mozilla"  SetShellVarContext all  ; Set SHCTX to HKLM  ${RegCleanMain} "Software\Mozilla"  ; Remove uninstall entries that point to our install location  ${RegCleanUninstall}  ${LogHeader} "Adding Registry Entries"  ClearErrors

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -