Bump to 4.6.1
[qBittorrent.git] / dist / windows / uninstaller.nsi
blob72a13749db66df02e302df36c0c5969da1bd02e6
1 Section "un.$(remove_files)" ;"un.Remove files"
2 SectionIn RO
4 ; Remove files and uninstaller
5 Delete "$INSTDIR\qbittorrent.exe"
6 Delete "$INSTDIR\qbittorrent.pdb"
7 Delete "$INSTDIR\qt.conf"
8 Delete "$INSTDIR\uninst.exe"
10 ; Remove directories used
11 RMDir /r "$INSTDIR\translations"
12 RMDir "$INSTDIR"
13 SectionEnd
15 Section "un.$(remove_shortcuts)" ;"un.Remove shortcuts"
16 SectionIn RO
17 ; Remove shortcuts, if any
18 RMDir /r "$SMPROGRAMS\qBittorrent"
19 Delete "$DESKTOP\qBittorrent.lnk"
20 SectionEnd
22 Section "un.$(remove_associations)" ;"un.Remove file associations"
23 SectionIn RO
24 ReadRegStr $0 HKLM "Software\Classes\.torrent" ""
25 StrCmp $0 "qBittorrent" 0 torrent_end
26 DetailPrint "$(uninst_tor_warn) $0"
27 DeleteRegValue HKLM "Software\Classes\.torrent" ""
28 DeleteRegKey /ifempty HKLM "Software\Classes\.torrent"
29 torrent_end:
31 ReadRegStr $0 HKLM "Software\Classes\magnet\shell\open\command" ""
32 StrCmp $0 '"$INSTDIR\qbittorrent.exe" "%1"' 0 magnet_end
33 DetailPrint "$(uninst_mag_warn) $0"
34 DeleteRegKey HKLM "Software\Classes\magnet"
35 magnet_end:
37 !insertmacro UAC_AsUser_Call Function un.remove_associations_user ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR}
39 System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, p 0, p 0)'
40 SectionEnd
42 Function un.remove_associations_user
43 ReadRegStr $0 HKCU "Software\Classes\.torrent" ""
44 StrCmp $0 "qBittorrent" 0 torrent_end
45 DetailPrint "$(uninst_tor_warn) $0"
46 DeleteRegValue HKCU "Software\Classes\.torrent" ""
47 DeleteRegKey /ifempty HKCU "Software\Classes\.torrent"
48 torrent_end:
50 ReadRegStr $0 HKCU "Software\Classes\magnet\shell\open\command" ""
51 StrCmp $0 '"$INSTDIR\qbittorrent.exe" "%1"' 0 magnet_end
52 DetailPrint "$(uninst_mag_warn) $0"
53 DeleteRegKey HKCU "Software\Classes\magnet"
54 magnet_end:
55 FunctionEnd
57 Section "un.$(remove_registry)" ;"un.Remove registry keys"
58 SectionIn RO
59 ; Remove registry keys
60 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent"
61 DeleteRegKey HKLM "Software\qBittorrent"
62 DeleteRegKey HKLM "Software\Classes\qBittorrent"
64 System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, p 0, p 0)'
65 SectionEnd
67 Section "un.$(remove_firewall)" ;
69 DetailPrint $(remove_firewallinfo)
70 nsisFirewallW::RemoveAuthorizedApplication "$INSTDIR\qbittorrent.exe"
72 SectionEnd
74 Section /o "un.$(remove_conf)" ;"un.Remove configuration files"
76 !insertmacro UAC_AsUser_Call Function un.remove_conf_user ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR}
78 SectionEnd
80 Function un.remove_conf_user
82 System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT, t .r1, i ${CSIDL_APPDATA}, i0)i.r0'
83 RMDir /r "$1\qBittorrent"
85 FunctionEnd
87 Section /o "un.$(remove_cache)"
89 !insertmacro UAC_AsUser_Call Function un.remove_cache_user ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR}
91 SectionEnd
93 Function un.remove_cache_user
95 System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT, t .r1, i ${CSIDL_LOCALAPPDATA}, i0)i.r0'
96 RMDir /r "$1\qBittorrent\"
98 FunctionEnd
100 ;--------------------------------
101 ;Uninstaller Functions
103 Function un.onInit
105 !insertmacro Init "uninstaller"
106 !insertmacro MUI_UNGETLANGUAGE
108 FunctionEnd
110 Function un.check_instance
112 check:
113 FindProcDLL::FindProc "qbittorrent.exe"
114 StrCmp $R0 "1" 0 notfound
115 MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(uninst_warning) IDRETRY check IDCANCEL done
117 done:
118 Abort
120 notfound:
122 FunctionEnd
124 Function un.onUninstSuccess
125 SetErrorLevel 0
126 FunctionEnd