?? installer.nsi
字號:
WriteRegStr HKLM "Software\Mozilla\InstallerTest" "InstallerTest" "Test" ${If} ${Errors} SetShellVarContext current ; Set SHCTX to HKCU StrCpy $TmpVal "HKCU" ; used primarily for logging ${Else} SetShellVarContext all ; Set SHCTX to HKLM DeleteRegKey HKLM "Software\Mozilla\InstallerTest" StrCpy $TmpVal "HKLM" ; used primarily for logging ${EndIf} ; The previous installer adds several regsitry values to both HKLM and HKCU. ; We now try to add to HKLM and if that fails to HKCU ; The order that reg keys and values are added is important if you use the ; uninstall log to remove them on uninstall. When using the uninstall log you ; MUST add children first so they will be removed first on uninstall so they ; will be empty when the key is deleted. This allows the uninstaller to ; specify that only empty keys will be deleted. StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Main" ${WriteRegStr2} $TmpVal "$0" "Install Directory" "$INSTDIR" 0 ${WriteRegStr2} $TmpVal "$0" "PathToExe" "$INSTDIR\${FileMainEXE}" 0 ${WriteRegStr2} $TmpVal "$0" "Program Folder Path" "$SMPROGRAMS\$StartMenuDir" 0 ${WriteRegDWORD2} $TmpVal "$0" "Create Quick Launch Shortcut" $AddQuickLaunchSC 0 ${WriteRegDWORD2} $TmpVal "$0" "Create Desktop Shortcut" $AddDesktopSC 0 ${WriteRegDWORD2} $TmpVal "$0" "Create Start Menu Shortcut" $AddStartMenuSC 0 StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Uninstall" ${WriteRegStr2} $TmpVal "$0" "Uninstall Log Folder" "$INSTDIR\uninstall" 0 ${WriteRegStr2} $TmpVal "$0" "Description" "${BrandFullNameInternal} (${AppVersion})" 0 StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})" ${WriteRegStr2} $TmpVal "$0" "" "${AppVersion} (${AB_CD})" 0 StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}\bin" ${WriteRegStr2} $TmpVal "$0" "PathToExe" "$INSTDIR\${FileMainEXE}" 0 StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}\extensions" ${WriteRegStr2} $TmpVal "$0" "Components" "$INSTDIR\components" 0 ${WriteRegStr2} $TmpVal "$0" "Plugins" "$INSTDIR\plugins" 0 StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}" ${WriteRegStr2} $TmpVal "$0" "GeckoVer" "${GREVersion}" 0 StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}" ${WriteRegStr2} $TmpVal "$0" "" "${GREVersion}" 0 ${WriteRegStr2} $TmpVal "$0" "CurrentVersion" "${AppVersion} (${AB_CD})" 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Add the Mail registry keys ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GetFullPathName /SHORT $ShortPathNameToExe "$INSTDIR\${FileMainEXE}" StrCpy $0 "Software\Clients\Mail\${BrandFullNameInternal}" ${WriteRegStr2} $TmpVal "$0" "" "${BrandFullNameInternal}" 0 GetFullPathName /SHORT $1 "$INSTDIR\mozMapi32.dll" ${WriteRegStr2} $TmpVal "$0" "DLLPath" "$1" 0 StrCpy $0 "Software\Clients\Mail\${BrandFullNameInternal}\DefaultIcon" StrCpy $1 "$\"$INSTDIR\${FileMainEXE}$\",0" ${WriteRegStr2} $TmpVal "$0" "" "$1" 0 ; The Reinstall Command is defined at ; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_adv/registeringapps.asp StrCpy $0 "Software\Clients\Mail\${BrandFullNameInternal}\InstallInfo" ; the old installer didn't pass in 'mail' here... StrCpy $1 "$\"$INSTDIR\uninstall\uninst.exe$\" /ua $\"${AppVersion} (${AB_CD})$\" /hs mail" ${WriteRegStr2} $TmpVal "$0" "HideIconsCommand" "$1" 0 ${WriteRegDWORD2} $TmpVal "$0" "IconsVisible" 1 0 StrCpy $1 "$\"$INSTDIR\${FileMainEXE}$\" -silent -setDefaultMail" ${WriteRegStr2} $TmpVal "$0" "ReinstallCommand" "$1" 0 StrCpy $1 "$\"$INSTDIR\uninstall\uninst.exe$\" /ua $\"${AppVersion} (${AB_CD})$\" /ss mail" ${WriteRegStr2} $TmpVal "$0" "ShowIconsCommand" "$1" 0 ; shell/open/command StrCpy $0 "Software\Clients\Mail\${BrandFullNameInternal}\shell\open\command" ${WriteRegStr2} $TmpVal "$0" "" "$ShortPathNameToExe" 0 ; shell/properties/command StrCpy $0 "Software\Clients\Mail\${BrandFullNameInternal}\shell\properties" ${WriteRegStr2} $TmpVal "$0" "" "$(OPTIONS)" 0 StrCpy $0 "Software\Clients\Mail\${BrandFullNameInternal}\shell\properties\command" ${WriteRegStr2} $TmpVal "$0" "" "$ShortPathNameToExe -options" 0 ; protocols/mailto StrCpy $0 "Software\Clients\Mail\${BrandFullNameInternal}\protocols\mailto" ${WriteRegStr2} $TmpVal "$0" "" "URL:MailTo Protocol" 0 ${WriteRegStr2} $TmpVal "$0" "URL Protocol" "" 0 StrCpy $0 "Software\Clients\Mail\${BrandFullNameInternal}\protocols\mailto\DefaultIcon" StrCpy $1 "$\"$ShortPathNameToExe$\",0" ${WriteRegStr2} $TmpVal "$0" "" "$1" 0 StrCpy $0 "Software\Clients\Mail\${BrandFullNameInternal}\protocols\mailto\shell\open\command" StrCpy $1 "$ShortPathNameToExe -compose $\"%1$\"" ${WriteRegStr2} $TmpVal "$0" "" "$1" 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Add the News registry keys ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}" ${WriteRegStr2} $TmpVal "$0" "" "${BrandFullNameInternal}" 0 StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\DefaultIcon" StrCpy $1 "$\"$INSTDIR\${FileMainEXE}$\",0" ${WriteRegStr2} $TmpVal "$0" "" "$1" 0 ; shell/open/command StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\shell\open\command" ${WriteRegStr2} $TmpVal "$0" "" "$INSTDIR\${FileMainEXE}" 0 ; protocols/news StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\protocols\news" ${WriteRegStr2} $TmpVal "$0" "" "URL:News Protocol" 0 ${WriteRegStr2} $TmpVal "$0" "URL Protocol" "" 0 StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\protocols\news\DefaultIcon" StrCpy $1 "$\"$INSTDIR\${FileMainEXE}$\",0" ${WriteRegStr2} $TmpVal "$0" "" "$1" 0 StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\protocols\news\shell\open\command" StrCpy $1 "$INSTDIR\${FileMainEXE} -mail $\"%1$\"" ${WriteRegStr2} $TmpVal "$0" "" "$1" 0 ; protocols/nntp StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\protocols\nntp" ${WriteRegStr2} $TmpVal "$0" "" "URL:NNTP Protocol" 0 ${WriteRegStr2} $TmpVal "$0" "URL Protocol" "" 0 StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\protocols\nntp\DefaultIcon" StrCpy $1 "$\"$INSTDIR\${FileMainEXE}$\",0" ${WriteRegStr2} $TmpVal "$0" "" "$1" 0 StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\protocols\nntp\shell\open\command" StrCpy $1 "$INSTDIR\${FileMainEXE} -mail $\"%1$\"" ${WriteRegStr2} $TmpVal "$0" "" "$1" 0 ; protocols/nntp StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\protocols\snews" ${WriteRegStr2} $TmpVal "$0" "" "URL:Snews Protocol" 0 ${WriteRegStr2} $TmpVal "$0" "URL Protocol" "" 0 StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\protocols\snews\DefaultIcon" StrCpy $1 "$\"$INSTDIR\${FileMainEXE}$\",0" ${WriteRegStr2} $TmpVal "$0" "" "$1" 0 StrCpy $0 "Software\Clients\News\${BrandFullNameInternal}\protocols\snews\shell\open\command" StrCpy $1 "$INSTDIR\${FileMainEXE} -mail $\"%1$\"" ${WriteRegStr2} $TmpVal "$0" "" "$1" 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; End of protocol registration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Write the uninstall registry keys StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})" StrCpy $1 "$INSTDIR\uninstall\uninst.exe" ${WriteRegStr2} $TmpVal "$0" "Comments" "${BrandFullNameInternal}" 0 ${WriteRegStr2} $TmpVal "$0" "DisplayIcon" "$INSTDIR\${FileMainEXE},0" 0 ${WriteRegStr2} $TmpVal "$0" "DisplayName" "${BrandFullNameInternal} (${AppVersion})" 0 ${WriteRegStr2} $TmpVal "$0" "DisplayVersion" "${AppVersion} (${AB_CD})" 0 ${WriteRegStr2} $TmpVal "$0" "InstallLocation" "$INSTDIR" 0 ${WriteRegStr2} $TmpVal "$0" "Publisher" "Mozilla" 0 ${WriteRegStr2} $TmpVal "$0" "UninstallString" "$1" 0 ${WriteRegStr2} $TmpVal "$0" "URLInfoAbout" "${URLInfoAbout}" 0 ${WriteRegStr2} $TmpVal "$0" "URLUpdateInfo" "${URLUpdateInfo}" 0 ${WriteRegDWORD2} $TmpVal "$0" "NoModify" 1 0 ${WriteRegDWORD2} $TmpVal "$0" "NoRepair" 1 0 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ; Create Start Menu shortcuts ${LogHeader} "Adding Shortcuts" ${If} $AddStartMenuSC == 1 CreateDirectory "$SMPROGRAMS\$StartMenuDir" CreateShortCut "$SMPROGRAMS\$StartMenuDir\${BrandFullNameInternal}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0 ${LogUninstall} "File: $SMPROGRAMS\$StartMenuDir\${BrandFullNameInternal}.lnk" CreateShortCut "$SMPROGRAMS\$StartMenuDir\${BrandFullNameInternal} ($(SAFE_MODE)).lnk" "$INSTDIR\${FileMainEXE}" "-safe-mode" "$INSTDIR\${FileMainEXE}" 0 ${LogUninstall} "File: $SMPROGRAMS\$StartMenuDir\${BrandFullNameInternal} ($(SAFE_MODE)).lnk" ${EndIf} ; perhaps use the uninstall keys ${If} $AddQuickLaunchSC == 1 CreateShortCut "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0 ${LogUninstall} "File: $QUICKLAUNCH\${BrandFullName}.lnk" ${EndIf} ${LogHeader} "Updating Quick Launch Shortcuts" ${If} $AddDesktopSC == 1 CreateShortCut "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0 ${LogUninstall} "File: $DESKTOP\${BrandFullName}.lnk" ${EndIf} !insertmacro MUI_STARTMENU_WRITE_END ; Refresh desktop icons System::Call "shell32::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)"SectionEndSection /o "Developer Tools" Section2 Call installInspectorSectionEndSection /o "Quality Feedback Agent" Section3 Call installTalkbackSectionEnd################################################################################# Helper FunctionsFunction installInspector ${If} ${FileExists} "$EXEDIR\optional\extensions\inspector@mozilla.org" SetDetailsPrint textonly DetailPrint $(STATUS_INSTALL_OPTIONAL) SetDetailsPrint none ${RemoveDir} "$INSTDIR\extensions\inspector@mozilla.org" ClearErrors ${LogHeader} "Installing Developer Tools" StrCpy $R0 "$EXEDIR\optional\extensions\inspector@mozilla.org" StrCpy $R1 "$INSTDIR\extensions\inspector@mozilla.org" Call DoCopyFiles ${EndIf}FunctionEndFunction installTalkback StrCpy $R0 "$EXEDIR\optional\extensions\talkback@mozilla.org" ${If} ${FileExists} "$R0" SetDetailsPrint textonly DetailPrint $(STATUS_INSTALL_OPTIONAL) SetDetailsPrint none StrCpy $R1 "$INSTDIR\extensions\talkback@mozilla.org" ${If} ${FileExists} "$R1" ; If there is an existing InstallDisabled file copy it to the source dir. ; This will add it during install to the uninstall.log and retains the ; original disabled state from the installation. ${If} ${FileExists} "$R1\InstallDisabled" CopyFiles "$R1\InstallDisabled" "$R0" ${EndIf} ; Remove the existing install of talkback RmDir /r "$R1" ${ElseIf} $InstallType == 1 ; For standard installations only enable talkback for the x percent as ; defined by the application. We use QueryPerformanceCounter for the seed ; since it returns a 64bit integer which should improve the accuracy. System::Call "kernel32::QueryPerformanceCounter(*l.r1)" System::Int64Op $1 % 100 Pop $0 ; The percentage provided by the application refers to the percentage to ; include so all numbers equal or greater than should be disabled. ${If} $0 >= ${RandomPercent} FileOpen $2 "$R0\InstallDisabled" w FileWrite $2 "$\r$\n" FileClose $2 ${EndIf} ${EndIf} ClearErrors ${LogHeader} "Installing Quality Feedback Agent" Call DoCopyFiles ${EndIf}FunctionEnd; Adds a section divider to the human readable log.Function WriteLogSeparator FileWrite $fhInstallLog "$\r$\n-------------------------------------------------------------------------------$\r$\n"FunctionEnd; Check whether to display the current page (e.g. if we aren't performing a; custom install don't display the custom pages).Function CheckCustom ${If} $InstallType != 4 Abort ${EndIf}FunctionEndFunction onInstallDeleteFile ${TrimNewLines} "$R9" "$R9" StrCpy $R1 "$R9" 5 ${If} $R1 == "File:" StrCpy $R9 "$R9" "" 6 ${If} ${FileExists} "$INSTDIR$R9" ClearErrors Delete "$INSTDIR$R9" ${If} ${Errors} ${LogMsg} "** ERROR Deleting File: $INSTDIR$R9 **" ${Else} ${LogMsg} "Deleted File: $INSTDIR$R9" ${EndIf} ${EndIf} ${EndIf} ClearErrors Push 0FunctionEnd; The previous installer removed directories even when they aren't empty so this; function does as well.Function onInstallRemoveDir ${TrimNewLines} "$R9" "$R9" StrCpy $R1 "$R9" 4 ${If} $R1 == "Dir:" StrCpy $R9 "$R9" "" 5 StrCpy $R1 "$R9" "" -1 ${If} $R1 == "\" StrCpy $R9 "$R9" -1 ${EndIf} ${If} ${FileExists} "$INSTDIR$R9" ClearErrors RmDir /r "$INSTDIR$R9" ${If} ${Errors} ${LogMsg} "** ERROR Removing Directory: $INSTDIR$R9 **" ${Else} ${LogMsg} "Removed Directory: $INSTDIR$R9" ${EndIf} ${EndIf} ${EndIf} ClearErrors Push 0FunctionEndFunction GetDiff ${TrimNewLines} "$9" "$9" ${If} $9 != "" FileWrite $R3 "$9$\r$\n" ${LogMsg} "Added To Uninstall Log: $9" ${EndIf} Push 0FunctionEndFunction DoCopyFiles StrLen $R2 $R0 ${LocateNoDetails} "$R0" "/L=FD" "CopyFile"FunctionEndFunction CopyFile StrCpy $R3 $R8 "" $R2 ${If} $R6 == "" ${Unless} ${FileExists} "$R1$R3\$R7" ClearErrors CreateDirectory "$R1$R3\$R7" ${If} ${Errors} ${LogMsg} "** ERROR Creating Directory: $R1$R3\$R7 **" ${Else} ${LogMsg} "Created Directory: $R1$R3\$R7" ${EndIf} ${EndUnless} ${Else} ${Unless} ${FileExists} "$R1$R3" ClearErrors CreateDirectory "$R1$R3" ${If} ${Errors} ${LogMsg} "** ERROR Creating Directory: $R1$R3 **" ${Else} ${LogMsg} "Created Directory: $R1$R3" ${EndIf} ${EndUnless} ${If} ${FileExists} "$R1$R3\$R7" Delete "$R1$R3\$R7" ${EndIf} ClearErrors CopyFiles /SILENT $R9 "$R1$R3" ${If} ${Errors} ; XXXrstrong - what should we do if there is an error installing a file? ${LogMsg} "** ERROR Installing File: $R1$R3\$R7 **" ${Else} ${LogMsg} "Installed File: $R1$R3\$R7" ${EndIf} ; If the file is installed into the installation directory remove the ; installation directory's path from the file path when writing to the ; uninstall.log so it will be a relative path. This allows the same ; uninst.exe to be used with zip builds if we supply an uninstall.log. ${WordReplace} "$R1$R3\$R7" "$INSTDIR" "" "+" $R3 ${LogUninstall} "File: $R3" ${EndIf} Push 0FunctionEnd; Clean up the old log files. We only diff the first two found since it is; possible for there to be several MB and comparing that many would take a very; long time to diff.Function CleanupOldLogs FindFirst $0 $TmpVal "$INSTDIR\uninstall\*wizard*" StrCmp $TmpVal "" done
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -