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
9 ; The string MUST contain ONLY numbers delimited by dots.
10 ; It MUST contain a maximum of 4 delimited numbers
11 ; Other values will result in undefined behavior
17 !define /ifndef QBT_VERSION "5.1.0"
19 ; Option that controls the installer's window name
20 ; If set, its value will be used like this:
21 ; "qBittorrent ${QBT_INSTALLER_FILENAME}"
22 ; If not set, the window name will be auto composed from QBT_VERSION
23 ; If you set this define then you MUST set QBT_INSTALLER_FILENAME too. Otherwise it will be ignored.
24 ; This define is meant to ease automation from scripts/commandline
25 ;!define QBT_INSTALLER_WINDOWNAME
27 ; Option that controls the installer's window name
28 ; If set, its value will be used like this:
29 ; "qbittorrent_${QBT_INSTALLER_FILENAME}_setup.exe"
30 ; If not set, the installer filename will be auto composed from QBT_VERSION
31 ; If you set this define then you MUST set QBT_INSTALLER_WINDOWNAME too. Otherwise it will be ignored.
32 ; This define is meant to ease automation from scripts/commandline
33 ;!define QBT_INSTALLER_FILENAME
35 ;End of user configurable options
36 ;==============================================================================
38 !ifndef QBT_INSTALLER_WINDOWNAME | QBT_INSTALLER_FILENAME
39 ; The name of the installer
40 !define QBT_INSTALLER_WINDOWNAME "${QBT_VERSION} x64"
43 !define QBT_INSTALLER_FILENAME "${QBT_VERSION}_x64"
46 !define /ifndef QBT_DIST_DIR "qBittorrent"
47 !define /ifndef QBT_NSIS_PLUGINS_DIR "NSISPlugins"
53 !packhdr "$%TEMP%\exehead.tmp" 'upx.exe -9 --best --ultra-brute "$%TEMP%\exehead.tmp"'
56 ;Setting the compression
57 SetCompressor /SOLID LZMA
58 SetCompressorDictSize 64
63 !include "FileFunc.nsh"
66 !include "3rdparty\VersionCompleteXXXX.nsi"
68 ;For the file association
69 !define SHCNE_ASSOCCHANGED 0x8000000
70 !define SHCNF_IDLIST 0
72 ;For special folder detection
73 !define CSIDL_APPDATA '0x1A' ;Application Data path
74 !define CSIDL_LOCALAPPDATA '0x1C' ;Local Application Data path
76 !define MUI_FINISHPAGE_RUN
77 !define MUI_FINISHPAGE_RUN_FUNCTION PageFinishRun
78 !define MUI_FINISHPAGE_RUN_TEXT $(launch_qbt)
80 ; The name of the installer
81 Name "qBittorrent ${QBT_INSTALLER_WINDOWNAME}"
84 OutFile "qbittorrent_${QBT_INSTALLER_FILENAME}_setup.exe"
86 ;Installer Version Information
87 VIAddVersionKey "ProductName" "qBittorrent"
88 VIAddVersionKey "CompanyName" "The qBittorrent project"
89 VIAddVersionKey "LegalCopyright" "Copyright ©2006-2024 The qBittorrent project"
90 VIAddVersionKey "FileDescription" "qBittorrent - A Bittorrent Client"
91 VIAddVersionKey "FileVersion" "${QBT_VERSION}"
93 ; VIProductVersion needs a 4 part version.
94 ; If QBT_VERSION contains less than 4 parts then VersionCompleteXXXX, will extend it with zeroes.
95 ${VersionCompleteXXXX} ${QBT_VERSION} VERSION_4_PART
96 VIProductVersion "${VERSION_4_PART}"
98 ; The default installation directory.
99 InstallDir $PROGRAMFILES64\qBittorrent
101 ; Registry key to check for directory (so if you install again, it will
102 ; overwrite the old one automatically)
103 InstallDirRegKey HKLM Software\qbittorrent InstallLocation
105 ; Request application privileges for Windows Vista
106 RequestExecutionLevel user
108 ;--------------------------------
110 !define MUI_ABORTWARNING
111 !define MUI_HEADERIMAGE
112 !define MUI_COMPONENTSPAGE_NODESC
113 ;!define MUI_ICON "qbittorrent.ico"
114 !define MUI_LICENSEPAGE_CHECKBOX
115 !define MUI_LANGDLL_ALLLANGUAGES
117 ;--------------------------------
118 ;Remember the uninstaller/installer language
119 !define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
120 !define MUI_LANGDLL_REGISTRY_KEY "Software\qbittorrent"
121 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
123 ;--------------------------------
125 !insertmacro MUI_PAGE_WELCOME
126 !insertmacro MUI_PAGE_LICENSE "license.txt"
127 !insertmacro MUI_PAGE_COMPONENTS
128 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE check_instance
129 !insertmacro MUI_PAGE_DIRECTORY
130 !insertmacro MUI_PAGE_INSTFILES
131 !insertmacro MUI_PAGE_FINISH
133 ;--------------------------------
135 !insertmacro MUI_UNPAGE_CONFIRM
136 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.check_instance
137 !insertmacro MUI_UNPAGE_COMPONENTS
138 !insertmacro MUI_UNPAGE_INSTFILES
140 !insertmacro MUI_RESERVEFILE_LANGDLL
142 !addplugindir /x86-unicode "${QBT_NSIS_PLUGINS_DIR}"
143 ReserveFile /plugin FindProcDLL.dll
144 ReserveFile /plugin UAC.dll
148 !insertmacro UAC_RunElevated
151 ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
152 ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
153 ${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
154 MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0
156 ;fall-through and die
158 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, aborting!"
161 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
164 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate , error $0"
168 SetShellVarContext all