5 ;Search if qBittorrent is already installed.
6 FindFirst $0 $1 "$uninstallerPath\uninst.exe"
10 ;Run the uninstaller of the previous install.
11 DetailPrint $(inst_unist
)
12 ExecWait '"$uninstallerPath\uninst.exe" /S _?=$uninstallerPath'
13 Delete "$uninstallerPath\uninst.exe"
14 RMDir "$uninstallerPath"
21 Section $(inst_qbt_req
) ;"qBittorrent (required)"
25 ; Set output path to the installation directory.
28 File "qbittorrent.exe"
29 File "qbittorrent.pdb"
32 ;Create 'translations' directory
33 CreateDirectory $INSTDIR\translations
34 ; Set output path to the installation\translations directory.
35 SetOutPath "$INSTDIR\translations"
37 File /r
"translations\qt*.qm"
38 ; Restore output path because it affects `CreateShortCut`. It affects the "Start in" field.
41 ; Write the installation path into the registry
42 WriteRegStr HKLM "Software\qBittorrent" "InstallLocation" "$INSTDIR"
44 ; Write the uninstall keys for Windows
45 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayName" "qBittorrent"
46 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "UninstallString" '"$INSTDIR\uninst.exe"'
47 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayIcon" '"$INSTDIR\qbittorrent.exe",0'
48 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "Publisher" "The qBittorrent project"
49 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "URLInfoAbout" "https://www.qbittorrent.org"
50 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayVersion" "${QBT_VERSION}"
51 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "NoModify" 1
52 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "NoRepair" 1
53 WriteUninstaller "uninst.exe"
54 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
56 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "EstimatedSize" "$0"
59 WriteRegStr HKLM "Software\Classes\qBittorrent" "" "qBittorrent Torrent File"
60 WriteRegStr HKLM "Software\Classes\qBittorrent" "FriendlyTypeName" "qBittorrent Torrent File"
61 WriteRegStr HKLM "Software\Classes\qBittorrent\shell" "" "open"
62 WriteRegStr HKLM "Software\Classes\qBittorrent\shell\open\command" "" '"$INSTDIR\qbittorrent.exe" "%1"'
63 WriteRegStr HKLM "Software\Classes\qBittorrent\DefaultIcon" "" '"$INSTDIR\qbittorrent.exe",1'
67 ; Optional section (can be disabled by the user)
68 Section /o
$(inst_desktop
) ;"Create Desktop Shortcut"
70 CreateShortCut "$DESKTOP\qBittorrent.lnk" "$INSTDIR\qbittorrent.exe"
74 Section $(inst_startmenu
) ;"Create Start Menu Shortcut"
76 CreateDirectory "$SMPROGRAMS\qBittorrent"
77 CreateShortCut "$SMPROGRAMS\qBittorrent\qBittorrent.lnk" "$INSTDIR\qbittorrent.exe"
78 CreateShortCut "$SMPROGRAMS\qBittorrent\$(inst_uninstall_link_description).lnk" "$INSTDIR\uninst.exe"
82 Section /o
$(inst_startup
) ;"Start qBittorrent on Windows start up"
84 !insertmacro UAC_AsUser_Call
Function inst_startup_user
${UAC_SYNCREGISTERS}|
${UAC_SYNCOUTDIR}|
${UAC_SYNCINSTDIR}
88 Function inst_startup_user
90 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "qBittorrent" "$INSTDIR\qbittorrent.exe"
94 Section $(inst_torrent
) ;"Open .torrent files with qBittorrent"
96 ReadRegStr $0 HKLM "Software\Classes\.torrent" ""
98 StrCmp $0 "qBittorrent" clear_errors
0
99 ;Check if empty string
100 StrCmp $0 "" clear_errors
0
101 ;Write old value to OpenWithProgIds
102 WriteRegStr HKLM "Software\Classes\.torrent\OpenWithProgIds" $0 ""
107 WriteRegStr HKLM "Software\Classes\.torrent" "" "qBittorrent"
108 WriteRegStr HKLM "Software\Classes\.torrent" "Content Type" "application/x-bittorrent"
110 !insertmacro UAC_AsUser_Call
Function inst_torrent_user
${UAC_SYNCREGISTERS}|
${UAC_SYNCOUTDIR}|
${UAC_SYNCINSTDIR}
112 System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, p 0, p 0)'
116 Function inst_torrent_user
118 ReadRegStr $0 HKCU "Software\Classes\.torrent" ""
120 StrCmp $0 "qBittorrent" clear_errors
0
121 ;Check if empty string
122 StrCmp $0 "" clear_errors
0
123 ;Write old value to OpenWithProgIds
124 WriteRegStr HKCU "Software\Classes\.torrent\OpenWithProgIds" $0 ""
129 WriteRegStr HKCU "Software\Classes\.torrent" "" "qBittorrent"
130 WriteRegStr HKCU "Software\Classes\.torrent" "Content Type" "application/x-bittorrent"
134 Section $(inst_magnet
) ;"Open magnet links with qBittorrent"
136 WriteRegStr HKLM "Software\Classes\magnet" "" "URL:Magnet link"
137 WriteRegStr HKLM "Software\Classes\magnet" "Content Type" "application/x-magnet"
138 WriteRegStr HKLM "Software\Classes\magnet" "URL Protocol" ""
139 WriteRegStr HKLM "Software\Classes\magnet\DefaultIcon" "" '"$INSTDIR\qbittorrent.exe",1'
140 WriteRegStr HKLM "Software\Classes\magnet\shell" "" "open"
141 WriteRegStr HKLM "Software\Classes\magnet\shell\open\command" "" '"$INSTDIR\qbittorrent.exe" "%1"'
143 !insertmacro UAC_AsUser_Call
Function inst_magnet_user
${UAC_SYNCREGISTERS}|
${UAC_SYNCOUTDIR}|
${UAC_SYNCINSTDIR}
145 System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, p 0, p 0)'
149 Function inst_magnet_user
151 WriteRegStr HKCU "Software\Classes\magnet" "" "URL:Magnet link"
152 WriteRegStr HKCU "Software\Classes\magnet" "Content Type" "application/x-magnet"
153 WriteRegStr HKCU "Software\Classes\magnet" "URL Protocol" ""
154 WriteRegStr HKCU "Software\Classes\magnet\DefaultIcon" "" '"$INSTDIR\qbittorrent.exe",1'
155 WriteRegStr HKCU "Software\Classes\magnet\shell" "" "open"
156 WriteRegStr HKCU "Software\Classes\magnet\shell\open\command" "" '"$INSTDIR\qbittorrent.exe" "%1"'
160 Section $(inst_firewall
)
162 DetailPrint $(inst_firewallinfo
)
163 nsisFirewallW::AddAuthorizedApplication
"$INSTDIR\qbittorrent.exe" "qBittorrent"
167 Section $(inst_pathlimit
) ;"Disable Windows path length limit (260 character MAX_PATH limitation, requires Windows 10 1607 or later)"
169 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\FileSystem" "LongPathsEnabled" 1
173 ;--------------------------------
177 !insertmacro Init
"installer"
178 !insertmacro MUI_LANGDLL_DISPLAY
181 ${IfNot} ${AtLeastWin7}
182 MessageBox MB_OK|
MB_ICONEXCLAMATION $(inst_requires_win7
)
186 ${IfNot} ${AtLeastWaaS} 1809 ; Windows 10 1809. Min supported version by Qt6
187 MessageBox MB_OK|
MB_ICONEXCLAMATION $(inst_requires_win10
)
193 ${IfNot} ${RunningX64}
194 MessageBox MB_OK|
MB_ICONEXCLAMATION $(inst_requires_64bit
)
199 ;Search if qBittorrent is already installed.
200 FindFirst $0 $1 "$INSTDIR\uninst.exe"
204 ;Copy old value to var so we can call the correct uninstaller
205 StrCpy $uninstallerPath $INSTDIR
208 MessageBox MB_OKCANCEL|MB_ICONINFORMATION
$(inst_uninstall_question
) /SD
IDOK IDOK done
215 Function check_instance
218 FindProcDLL::FindProc
"qbittorrent.exe"
219 StrCmp $R0 "1" 0 notfound
220 MessageBox MB_RETRYCANCEL|
MB_ICONEXCLAMATION $(inst_warning
) IDRETRY check
IDCANCEL done
229 Function PageFinishRun
231 !insertmacro UAC_AsUser_ExecShell
"" "$INSTDIR\qbittorrent.exe" "" "" ""
235 Function .onInstSuccess