Browse Source

Merge pull request #6584 from Chocobo1/nsis

NSIS: set exit code to 0 on install/uninstall success
adaptive-webui-19844
sledgehammer999 8 years ago committed by GitHub
parent
commit
027607490a
  1. 48
      dist/windows/installer.nsi
  2. 38
      dist/windows/uninstaller.nsi

48
dist/windows/installer.nsi vendored

@ -18,14 +18,14 @@ SectionEnd
Section $(inst_qbt_req) ;"qBittorrent (required)" Section $(inst_qbt_req) ;"qBittorrent (required)"
SectionIn RO SectionIn RO
; Set output path to the installation directory. ; Set output path to the installation directory.
SetOutPath $INSTDIR SetOutPath $INSTDIR
;Create 'translations' directory ;Create 'translations' directory
CreateDirectory $INSTDIR\translations CreateDirectory $INSTDIR\translations
; Put file there ; Put file there
File "qbittorrent.exe" File "qbittorrent.exe"
File "qbittorrent.pdb" File "qbittorrent.pdb"
File "qt.conf" File "qt.conf"
@ -74,10 +74,10 @@ Section $(inst_qbt_req) ;"qBittorrent (required)"
File /oname=translations\qtbase_ru.qm "translations\qtbase_ru.qm" File /oname=translations\qtbase_ru.qm "translations\qtbase_ru.qm"
File /oname=translations\qtbase_sk.qm "translations\qtbase_sk.qm" File /oname=translations\qtbase_sk.qm "translations\qtbase_sk.qm"
File /oname=translations\qtbase_uk.qm "translations\qtbase_uk.qm" File /oname=translations\qtbase_uk.qm "translations\qtbase_uk.qm"
; Write the installation path into the registry ; Write the installation path into the registry
WriteRegStr HKLM "Software\qBittorrent" "InstallLocation" "$INSTDIR" WriteRegStr HKLM "Software\qBittorrent" "InstallLocation" "$INSTDIR"
; Write the uninstall keys for Windows ; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayName" "qBittorrent ${PROG_VERSION}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayName" "qBittorrent ${PROG_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "UninstallString" '"$INSTDIR\uninst.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "UninstallString" '"$INSTDIR\uninst.exe"'
@ -87,53 +87,53 @@ Section $(inst_qbt_req) ;"qBittorrent (required)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayVersion" "${PROG_VERSION}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayVersion" "${PROG_VERSION}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "NoRepair" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "NoRepair" 1
WriteUninstaller "uninst.exe" WriteUninstaller "uninst.exe"
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0 IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "EstimatedSize" "$0" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "EstimatedSize" "$0"
; qBittorrent ProgID ; qBittorrent ProgID
WriteRegStr HKLM "Software\Classes\qBittorrent" "" "qBittorrent Torrent File" WriteRegStr HKLM "Software\Classes\qBittorrent" "" "qBittorrent Torrent File"
WriteRegStr HKLM "Software\Classes\qBittorrent" "FriendlyTypeName" "qBittorrent Torrent File" WriteRegStr HKLM "Software\Classes\qBittorrent" "FriendlyTypeName" "qBittorrent Torrent File"
WriteRegStr HKLM "Software\Classes\qBittorrent\shell" "" "open" WriteRegStr HKLM "Software\Classes\qBittorrent\shell" "" "open"
WriteRegStr HKLM "Software\Classes\qBittorrent\shell\open\command" "" '"$INSTDIR\qbittorrent.exe" "%1"' WriteRegStr HKLM "Software\Classes\qBittorrent\shell\open\command" "" '"$INSTDIR\qbittorrent.exe" "%1"'
WriteRegStr HKLM "Software\Classes\qBittorrent\DefaultIcon" "" '"$INSTDIR\qbittorrent.exe",1' WriteRegStr HKLM "Software\Classes\qBittorrent\DefaultIcon" "" '"$INSTDIR\qbittorrent.exe",1'
SectionEnd SectionEnd
; Optional section (can be disabled by the user) ; Optional section (can be disabled by the user)
Section /o $(inst_dekstop) ;"Create Desktop Shortcut" Section /o $(inst_dekstop) ;"Create Desktop Shortcut"
CreateShortCut "$DESKTOP\qBittorrent.lnk" "$INSTDIR\qbittorrent.exe" CreateShortCut "$DESKTOP\qBittorrent.lnk" "$INSTDIR\qbittorrent.exe"
SectionEnd SectionEnd
Section $(inst_startmenu) ;"Create Start Menu Shortcut" Section $(inst_startmenu) ;"Create Start Menu Shortcut"
CreateDirectory "$SMPROGRAMS\qBittorrent" CreateDirectory "$SMPROGRAMS\qBittorrent"
CreateShortCut "$SMPROGRAMS\qBittorrent\qBittorrent.lnk" "$INSTDIR\qbittorrent.exe" CreateShortCut "$SMPROGRAMS\qBittorrent\qBittorrent.lnk" "$INSTDIR\qbittorrent.exe"
CreateShortCut "$SMPROGRAMS\qBittorrent\Uninstall.lnk" "$INSTDIR\uninst.exe" CreateShortCut "$SMPROGRAMS\qBittorrent\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd SectionEnd
Section $(inst_torrent) ;"Open .torrent files with qBittorrent" Section $(inst_torrent) ;"Open .torrent files with qBittorrent"
ReadRegStr $0 HKLM "Software\Classes\.torrent" "" ReadRegStr $0 HKLM "Software\Classes\.torrent" ""
StrCmp $0 "qBittorrent" clear_errors 0 StrCmp $0 "qBittorrent" clear_errors 0
;Check if empty string ;Check if empty string
StrCmp $0 "" clear_errors 0 StrCmp $0 "" clear_errors 0
;Write old value to OpenWithProgIds ;Write old value to OpenWithProgIds
WriteRegStr HKLM "Software\Classes\.torrent\OpenWithProgIds" $0 "" WriteRegStr HKLM "Software\Classes\.torrent\OpenWithProgIds" $0 ""
clear_errors: clear_errors:
ClearErrors ClearErrors
WriteRegStr HKLM "Software\Classes\.torrent" "" "qBittorrent" WriteRegStr HKLM "Software\Classes\.torrent" "" "qBittorrent"
WriteRegStr HKLM "Software\Classes\.torrent" "Content Type" "application/x-bittorrent" WriteRegStr HKLM "Software\Classes\.torrent" "Content Type" "application/x-bittorrent"
!insertmacro UAC_AsUser_Call Function inst_torrent_user ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR} !insertmacro UAC_AsUser_Call Function inst_torrent_user ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR}
System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)'
SectionEnd SectionEnd
@ -141,13 +141,13 @@ SectionEnd
Function inst_torrent_user Function inst_torrent_user
ReadRegStr $0 HKCU "Software\Classes\.torrent" "" ReadRegStr $0 HKCU "Software\Classes\.torrent" ""
StrCmp $0 "qBittorrent" clear_errors 0 StrCmp $0 "qBittorrent" clear_errors 0
;Check if empty string ;Check if empty string
StrCmp $0 "" clear_errors 0 StrCmp $0 "" clear_errors 0
;Write old value to OpenWithProgIds ;Write old value to OpenWithProgIds
WriteRegStr HKCU "Software\Classes\.torrent\OpenWithProgIds" $0 "" WriteRegStr HKCU "Software\Classes\.torrent\OpenWithProgIds" $0 ""
clear_errors: clear_errors:
ClearErrors ClearErrors
@ -164,7 +164,7 @@ Section $(inst_magnet) ;"Open magnet links with qBittorrent"
WriteRegStr HKLM "Software\Classes\magnet\DefaultIcon" "" '"$INSTDIR\qbittorrent.exe",1' WriteRegStr HKLM "Software\Classes\magnet\DefaultIcon" "" '"$INSTDIR\qbittorrent.exe",1'
WriteRegStr HKLM "Software\Classes\magnet\shell" "" "open" WriteRegStr HKLM "Software\Classes\magnet\shell" "" "open"
WriteRegStr HKLM "Software\Classes\magnet\shell\open\command" "" '"$INSTDIR\qbittorrent.exe" "%1"' WriteRegStr HKLM "Software\Classes\magnet\shell\open\command" "" '"$INSTDIR\qbittorrent.exe" "%1"'
!insertmacro UAC_AsUser_Call Function inst_magnet_user ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR} !insertmacro UAC_AsUser_Call Function inst_magnet_user ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR}
System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)'
@ -185,8 +185,8 @@ FunctionEnd
Section $(inst_firewall) Section $(inst_firewall)
DetailPrint $(inst_firewallinfo) DetailPrint $(inst_firewallinfo)
nsisFirewallW::AddAuthorizedApplication "$INSTDIR\qbittorrent.exe" "qBittorrent" nsisFirewallW::AddAuthorizedApplication "$INSTDIR\qbittorrent.exe" "qBittorrent"
SectionEnd SectionEnd
;-------------------------------- ;--------------------------------
@ -228,3 +228,7 @@ Function PageFinishRun
!insertmacro UAC_AsUser_ExecShell "" "$INSTDIR\qbittorrent.exe" "" "" "" !insertmacro UAC_AsUser_ExecShell "" "$INSTDIR\qbittorrent.exe" "" "" ""
FunctionEnd FunctionEnd
Function .onInstSuccess
SetErrorLevel 0
FunctionEnd

38
dist/windows/uninstaller.nsi vendored

@ -1,10 +1,10 @@
Section "un.$(remove_files)" ;"un.Remove files" Section "un.$(remove_files)" ;"un.Remove files"
SectionIn RO SectionIn RO
; Remove files and uninstaller ; Remove files and uninstaller
Delete "$INSTDIR\qbittorrent.exe" Delete "$INSTDIR\qbittorrent.exe"
Delete "$INSTDIR\qbittorrent.pdb" Delete "$INSTDIR\qbittorrent.pdb"
Delete "$INSTDIR\qt.conf" Delete "$INSTDIR\qt.conf"
Delete "$INSTDIR\translations\qt_ar.qm" Delete "$INSTDIR\translations\qt_ar.qm"
Delete "$INSTDIR\translations\qt_bg.qm" Delete "$INSTDIR\translations\qt_bg.qm"
Delete "$INSTDIR\translations\qt_ca.qm" Delete "$INSTDIR\translations\qt_ca.qm"
@ -51,8 +51,8 @@
Delete "$INSTDIR\translations\qtbase_sk.qm" Delete "$INSTDIR\translations\qtbase_sk.qm"
Delete "$INSTDIR\translations\qtbase_uk.qm" Delete "$INSTDIR\translations\qtbase_uk.qm"
Delete "$INSTDIR\uninst.exe" Delete "$INSTDIR\uninst.exe"
; Remove directories used ; Remove directories used
RMDir /r "$INSTDIR\translations" RMDir /r "$INSTDIR\translations"
RMDir "$INSTDIR" RMDir "$INSTDIR"
SectionEnd SectionEnd
@ -71,16 +71,16 @@ Section "un.$(remove_associations)" ;"un.Remove file associations"
DetailPrint "$(uninst_tor_warn) $0" DetailPrint "$(uninst_tor_warn) $0"
DeleteRegValue HKLM "Software\Classes\.torrent" "" DeleteRegValue HKLM "Software\Classes\.torrent" ""
DeleteRegKey /ifempty HKLM "Software\Classes\.torrent" DeleteRegKey /ifempty HKLM "Software\Classes\.torrent"
torrent_end: torrent_end:
ReadRegStr $0 HKLM "Software\Classes\magnet\shell\open\command" "" ReadRegStr $0 HKLM "Software\Classes\magnet\shell\open\command" ""
StrCmp $0 '"$INSTDIR\qbittorrent.exe" "%1"' 0 magnet_end StrCmp $0 '"$INSTDIR\qbittorrent.exe" "%1"' 0 magnet_end
DetailPrint "$(uninst_mag_warn) $0" DetailPrint "$(uninst_mag_warn) $0"
DeleteRegKey HKLM "Software\Classes\magnet" DeleteRegKey HKLM "Software\Classes\magnet"
magnet_end: magnet_end:
!insertmacro UAC_AsUser_Call Function un.remove_associations_user ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR} !insertmacro UAC_AsUser_Call Function un.remove_associations_user ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR}
System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)'
SectionEnd SectionEnd
@ -90,23 +90,23 @@ Function un.remove_associations_user
DetailPrint "$(uninst_tor_warn) $0" DetailPrint "$(uninst_tor_warn) $0"
DeleteRegValue HKCU "Software\Classes\.torrent" "" DeleteRegValue HKCU "Software\Classes\.torrent" ""
DeleteRegKey /ifempty HKCU "Software\Classes\.torrent" DeleteRegKey /ifempty HKCU "Software\Classes\.torrent"
torrent_end: torrent_end:
ReadRegStr $0 HKCU "Software\Classes\magnet\shell\open\command" "" ReadRegStr $0 HKCU "Software\Classes\magnet\shell\open\command" ""
StrCmp $0 '"$INSTDIR\qbittorrent.exe" "%1"' 0 magnet_end StrCmp $0 '"$INSTDIR\qbittorrent.exe" "%1"' 0 magnet_end
DetailPrint "$(uninst_mag_warn) $0" DetailPrint "$(uninst_mag_warn) $0"
DeleteRegKey HKCU "Software\Classes\magnet" DeleteRegKey HKCU "Software\Classes\magnet"
magnet_end: magnet_end:
FunctionEnd FunctionEnd
Section "un.$(remove_registry)" ;"un.Remove registry keys" Section "un.$(remove_registry)" ;"un.Remove registry keys"
SectionIn RO SectionIn RO
; Remove registry keys ; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent"
DeleteRegKey HKLM "Software\qBittorrent" DeleteRegKey HKLM "Software\qBittorrent"
DeleteRegKey HKLM "Software\Classes\qBittorrent" DeleteRegKey HKLM "Software\Classes\qBittorrent"
System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)'
SectionEnd SectionEnd
@ -114,7 +114,7 @@ Section "un.$(remove_firewall)" ;
DetailPrint $(remove_firewallinfo) DetailPrint $(remove_firewallinfo)
nsisFirewallW::RemoveAuthorizedApplication "$INSTDIR\qbittorrent.exe" nsisFirewallW::RemoveAuthorizedApplication "$INSTDIR\qbittorrent.exe"
SectionEnd SectionEnd
Section /o "un.$(remove_conf)" ;"un.Remove configuration files" Section /o "un.$(remove_conf)" ;"un.Remove configuration files"
@ -150,7 +150,7 @@ Function un.onInit
!insertmacro Init "uninstaller" !insertmacro Init "uninstaller"
!insertmacro MUI_UNGETLANGUAGE !insertmacro MUI_UNGETLANGUAGE
FunctionEnd FunctionEnd
Function un.check_instance Function un.check_instance
@ -162,7 +162,11 @@ Function un.check_instance
done: done:
Abort Abort
notfound: notfound:
FunctionEnd
Function un.onUninstSuccess
SetErrorLevel 0
FunctionEnd FunctionEnd

Loading…
Cancel
Save