Skip to content

Commit 41fd313

Browse files
committed
Update Windows Installer to detect old NSIS installer
NSIS was used up to v3.10.1 and then we moved to MSI. The Windows Installer will now be able to detect if a previous version was installed using NSIS and uninstall it before installing the new version. See issue #1642.
1 parent 4131283 commit 41fd313

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

installer/windows/product.wxs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,39 @@
257257

258258
<Property Id="MsiLogging" Value="voicewarmupx" />
259259

260+
<!-- ======================================== Remove old NSIS installer ======================================== -->
261+
<!--
262+
When the application is installed using the NSIS installer, the installer writes a key in the registry. We will
263+
use this fact to check if an older version (up to v3.10.1) of the application is installed. If found, we will
264+
remove it before installing the application with the new MSI installer.
265+
266+
NSIS installer writes the following key "HKLM\Software\<Company>\<Product>" in the registry after installation.
267+
So the right key to search for is "HKLM\Software\DB Browser for SQLite Team\DB Browser for SQLite".
268+
269+
But the installer itself is a 32-bit application, and it can't write to the 64-bit registry. This works without
270+
a problem on 32-bit Windows. On 64-bit Winodws however, the key is written in the 32-bit registry, under the
271+
"Wow6432Node" key.
272+
273+
Therefore, the `Win64="no"` attribute is needed to disable searching in the 64-bit registry. On 32-bit Windows
274+
the right key is searched, and on 64-bit Windows the same key is searched but under the "Wow6432Node" key.
275+
-->
276+
277+
<!-- Search the registry to find the location of NSIS installation folder, and set "NSIS_INSTALLDIR" to its path. -->
278+
<Property Id="NSIS_INSTALLDIR">
279+
<RegistrySearch Id="RS_NSIS" Root="HKLM" Key="Software\DB Browser for SQLite Team\DB Browser for SQLite" Win64="no" Type="raw" />
280+
</Property>
281+
282+
<!-- If registry search was successful, "NSIS_UNINSTALLER" property will hold the full path to "Uninstall.exe" -->
283+
<SetProperty Id="NSIS_UNINSTALLER" Value="[NSIS_INSTALLDIR]\Uninstall.exe" After="AppSearch">NSIS_INSTALLDIR</SetProperty>
284+
285+
<!-- Run "Uninstall.exe /S" to silently remove the older version of the application. -->
286+
<CustomAction Id="CA_NSIS_UNINSTALL" Property="NSIS_UNINSTALLER" ExeCommand="/S" Execute="deferred" Impersonate="no" />
287+
288+
<!-- Schedule the custom action above to run after "RemoveExistingProducts". -->
289+
<InstallExecuteSequence>
290+
<Custom Action='CA_NSIS_UNINSTALL' After='RemoveExistingProducts'>NSIS_INSTALLDIR</Custom>
291+
</InstallExecuteSequence>
292+
260293
</Product>
261294

262295
</Wix>

0 commit comments

Comments
 (0)