Bump to 4.6.1
[qBittorrent.git] / dist / windows / config.nsi
blob35a2e09545ba57f4f0dd05a2419a3585617ee123
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
6 ;!define USE_UPX
8 ; Uncomment when packaging 64bit qbittorrent
9 ;!define QBT_IS_X64
11 ; Uncomment when packaging qt6 qbittorrent
12 ; It will also define QBT_IS_X64
13 ;!define QBT_USES_QT6
15 !ifdef QBT_USES_QT6
16 !define /redef QBT_IS_X64
17 !endif
19 ; qBittorrent version
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
23 ; examples:
24 ; 4.5.0 -> good
25 ; 4.5.1.3 -> good
26 ; 4.5.1.3.2 -> bad
27 ; 4.5.0beta -> bad
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
50 !ifndef QBT_IS_X64
51 ; The name of the installer
52 !define QBT_INSTALLER_WINDOWNAME "${QBT_VERSION}"
54 ; The file to write
55 !define QBT_INSTALLER_FILENAME "${QBT_VERSION}"
56 !else ; QBT_IS_X64
57 !ifndef QBT_USES_QT6
58 ; The name of the installer
59 !define QBT_INSTALLER_WINDOWNAME "${QBT_VERSION} x64"
61 ; The file to write
62 !define QBT_INSTALLER_FILENAME "${QBT_VERSION}_x64"
63 !else ; QBT_USES_QT6
64 ; The name of the installer
65 !define QBT_INSTALLER_WINDOWNAME "${QBT_VERSION} (qt6) x64"
67 ; The file to write
68 !define QBT_INSTALLER_FILENAME "${QBT_VERSION}_qt6_x64"
69 !endif ; QBT_USES_QT6
70 !endif ; QBT_IS_X64
71 !endif
73 Unicode true
74 ManifestDPIAware true
76 !ifdef USE_UPX
77 !packhdr "$%TEMP%\exehead.tmp" 'upx.exe -9 --best --ultra-brute "$%TEMP%\exehead.tmp"'
78 !endif
80 ;Setting the compression
81 SetCompressor /SOLID LZMA
82 SetCompressorDictSize 64
83 XPStyle on
85 !include "MUI2.nsh"
86 !include "UAC.nsh"
87 !include "FileFunc.nsh"
88 !include "WinVer.nsh"
89 !ifdef QBT_IS_X64
90 !include "x64.nsh"
91 !endif
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}"
109 ; The file to write
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
128 !ifndef QBT_IS_X64
129 InstallDir $PROGRAMFILES32\qBittorrent
130 !else
131 InstallDir $PROGRAMFILES64\qBittorrent
132 !endif
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 ;--------------------------------
142 ;General Settings
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 ;--------------------------------
157 ;Installer Pages
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 ;--------------------------------
167 ;Uninstaller Pages
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"
177 !macro Init thing
178 uac_tryagain:
179 !insertmacro UAC_RunElevated
180 ${Switch} $0
181 ${Case} 0
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
186 ${EndIf}
187 ;fall-through and die
188 ${Case} 1223
189 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, aborting!"
190 Quit
191 ${Case} 1062
192 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
193 Quit
194 ${Default}
195 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate , error $0"
196 Quit
197 ${EndSwitch}
199 SetShellVarContext all
200 !macroend