1 ;Start of user configurable options
2 ;==============================================================================
4 ; Uncomment if you want to use UPX to pack the installer header
5 ; Doing so may make antivirus software flag the installer as virus/malware
8 ; Uncomment when packaging 64bit qbittorrent
11 ; Uncomment when packaging qt6 qbittorrent
12 ; It will also define QBT_IS_X64
16 !define /redef QBT_IS_X64
20 ; The string MUST contain ONLY numbers delimited by dots.
21 ; It MUST contain a maximum of 4 delimited numbers
22 ; Other values will result in undefined behavior
28 !define /ifndef QBT_VERSION
"4.6.1"
30 ; Option that controls the installer's window name
31 ; If set, its value will be used like this:
32 ; "qBittorrent ${QBT_INSTALLER_FILENAME}"
33 ; If not set, the window name will be auto composed from QBT_VERSION, QBT_USES_QT6, QBT_IS_X64
34 ; If you set this define then you MUST set QBT_INSTALLER_FILENAME too. Otherwise it will be ignored.
35 ; This define is meant to ease automation from scripts/commandline
36 ;!define QBT_INSTALLER_WINDOWNAME
38 ; Option that controls the installer's window name
39 ; If set, its value will be used like this:
40 ; "qbittorrent_${QBT_INSTALLER_FILENAME}_setup.exe"
41 ; If not set, the window name will be auto composed from QBT_VERSION, QBT_USES_QT6, QBT_IS_X64
42 ; If you set this define then you MUST set QBT_INSTALLER_WINDOWNAME too. Otherwise it will be ignored.
43 ; This define is meant to ease automation from scripts/commandline
44 ;!define QBT_INSTALLER_FILENAME
46 ;End of user configurable options
47 ;==============================================================================
49 !ifndef QBT_INSTALLER_WINDOWNAME | QBT_INSTALLER_FILENAME
51 ; The name of the installer
52 !define QBT_INSTALLER_WINDOWNAME
"${QBT_VERSION}"
55 !define QBT_INSTALLER_FILENAME
"${QBT_VERSION}"
58 ; The name of the installer
59 !define QBT_INSTALLER_WINDOWNAME
"${QBT_VERSION} x64"
62 !define QBT_INSTALLER_FILENAME
"${QBT_VERSION}_x64"
64 ; The name of the installer
65 !define QBT_INSTALLER_WINDOWNAME
"${QBT_VERSION} (qt6) x64"
68 !define QBT_INSTALLER_FILENAME
"${QBT_VERSION}_qt6_x64"
77 !packhdr "$%TEMP%\exehead.tmp" 'upx.exe -9 --best --ultra-brute "$%TEMP%\exehead.tmp"'
80 ;Setting the compression
81 SetCompressor
/SOLID LZMA
82 SetCompressorDictSize
64
87 !include "FileFunc.nsh"
92 !include "3rdparty\VersionCompleteXXXX.nsi"
94 ;For the file association
95 !define SHCNE_ASSOCCHANGED
0x8000000
96 !define SHCNF_IDLIST
0
98 ;For special folder detection
99 !define CSIDL_APPDATA
'0x1A' ;Application Data path
100 !define CSIDL_LOCALAPPDATA
'0x1C' ;Local Application Data path
102 !define MUI_FINISHPAGE_RUN
103 !define MUI_FINISHPAGE_RUN_FUNCTION PageFinishRun
104 !define MUI_FINISHPAGE_RUN_TEXT
$(launch_qbt
)
106 ; The name of the installer
107 Name "qBittorrent ${QBT_INSTALLER_WINDOWNAME}"
110 OutFile "qbittorrent_${QBT_INSTALLER_FILENAME}_setup.exe"
112 ;Installer Version Information
113 VIAddVersionKey
"ProductName" "qBittorrent"
114 VIAddVersionKey
"CompanyName" "The qBittorrent project"
115 VIAddVersionKey
"LegalCopyright" "Copyright ©2006-2023 The qBittorrent project"
116 VIAddVersionKey
"FileDescription" "qBittorrent - A Bittorrent Client"
117 VIAddVersionKey
"FileVersion" "${QBT_VERSION}"
119 ; VIProductVersion needs a 4 part version.
120 ; If QBT_VERSION contains less than 4 parts then VersionCompleteXXXX, will extend it with zeroes.
121 ${VersionCompleteXXXX} ${QBT_VERSION} VERSION_4_PART
122 VIProductVersion
"${VERSION_4_PART}"
124 ; The default installation directory. It changes depending if we install in the 64bit dir or not.
125 ; A caveat of this is if a user has installed a 32bit version and then runs the 64bit installer
126 ; (which in turn launches the 32bit uninstaller first) the value will still point to the 32bit location.
127 ; The user has to manually uninstall the old version and THEN run the 64bit installer
129 InstallDir $PROGRAMFILES32\qBittorrent
131 InstallDir $PROGRAMFILES64\qBittorrent
134 ; Registry key to check for directory (so if you install again, it will
135 ; overwrite the old one automatically)
136 InstallDirRegKey HKLM Software\qbittorrent InstallLocation
138 ; Request application privileges for Windows Vista
139 RequestExecutionLevel user
141 ;--------------------------------
143 !define MUI_ABORTWARNING
144 !define MUI_HEADERIMAGE
145 !define MUI_COMPONENTSPAGE_NODESC
146 ;!define MUI_ICON "qbittorrent.ico"
147 !define MUI_LICENSEPAGE_CHECKBOX
148 !define MUI_LANGDLL_ALLLANGUAGES
150 ;--------------------------------
151 ;Remember the unistaller/installer language
152 !define MUI_LANGDLL_REGISTRY_ROOT
"HKLM"
153 !define MUI_LANGDLL_REGISTRY_KEY
"Software\qbittorrent"
154 !define MUI_LANGDLL_REGISTRY_VALUENAME
"Installer Language"
156 ;--------------------------------
158 !insertmacro MUI_PAGE_WELCOME
159 !insertmacro MUI_PAGE_LICENSE
"license.txt"
160 !insertmacro MUI_PAGE_COMPONENTS
161 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE check_instance
162 !insertmacro MUI_PAGE_DIRECTORY
163 !insertmacro MUI_PAGE_INSTFILES
164 !insertmacro MUI_PAGE_FINISH
166 ;--------------------------------
168 !insertmacro MUI_UNPAGE_CONFIRM
169 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE un
.check_instance
170 !insertmacro MUI_UNPAGE_COMPONENTS
171 !insertmacro MUI_UNPAGE_INSTFILES
173 !insertmacro MUI_RESERVEFILE_LANGDLL
174 ReserveFile
"${NSISDIR}\Plugins\x86-unicode\FindProcDLL.dll"
175 ReserveFile
"${NSISDIR}\Plugins\x86-unicode\UAC.dll"
179 !insertmacro UAC_RunElevated
182 ${IfThen} $1 =
1 ${|
} Quit ${|
} ;we are the outer process, the inner process has done its work, we are done
183 ${IfThen} $3 <> 0 ${|
} ${Break} ${|
} ;we are admin, let the show go on
184 ${If} $1 =
3 ;RunAs completed successfully, but with a non-admin user
185 MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground
"This ${thing} requires admin privileges, try again" /SD
IDNO IDYES uac_tryagain
IDNO 0
187 ;fall-through and die
189 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground
"This ${thing} requires admin privileges, aborting!"
192 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground
"Logon service not running, aborting!"
195 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground
"Unable to elevate , error $0"
199 SetShellVarContext all