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 "${QBT_DIST_DIR}\qbittorrent.exe"
30 File /nonfatal /r /x "${QBT_DIST_DIR}\qbittorrent.exe" "${QBT_DIST_DIR}\*.*"
32 ; Write the installation path into the registry
33 WriteRegStr HKLM "Software\qBittorrent" "InstallLocation" "$INSTDIR"
35 ; Register qBittorrent as possible default program for .torrent files and magnet links
36 WriteRegStr HKLM "Software\qBittorrent\Capabilities" "ApplicationDescription" "A BitTorrent client in Qt"
37 WriteRegStr HKLM "Software\qBittorrent\Capabilities" "ApplicationName" "qBittorrent"
38 WriteRegStr HKLM "Software\qBittorrent\Capabilities\FileAssociations" ".torrent" "qBittorrent.File.Torrent"
39 WriteRegStr HKLM "Software\qBittorrent\Capabilities\UrlAssociations" "magnet" "qBittorrent.Url.Magnet"
40 WriteRegStr HKLM "Software\RegisteredApplications" "qBittorrent" "Software\qBittorrent\Capabilities"
41 ; Register qBittorrent ProgIDs
42 WriteRegStr HKLM "Software\Classes\qBittorrent.File.Torrent" "" "Torrent File"
43 WriteRegStr HKLM "Software\Classes\qBittorrent.File.Torrent\DefaultIcon" "" '"$INSTDIR\qbittorrent.exe",1'
44 WriteRegStr HKLM "Software\Classes\qBittorrent.File.Torrent\shell\open\command" "" '"$INSTDIR\qbittorrent.exe" "%1"'
45 WriteRegStr HKLM "Software\Classes\qBittorrent.Url.Magnet" "" "Magnet URI"
46 WriteRegStr HKLM "Software\Classes\qBittorrent.Url.Magnet\DefaultIcon" "" '"$INSTDIR\qbittorrent.exe",1'
47 WriteRegStr HKLM "Software\Classes\qBittorrent.Url.Magnet\shell\open\command" "" '"$INSTDIR\qbittorrent.exe" "%1"'
49 WriteRegStr HKLM "Software\Classes\.torrent" "Content Type" "application/x-bittorrent"
50 WriteRegStr HKLM "Software\Classes\magnet" "" "URL:Magnet URI"
51 WriteRegStr HKLM "Software\Classes\magnet" "Content Type" "application/x-magnet"
52 WriteRegStr HKLM "Software\Classes\magnet" "URL Protocol" ""
54 System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, p 0, p 0)'
56 ; Write the uninstall keys for Windows
57 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayName" "qBittorrent"
58 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "UninstallString" '"$INSTDIR\uninst.exe"'
59 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayIcon" '"$INSTDIR\qbittorrent.exe",0'
60 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "Publisher" "The qBittorrent project"
61 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "URLInfoAbout" "https://www.qbittorrent.org"
62 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayVersion" "${QBT_VERSION}"
63 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "NoModify" 1
64 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "NoRepair" 1
65 WriteUninstaller "uninst.exe"
66 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
68 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "EstimatedSize" "$0"
72 ; Optional section (can be disabled by the user)
73 Section /o $(inst_desktop) ;"Create Desktop Shortcut"
75 CreateShortCut "$DESKTOP\qBittorrent.lnk" "$INSTDIR\qbittorrent.exe"
79 Section $(inst_startmenu) ;"Create Start Menu Shortcut"
81 CreateDirectory "$SMPROGRAMS\qBittorrent"
82 CreateShortCut "$SMPROGRAMS\qBittorrent\qBittorrent.lnk" "$INSTDIR\qbittorrent.exe"
83 CreateShortCut "$SMPROGRAMS\qBittorrent\$(inst_uninstall_link_description).lnk" "$INSTDIR\uninst.exe"
87 Section /o $(inst_startup) ;"Start qBittorrent on Windows start up"
89 !insertmacro UAC_AsUser_Call Function inst_startup_user ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR}
93 Function inst_startup_user
95 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "qBittorrent" "$INSTDIR\qbittorrent.exe"
99 Section $(inst_firewall)
101 DetailPrint $(inst_firewallinfo)
102 nsisFirewallW::AddAuthorizedApplication "$INSTDIR\qbittorrent.exe" "qBittorrent"
106 Section $(inst_pathlimit) ;"Disable Windows path length limit (260 character MAX_PATH limitation, requires Windows 10 1607 or later)"
108 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\FileSystem" "LongPathsEnabled" 1
112 ;--------------------------------
116 !insertmacro Init "installer"
117 !insertmacro MUI_LANGDLL_DISPLAY
119 ${IfNot} ${AtLeastWaaS} 1809 ; Windows 10 (1809) / Windows Server 2019. Min supported version by Qt6
120 MessageBox MB_OK|MB_ICONEXCLAMATION $(inst_requires_win10) /SD IDOK
121 SetErrorLevel 1654 # WinError.h: `ERROR_INSTALL_REJECTED`
125 ${IfNot} ${RunningX64}
126 MessageBox MB_OK|MB_ICONEXCLAMATION $(inst_requires_64bit) /SD IDOK
127 SetErrorLevel 1654 # WinError.h: `ERROR_INSTALL_REJECTED`
131 ;Search if qBittorrent is already installed.
132 FindFirst $0 $1 "$INSTDIR\uninst.exe"
136 ;Copy old value to var so we can call the correct uninstaller
137 StrCpy $uninstallerPath $INSTDIR
140 MessageBox MB_OKCANCEL|MB_ICONINFORMATION $(inst_uninstall_question) /SD IDOK IDOK done
147 Function check_instance
150 FindProcDLL::FindProc "qbittorrent.exe"
151 StrCmp $R0 "1" 0 notfound
152 MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(inst_warning) /SD IDCANCEL IDRETRY check IDCANCEL canceled
155 SetErrorLevel 15618 # WinError.h: `ERROR_PACKAGES_IN_USE`
162 Function PageFinishRun
164 !insertmacro UAC_AsUser_ExecShell "" "$INSTDIR\qbittorrent.exe" "" "" ""
168 Function .onInstSuccess