NSIS: Require Windows 10 1809 for Qt6 builds
[qBittorrent.git] / dist / windows / config.nsi
blob1d5d3e5293bb2df3ac9fd14cf4fa3c48ed0e6c60
1 ; Uncomment when packaging 64bit qbittorrent
2 ;!define QBT_IS_X64
4 ; Uncomment when packaging qt6 qbittorrent
5 ; It will also define QBT_IS_X64
6 ;!define QBT_USES_QT6
8 !ifdef QBT_USES_QT6
9 !define /redef QBT_IS_X64
10 !endif
12 ; qBittorrent version
13 !define /ifndef QBT_VERSION "4.5.0"
15 Unicode true
16 ManifestDPIAware true
17 ;Compress the header too
18 !packhdr "$%TEMP%\exehead.tmp" 'upx.exe -9 --best --ultra-brute "$%TEMP%\exehead.tmp"'
20 ;Setting the compression
21 SetCompressor /SOLID LZMA
22 SetCompressorDictSize 64
23 XPStyle on
25 !include "MUI.nsh"
26 !include "UAC.nsh"
27 !include "FileFunc.nsh"
28 !include "WinVer.nsh"
29 !ifdef QBT_IS_X64
30 !include "x64.nsh"
31 !endif
33 ;For the file association
34 !define SHCNE_ASSOCCHANGED 0x8000000
35 !define SHCNF_IDLIST 0
37 ;For special folder detection
38 !define CSIDL_APPDATA '0x1A' ;Application Data path
39 !define CSIDL_LOCALAPPDATA '0x1C' ;Local Application Data path
41 !define MUI_FINISHPAGE_RUN
42 !define MUI_FINISHPAGE_RUN_FUNCTION PageFinishRun
43 !define MUI_FINISHPAGE_RUN_TEXT $(launch_qbt)
45 !ifndef QBT_IS_X64
46 ; The name of the installer
47 Name "qBittorrent ${QBT_VERSION}"
49 ; The file to write
50 OutFile "qbittorrent_${QBT_VERSION}_setup.exe"
51 !else ; QBT_IS_X64
52 !ifndef QBT_USES_QT6
53 ; The name of the installer
54 Name "qBittorrent ${QBT_VERSION} x64"
56 ; The file to write
57 OutFile "qbittorrent_${QBT_VERSION}_x64_setup.exe"
58 !else ; QBT_USES_QT6
59 ; The name of the installer
60 Name "qBittorrent ${QBT_VERSION} (qt6) x64"
62 ; The file to write
63 OutFile "qbittorrent_${QBT_VERSION}_qt6_x64_setup.exe"
64 !endif ; QBT_USES_QT6
65 !endif ; QBT_IS_X64
67 ;Installer Version Information
68 VIAddVersionKey "ProductName" "qBittorrent"
69 VIAddVersionKey "CompanyName" "The qBittorrent project"
70 VIAddVersionKey "LegalCopyright" "Copyright ©2006-2022 The qBittorrent project"
71 VIAddVersionKey "FileDescription" "qBittorrent - A Bittorrent Client"
72 VIAddVersionKey "FileVersion" "${QBT_VERSION}"
74 VIProductVersion "${QBT_VERSION}.0"
76 ; The default installation directory. It changes depending if we install in the 64bit dir or not.
77 ; A caveat of this is if a user has installed a 32bit version and then runs the 64bit installer
78 ; (which in turn launches the 32bit uninstaller first) the value will still point to the 32bit location.
79 ; The user has to manually uninstall the old version and THEN run the 64bit installer
80 !ifndef QBT_IS_X64
81 InstallDir $PROGRAMFILES32\qBittorrent
82 !else
83 InstallDir $PROGRAMFILES64\qBittorrent
84 !endif
86 ; Registry key to check for directory (so if you install again, it will
87 ; overwrite the old one automatically)
88 InstallDirRegKey HKLM Software\qbittorrent InstallLocation
90 ; Request application privileges for Windows Vista
91 RequestExecutionLevel user
93 ;--------------------------------
94 ;General Settings
95 !define MUI_ABORTWARNING
96 !define MUI_HEADERIMAGE
97 !define MUI_COMPONENTSPAGE_NODESC
98 ;!define MUI_ICON "qbittorrent.ico"
99 !define MUI_LICENSEPAGE_CHECKBOX
100 !define MUI_LANGDLL_ALLLANGUAGES
102 ;--------------------------------
103 ;Remember the unistaller/installer language
104 !define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
105 !define MUI_LANGDLL_REGISTRY_KEY "Software\qbittorrent"
106 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
108 ;--------------------------------
109 ;Installer Pages
110 !insertmacro MUI_PAGE_WELCOME
111 !insertmacro MUI_PAGE_LICENSE "license.txt"
112 !insertmacro MUI_PAGE_COMPONENTS
113 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE check_instance
114 !insertmacro MUI_PAGE_DIRECTORY
115 !insertmacro MUI_PAGE_INSTFILES
116 !insertmacro MUI_PAGE_FINISH
118 ;--------------------------------
119 ;Uninstaller Pages
120 !insertmacro MUI_UNPAGE_CONFIRM
121 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.check_instance
122 !insertmacro MUI_UNPAGE_COMPONENTS
123 !insertmacro MUI_UNPAGE_INSTFILES
125 !insertmacro MUI_RESERVEFILE_LANGDLL
126 ReserveFile "${NSISDIR}\Plugins\x86-unicode\FindProcDLL.dll"
127 ReserveFile "${NSISDIR}\Plugins\x86-unicode\UAC.dll"
129 !macro Init thing
130 uac_tryagain:
131 !insertmacro UAC_RunElevated
132 ${Switch} $0
133 ${Case} 0
134 ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
135 ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
136 ${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
137 MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0
138 ${EndIf}
139 ;fall-through and die
140 ${Case} 1223
141 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, aborting!"
142 Quit
143 ${Case} 1062
144 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
145 Quit
146 ${Default}
147 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate , error $0"
148 Quit
149 ${EndSwitch}
151 SetShellVarContext all
152 !macroend